Class ContentionStrategy
- java.lang.Object
-
- org.apache.cassandra.service.paxos.ContentionStrategy
-
public class ContentionStrategy extends java.lang.Object
A 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:
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 -
attempts
the number of failed attempts made by the operation so far -
constant
a 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 ^ attempts
Furthermore, the dynamic calculations can be bounded with a min/max, like so:
min[mu]s <= dynamic expr <= max[mu]s
e.g.10ms <= p50(rw)*0.66
10ms <= p95(rw)*1.8^attempts <= 100ms
5ms <= p50(rw)*0.5
These calculations are put together to construct a range from which we draw a random number. The period we wait for
X
will be drawn so thatmin <= X < max
.With the constraint that
max
must beminDelta
greater thanmin
, but no greater than its expression-defined maximum.max
will be increased up until this point, after whichmin
will be decreased until this gap is imposed.The
waitRandomizer
property 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
attempts
buckets, 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
traceAfterAttempts
property 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 class
ContentionStrategy.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.String
getStrategySpec()
static void
setStrategy(java.lang.String spec)
-