Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AIMDConfig ¶
type AIMDConfig struct { // MinimumLimit is the mimimum limit the algorithm will decrease. It also will start with this limit. MinimumLimit int // This is like TCP algorithms `ssthresh`. It will start increasing the limit by one // and when reached to this threshold it will change the mode and increase slowly. // If set to 0 then slow start will be disabled. SlowStartThreshold int // RTTTimeout is the rtt is greater than this value it will be measured as a failure. RTTTimeout time.Duration // BackoffRatio is the ratio used to decrease the limit when a failure occurs. // this will be the way is used: new limit = current limit * backoffRatio. BackoffRatio float64 // LimitIncrementInflightFactor will increment the limit only if inflight * LimitIncrementInflightFactor > limit LimitIncrementInflightFactor int }
AIMDConfig is the configuration of the algorithm used for the AIMD adaptive limit.
type Limiter ¶
type Limiter interface { // MeasureSample will measure the sample of an execution. This data will be used // by the algorithm to know what should be the limit. // It also returns the current limit after measuring the samples. MeasureSample(startTime time.Time, inflight int, result Result) int // Gets the current limit. GetLimit() int }
Limiter knows what should be the concurrency limit based on the measured results. These are based on TCP congestion control algorithms.
func NewAIMD ¶
func NewAIMD(cfg AIMDConfig) Limiter
NewAIMD returns a new aimd adaptive Limiter algorithm, based on the TCP congestion algorithm with the same name. It increases the limit at a constant rate and when congestion occurs it will decrease by a configured factor. More information about this algorithm in: https://en.wikipedia.org/wiki/Additive_increase/multiplicative_decrease
Click to show internal directories.
Click to hide internal directories.