Module: RateThrottleClient
- Defined in:
- lib/rate_throttle_client/demo.rb,
lib/rate_throttle_client.rb,
lib/rate_throttle_client/info.rb,
lib/rate_throttle_client/chart.rb,
lib/rate_throttle_client/version.rb,
lib/rate_throttle_client/clients/base.rb,
lib/rate_throttle_client/clients/null.rb,
lib/rate_throttle_client/clients/exponential_backoff.rb,
lib/rate_throttle_client/servers/gcra/gcra_fake_server.rb,
lib/rate_throttle_client/clients/exponential_increase_gradual_decrease.rb,
lib/rate_throttle_client/clients/exponential_increase_proportional_decrease.rb,
lib/rate_throttle_client/clients/exponential_increase_proportional_remaining_decrease.rb
Overview
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.
Defined Under Namespace
Modules: UniquePort Classes: Base, Chart, Demo, Error, ExponentialBackoff, ExponentialIncreaseGradualDecrease, ExponentialIncreaseProportionalDecrease, ExponentialIncreaseProportionalRemainingDecrease, GcraFakeServer, Info, Null
Constant Summary collapse
- VERSION =
"0.1.2"
Class Attribute Summary collapse
-
.log_block ⇒ Object
Returns the value of attribute log_block.
-
.max_limit ⇒ Object
Returns the value of attribute max_limit.
-
.min_sleep ⇒ Object
Returns the value of attribute min_sleep.
-
.multiplier ⇒ Object
Returns the value of attribute multiplier.
Class Method Summary collapse
Class Attribute Details
.log_block ⇒ Object
Returns the value of attribute log_block.
9 10 11 |
# File 'lib/rate_throttle_client.rb', line 9 def log_block @log_block end |
.max_limit ⇒ Object
Returns the value of attribute max_limit.
9 10 11 |
# File 'lib/rate_throttle_client.rb', line 9 def max_limit @max_limit end |
.min_sleep ⇒ Object
Returns the value of attribute min_sleep.
9 10 11 |
# File 'lib/rate_throttle_client.rb', line 9 def min_sleep @min_sleep end |
.multiplier ⇒ Object
Returns the value of attribute multiplier.
9 10 11 |
# File 'lib/rate_throttle_client.rb', line 9 def multiplier @multiplier end |
Class Method Details
.config {|_self| ... } ⇒ Object
16 17 18 |
# File 'lib/rate_throttle_client.rb', line 16 def self.config yield self end |