module RateThrottleClient
A class for simulating or “demoing” a rate throttle client
Example:
duration = 3600 # seconds in one hour client = ExponentialIncreaseSleepAndRemainingDecrease.new demo = RateThrottleDemo.new(client: client, stream_requests: true, duration: duration) demo.call demo.print_results # => max_sleep_val: [59.05, 80.58, 80.58, 80.58, 56.18, 56.18, 56.18, 59.05, 70.05, 70.05, 70.05, 59.15, 59.15, 59.15, 59.15, 70.05, 70.05, 59.15, 56.18, 80.58, 80.58, 59.05, 59.05, 59.05, 56.18] # => retry_ratio: [0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.02, 0.01, 0.01, 0.01, 0.00, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01] # => request_count: [3321.00, 1551.00, 2167.00, 2197.00, 1628.00, 1709.00, 1484.00, 3512.00, 1722.00, 2816.00, 3182.00, 2137.00, 4398.00, 2154.00, 2418.00, 2868.00, 2492.00, 2982.00, 1731.00, 2278.00, 1988.00, 4221.00, 3160.00, 2927.00, 2635.00]
Arguments:
Thread count can be controlled via the `thread_count` arguement, or the THREAD_COUNT env var (default is below). Process count can be controlled via the `process_count` arguement, or the PROCESS_COUNT env var (default is below). total number of clients is thread_count * process_count.
Time scale can be controlled via the `time_scale` arguement, or the TIME_SCALE env var (default is below). The time scale value will speed up the simulation, for example `TIME_SCALE=10` means a 60 second simulation will complete in 6 minutes.
The simulation will stop after `duration:` seconds. Outputting request logs to stdout can be enabled/disabled by setting `stream_requests`. The other way to stop a simulation is to specify `remaining_stop_under` when this value is set, the simulation will stop when the “remaining” limit count from the server is under this value.
The starting “remaining” limit count in the server can be set via passing in the `starting_limit`, default is 0 requests.
Outputs:
-
Writes log outputs to stdout if `stream_requests` is true
-
Writes aggregate metrics of each client to an intermediate json file every @json_duration seconds. This is then later used to produce the data for `print_results`
-
Writes the last value the client slept for to a newline separated file every 1 (real time, not simulated) second. This is used to generate the charts using the `chart.rb` script.
Constants
- VERSION
Attributes
Public Class Methods
# File lib/rate_throttle_client.rb, line 16 def self.config yield self end