Skip to content

Implement adaptive calculator for concurrency limiter

Quang-Minh Nguyen requested to merge qmnguyen0711/implement-aimd-calculator into master

For #5372 (closed)

This MR implements a calculator to calculate the adaptive limits based on the Additive increase/multiplicative decrease (AIMD) algorithm. This method involves gradually increasing the limit during normal process functioning but quickly reducing it when an issue (backoff event) occurs.

The calculator receives a list of AdaptiveLimiter and a list of ResourceWatcher. Although the limits may have different settings (Initial, Min, Max, BackoffFactor), they all move as a whole. The caller accesses the current limits via AdaptiveLimiter.Current method.

When the calculator starts, each limit value is set to its Initial limit. Periodically, the calculator polls the backoff events from the watchers. The current value of each limit is re-calibrated as follows:

  • limit = limit + 1 if there is no backoff event since the last calibration. The new limit cannot exceed the max limit.
  • limit = limit * BackoffFactor otherwise. The new limit cannot be lower than min limit.

This MR doesn't implement any resource watcher. We'll integrate the resource watcher in #5370 (closed).

Merge request reports