View Source Regulator.Limit.AIMD (Regulator v0.6.0)
Loss based dynamic limit algorithm. Additively increases the concurrency limit when there are no errors and multiplicatively decrements the limit when there are errors.
To use this regulator you must specify a "target average latency". Regulator collects measurements of your service calls and averages them over a sliding window. If the average latency is above the target specified, regulator considers it an error and will begin to multiplicatively decrease the concurrency limit. If the avg latency is below the target and over half of the concurrency tokens were utilized during the window, then regulator will increase the concurrency limit by a fixed value. If less than half of the concurrency tokens were utilized in the window, Regulator leaves the concurrency limit as is, since there is no need for additional tokens.
Finally, if there was any errors that occured during the window, Regulator treats that as a backoff situation and will begin to reduce the concurrency limit.
Options
:min_limit
- The minimum concurrency limit (defaults to 5):initial_limit
- The initial concurrency limit when the regulator is installed (deafults to 20):max_limit
- The maximum concurrency limit (defaults to 200):step_increase
- The number of tokens to add when regulator is increasing the concurrency limit (defaults to 10).:backoff_ratio
- Floating point value for how quickly to reduce the concurrency limit (defaults to 0.9):target_avg_latency
- This is the average latency in milliseconds for the system regulator is protecting. If the average latency drifts above this value Regulator considers it an error and backs off. Defaults to 5.:timeout
- alias fortarget_avg_latency
.