Module sregulator_relative_valve

Implements a valve which increases its size based on updates being below a target between a minimum and maximum capacity.

Behaviours: sregulator_valve.

Description

Implements a valve which increases its size based on updates being below a target between a minimum and maximum capacity.

sregulator_relative_value can be used as the sregulator_valve in a sregulator. Its argument is of the form:
  {Target :: integer(), Min :: non_neg_integer(),
   Max :: non_neg_integer() | infinity}

Target is the target relative value in milliseconds. The valve will open when an update below the target (in native time units) is received if between the the minimum, Min, and the maximum, Max. Once opened by an update the valve remains open until the concurrency level increases by 1 or an update greater than 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 samples from the RelativeTime in go tuples. For example:
  {go, _Ref, _Value, RelativeTime, _SojournTime} = sbroker:ask(Broker),
  sregulator:update(Regulator, RelativeTime).

To grow when a queue is moving slowly use -RelativeTime.

By using a positive target RelativeTime of an sbroker queue, a pool of workers can grow before the queue is empty. Therefore preventing or delaying the situation where the counter party client processes have to wait for a worker.

By using a negative target RelativeTime of an sbroker queue, a pool of expensive resources can delay growth until required.

Generated by EDoc, Sep 29 2016, 17:17:28.