Class ContentionStrategy
- java.lang.Object
-
- org.apache.cassandra.service.paxos.ContentionStrategy
-
public class ContentionStrategy extends java.lang.ObjectA strategy for making back-off decisions for Paxos operations that fail to make progress because of other paxos operations. The strategy is defined by four factors:
-
min -
max -
minDelta -
waitRandomizer
The first three represent time periods, and may be defined dynamically based on a simple calculation over:
-
pX()recent experienced latency distribution for successful operations, e.g.p50(rw)the maximum of read and write median latencies,p999(r)the 99.9th percentile of read latencies -
attemptsthe number of failed attempts made by the operation so far -
constanta user provided floating point constant
Their calculation may take any of these forms
- constant
$constant$[mu]s- dynamic constant
pX() * constant- dynamic linear
pX() * constant * attempts- dynamic exponential
pX() * constant ^ attemptsFurthermore, the dynamic calculations can be bounded with a min/max, like so:
min[mu]s <= dynamic expr <= max[mu]se.g.10ms <= p50(rw)*0.6610ms <= p95(rw)*1.8^attempts <= 100ms5ms <= p50(rw)*0.5These calculations are put together to construct a range from which we draw a random number. The period we wait for
Xwill be drawn so thatmin <= X < max.With the constraint that
maxmust beminDeltagreater thanmin, but no greater than its expression-defined maximum.maxwill be increased up until this point, after whichminwill be decreased until this gap is imposed.The
waitRandomizerproperty specifies the manner in which a random value is drawn from the range. It is defined using one of the following specifiers:- uniform
- exp($power$) or exponential($power$)
- qexp($power$) or qexponential($power$) or quantizedexponential($power$) The uniform specifier is self-explanatory, selecting all values in the range with equal probability. The exponential specifier draws values towards the end of the range with higher probability, raising a floating point number in the range [0..1.0) to the power provided, and translating the resulting value to a uniform value in the range. The quantized exponential specifier partitions the range into
attemptsbuckets, then applies the pure exponential approach to draw values from [0..attempts), before drawing a uniform value from the corresponding bucketFinally, there is also a
traceAfterAttemptsproperty that permits initiating tracing of operations that experience a certain minimum number of failed paxos rounds due to contention. A setting of 0 or 1 will initiate a trace session after the first failed ballot. -
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classContentionStrategy.Type
-
Constructor Summary
Constructors Constructor Description ContentionStrategy(java.lang.String waitRandomizer, java.lang.String min, java.lang.String max, java.lang.String minDelta, int traceAfterAttempts)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgetStrategySpec()static voidsetStrategy(java.lang.String spec)
-