Simulator
The simulator runs a model of the limiter in your browser, against a model API with a hidden quota. First, the race shows how all modes do in one story. Then the live run shows one mode step by step, so you can see why.
The race
Section titled “The race”The race runs all four modes through the story on the same seed, so each mode sees the same requests at the same times. The bars show the units that the API accepted so far. More units is not the only goal: “No limiter” gets many units, but with tens of thousands of throttles. Press Run the race to replay it, or Show the result for the table. A change to the story, the instances, the quota or the demand runs the race again. The race uses the default limiter options.
The live run
Section titled “The live run”The race shows the result, but not the cause. The live run shows one mode at a time: the queues, the buckets, the quota and each rule that fires. Choose a story, a mode, the number of instances, the hidden quota and the demand. At the bottom, change the limiter options and export your settings.
- Units used, 60 s
- 0
- Sum of rates
- 0
- Throttled
- 0
- In queue
- 0
- p95 wait
- 0 s
- Rejected or gave up
- 0
Limiter options
A change starts a new run. Changed values are marked. The checks are the checks of the library.
Export the settings
Controls
Section titled “Controls”| Control | Effect |
|---|---|
| Pause, Play | Stops and starts the run. With reduced motion turned on in your system, the run starts paused. |
| Reset | Starts a new run with the current settings and seed. |
| Quota drop | Another client takes half of the quota for 60 seconds, now. |
| Story | A script of events: a noisy neighbor, a quota cut, a scale-out, a burst of demand or an outage. A change starts a new run. |
| Mode | No limiter, a fixed rate of 1,500 units per minute, AIMD or CUBIC. A change starts a new run. |
| Instances | 1 to 4 processes that share the quota. |
| Speed | Simulated seconds per real second. |
| Hidden quota | The units per minute that the model API allows. The limiters cannot see it. |
| Demand per instance | The units per minute that each instance wants to send. |
| Seed | Sets the request times and costs. The same seed and settings give the same run. |
| Copy link | Copies a link that keeps the settings, the seed and the options. |
Read the chart
Section titled “Read the chart”The marks on the live chart show the rules of the limiter. Point at a mark to read the rule that fired. On a touch screen, tap the mark. With a keyboard, focus the chart and press the arrow keys.
| Mark | Meaning |
|---|---|
| Down triangle | A cut. The tooltip shows the rule and the new rate, and how many more throttles did not cut again because of DecreaseCooldown. |
| Red bar at the top | A pause for the Retry-After, up to MaxPause. |
| Up triangle | The rate reached the MaxUnitsPerMinute share. |
| Circle at the top | A story event. |
Export the settings
Section titled “Export the settings”The export shows your settings as appsettings.json or as C# options code for a limiter named api. It always shows the three rates, and the other options that differ from the defaults. Change the rates to the units of your API before you use them.
The model
Section titled “The model”| Part | Model |
|---|---|
| API | A sliding window of 60 seconds. A request that would go over the quota gets 429 with a Retry-After of the seconds until there is room. A throttled request uses no quota. In an outage, each request gets 503 with a Retry-After to the end of the outage. |
| Requests | Each instance makes requests at random times, at the demand rate. A request costs 1, 2 or 5 units (6 of 10 cost 1, 3 cost 2, 1 costs 5). |
| Network | A fixed time of 0.2 seconds from send to response. |
| Retry | A retry handler outside the limiter sends a throttled request again after its Retry-After, up to 3 times. |
| Limiter | The rules of AdaptiveRateLimiter, AdaptiveTokenBucket, AimdController and CubicController. It starts with the default options and the SharePoint default rates (1,500, 200 and 5,625 units per minute), or with the options that you set. |
| Fixed rate | A token bucket at the initial rate share, without cuts and without the pause. |
To print the comparison for several scenarios without a browser, run npm run simulate in the docs folder.