by Samy (Kondasamy Jayaraman)

Module 54 · Rate limits

Beginner

Why a busy API says slow down

An API can answer only so many requests a second. Here you stand a rain barrel of tokens at Larkspur’s stock API, flood it yourself, read the 429 it sends back, and set the limits for sale day.

Read as

The whole idea in one example

Oakmoor’s orders, on sale day

No limit

lost

12 of 40

A partner’s runaway script knocks the server over, and Oakmoor’s requests fail with it.

A barrel per key

served

40 of 40

The runaway script empties only its own barrel. Oakmoor never notices.

Counts come from a simulated stock API over hand-made traffic traces, with a hand-set server limit.

How it works

Four ideas carry the module

  1. 1 Too many at once

    Past its capacity, the server fails everyone

    Google’s Site Reliability Engineering book (Mike Ulrich, 2016) says overload is the most common cause of failures that spread: in its example, servers handling 1,000 requests a second that get 1,200 start crashing, and answer well below 1,000.

    Source, checked 30 October 2026

  2. 2 A barrel of tokens

    Size sets the burst; the drip sets the pace

    Amazon API Gateway’s guide says it limits requests with the token bucket method, a token per request: the rate is how fast tokens are added and the burst is the bucket’s size; past both, clients get 429 Too Many Requests.

    Source, checked 30 October 2026

  3. 3 Wait, then retry

    429 says no; Retry-After says when; jitter spreads the crowd

    RFC 6585 (April 2012) says status 429 Too Many Requests means the user has sent too many requests in a given amount of time, and the reply may include a Retry-After header saying how long to wait.

    Source, checked 30 October 2026

  4. 4 One barrel per key

    A runaway partner spends only its own tokens

    GitHub’s REST API docs, checked 30 October 2026, give each signed-in user their own limit of 5,000 requests an hour, and 60 an hour per address for requests without a sign-in.

    Source, checked 30 October 2026

The story

Larkspur’s stock API on sale day

On sale day a partner’s runaway script floods Larkspur Supply Co.’s stock API; the team puts a rain barrel of tokens at the door, and learns to say 429 and when to come back. You run the API’s front door.

5
callers in Larkspur’s hand-made sale-day traces
50
requests a second the simulated stock API answers before it falls over
680
requests in chapter 6’s twenty seconds
3
settings meet chapter 7’s rule

Your path

The chapters

  1. Chapter 1

    Too many at once

    What happens to everyone when one partner floods the API?

  2. Chapter 2

    Count per minute

    Can a per-minute count still let a burst through?

  3. Chapter 3

    The token bucket

    What do the barrel’s size and its drip each control?

  4. Chapter 4

    The 429 reply

    What does a 429 reply say, and what should a client do with it?

  5. Chapter 5

    Back off with jitter

    How should many refused clients come back without crashing in together?

  6. Chapter 6

    Who gets turned away

    How can a limit stop one partner without punishing the rest?

  7. Chapter 7

    Set the limits

    Which limits keep the API up and every quiet partner whole?

Who it’s for

  • Engineers
  • Product managers
  • Analysts
  • No code needed

Anyone whose product calls an API or offers one, and who has met a 429 or wondered why a partner’s script can slow everyone down. Read Web requests first if a request and its reply are new to you.