LiveLoad.Scenario.Throttle.Rate (LiveLoad v0.0.1-rc.58)

Copy Markdown View Source

LiveLoad.Scenario.Throttle.Rate provides a basic rate limiter which limits to a specific number of events per interval configured.

This is the most commonly used throttle type. It works cluster wide across the entire distributed load test and ensures that the concurrent executions do not pass the configured rate limit. This rate limiting is smoothed and ensures that no bursts occur at the beginning of an interval.

Examples

# 100 per minute (the default interval)
LiveLoad.Scenario.Throttle.Rate.new(:my_throttle, 100)

# 10 per second
LiveLoad.Scenario.Throttle.Rate.new(:my_throttle, 10)
|> LiveLoad.Scenario.Throttle.Rate.interval(to_timeout(second: 1))

# 500 per 30 seconds
LiveLoad.Scenario.Throttle.Rate.new(:my_throttle, 500)
|> LiveLoad.Scenario.Throttle.Rate.interval(to_timeout(second: 30))

# Start at 10 per minute and ramp up to 100 per minute over the next 5 minutes
LiveLoad.Scenario.Throttle.Rate.new(:my_throttle, 10)
|> LiveLoad.Scenario.Throttle.Rate.ramp(100, duration: to_timeout(minute: 5))

Summary

Types

The rate to which to throttle events.

t()

Functions

Sets the rate interval in milliseconds.

Creates a new LiveLoad.Scenario.Throttle.Rate with the given name and rate.

Attaches a gradually ramping rate change to the throttle.

Types

rate()

@type rate() :: pos_integer()

The rate to which to throttle events.

t()

@opaque t()

Functions

interval(rate, interval)

@spec interval(rate :: t(), interval :: non_neg_integer()) :: t()

Sets the rate interval in milliseconds.

Must be a positive integer. The default is one minute.

new(name, rate)

@spec new(name :: atom(), rate :: rate()) :: t()

Creates a new LiveLoad.Scenario.Throttle.Rate with the given name and rate.

By default, the rate will be calculated over a one minute interval. To set it to different a different interval, use interval/2 to set a new one.

ramp(rate, target, opts)

@spec ramp(
  rate :: t(),
  target :: LiveLoad.Scenario.Throttle.Ramp.target(),
  ramp_opts :: [LiveLoad.Scenario.Throttle.Ramp.option()]
) :: t()

Attaches a gradually ramping rate change to the throttle.

Options

  • :duration: The duration of the gradual ramp up in milliseconds
  • :steps: The number of steps to take while ramping up. Requires an :interval value.
  • :interval: The interval at which to take each step. Requires a :step value.