sregulator_codel_valve (sbroker v1.1.1)
Implements a valve which increases its size based on CoDel (Controlling Queue Delay).
sregulator_codel_valve
can be used as the sregulator_valve
in a sregulator
. It will provide a valve that increases in size in decreasing intervals while updates remain below a target (based on CoDel) between the minimum and maximum capacity. Its argument, spec()
, is of the form: #{target => Target :: integer(), % default: 100
interval => Interval :: pos_integer(), % default: 1000
min => Min :: non_neg_integer(), % default: 0
max => Max :: non_neg_integer() | infinity} % default: infinity
Target
is the target relative value in milliseconds. Interval
is the initial interval in milliseconds. The valve will open when updates remain below the target (in native
time units) for an interval. Each consecutive interval is smaller than the last until an update above the target is received. The valve is always open when below the minimum and always closed once it reaches the maximum.
This valve tries to enforce a minimum level of concurrency and will grow while a relevant sbroker_queue
is moving quickly - up to a maximum. Therefore this valves expects the updates to be from a sregulator_update_meter
.
The algorithm used in this valve is similar to sbroker_codel_queue
, except designed to keep the relevant queue slow (but not too slow) instead of fast. Therefore trying to ensure the counter party to the queue is always fast without using too many resources. This works by increasing the concurrency or number of requests when the queue is consistently fast and remaining static when the queue is slow. Therefore forcing the queue to be slightly slow.
This valve is designed to be used a sbroker_codel_queue
with the same Interval
and Target
s that are between 10% and 20% of the Interval
. The target range is suggested due to the observation in the CoDel paper that the queue goes from to fast to slow over this target range. Higher targets result in heavily congested queues and wasted resources. A suggested initial Interval
is the 95% percentile of the time it takes to stop a task and restart, as this is equivalent to the round trip when a packet is dropped and resent to rejoin the queue in the paper.
Decreasing the target of the valve makes it more resistant to bursts and reducing the target of the queue will increase the rate of shrinking when load decreases. This fulfils the general desire to increase resouce usage as late as possible and decrease resource usage as early as possible. If the queue's target is significantly lower than valve's this may lead to churn as the queue and valve may act against each other. Also if the minimum is too high the queue may drop the requests only for the valve to allow immediate enqueues.
More investigation needs to be done on suitable parameters.Link to this section Summary
Link to this section Types
spec/0
Specs
spec() :: #{target => Target :: integer(), interval => Interval :: pos_integer(), min => Min :: non_neg_integer(), max => Max :: non_neg_integer() | infinity}.