Create an R6
object for throttling.
Arguments
- seconds_max
Positive numeric scalar, maximum throttling interval
- seconds_min
Positive numeric scalar, minimum throttling interval.
- seconds_start
Positive numeric scalar, the initial wait time interval in seconds. The default is
min
because there is almost always auto-scaling to be done when the controller is created.reset()
always sets the current wait interval back toseconds_start
.- base
Numeric scalar greater than 1, base of the exponential backoff algorithm.
increment()
multiplies the waiting interval bybase
anddecrement()
divides the waiting interval bybase
. The defaultbase
is 2, which specifies a binary exponential backoff algorithm.
Details
Throttling is a technique that limits how often a function is
called in a given period of time. crew_throttle()
objects support
the throttle
argument of controller methods, which ensures auto-scaling
does not induce superfluous overhead.
The throttle uses deterministic exponential backoff algorithm
(https://en.wikipedia.org/wiki/Exponential_backoff) which
increases wait times when there is nothing to do and decreases
wait times when there is something to do. The controller decreases
or increases the wait time with methods accelerate()
and decelerate()
in the throttle object, respectively,
by dividing or multiplying by base
(but keeping the wait time
between seconds_min
and seconds_max
).
In practice, crew
calls reset()
instead of update()
in order to respond quicker to surges of activity (see the
update()
method).
See also
Other throttle:
crew_class_throttle