Rate limiting basics
One client can make a thousand requests a second. Nothing in HTTP stops them, and your server will try to answer every one.
Rate limiting controls how much traffic a service accepts. It's the difference between an endpoint that survives a bad afternoon and one that falls over because a single script got enthusiastic.
Three problems it solves
Fair use. One client hogging resources means everyone else waits. A limit keeps a single caller from consuming what the whole user base needs, so legitimate traffic still gets served while somebody's runaway loop is being refused.
Security. A login endpoint with no limit is an invitation to guess passwords, thousands at a time. Limits make brute force slow enough to be useless, and they blunt the simpler denial of service attacks.
Resources. Overload makes a service slow before it makes it unavailable, and slow is where users leave. Capping throughput keeps response times predictable for everyone still inside the limit.
Limits are not a DDoS defence on their own
A distributed denial of service arrives from thousands of separate machines, each looking like an ordinary client. Per-address limits barely touch that.
Answering it takes something upstream: geographic filtering, behavioural analysis, or a provider sitting in front of you. Rate limiting is a layer, not the answer.
Capping how often anyone can ask is what makes an app hard to abuse and pleasant for everyone else at the same time.
Refusing versus slowing
Two related controls that get used interchangeably and behave differently.
| Rate limiting | Throttling | |
|---|---|---|
| What it does | Refuses requests past a ceiling | Slows requests down as the limit approaches |
| The client sees | An error, usually 429 Too Many Requests | A response, later than usual |
| Best for | Hard caps you want enforced | Smoothing bursts without breaking clients |
Rate limiting refuses past a ceiling. Throttling slows.
Both have their place, and they combine: slow things down as traffic climbs, refuse outright past a hard ceiling. Throttling covers the second half in detail.
One breaks the client's request. The other makes them wait. Which is kinder depends entirely on who is calling and why.
What a limit counts against
A limit needs something to count per. Four candidates, each with different tradeoffs:
- IP address. Available on every request including anonymous ones, and shared by everyone behind an office network or a mobile carrier.
- Authenticated user id. Precise and fair, and only exists after login.
- API key. Ideal for machine clients, since a key identifies a caller exactly.
- A claim inside a JWT. Useful when identity already travels in the token.
Identifying clients works through picking between them. The short version: anonymous traffic leaves you with the address, and everything else is better when it's available.
Limits also need a window. Per second, per minute, per hour, and the choice shapes the behaviour as much as the number does.
Every rate limit is those three decisions together, and changing any one of them changes what the limit actually does.
Try it
An API has one limit: 1,000 requests per hour per IP address. Work out what it fails to prevent.
- A user on a university network cannot use the app during term time. Why?
- An attacker wants 10,000 requests an hour. What does that cost them?
- A script sends all 1,000 requests in the first two seconds of every hour. Is that within the limit?
Compare your answers
1. The limit counts the wrong thing. Everyone on that network shares one outbound address, so thousands of people are sharing a budget of a thousand. The fix is counting per authenticated user where a user exists, and keeping the address limit only for anonymous traffic.
2. Ten addresses. Residential proxy pools sell those by the thousand for very little. Per-address limits make abuse cost something; they do not make it hard. This is the same reason per-IP limiting barely dents a distributed attack.
3. Entirely within the limit. Nothing says how the thousand requests may be spread, so all of them can arrive at once and the endpoint sees a burst it was never protected from. That's what window length controls, and picking one hour permits a spike a one-minute window would never allow.
Three questions, three different weaknesses, and only the third is about the algorithm. The first two are about what you count and how cheaply it can be replaced.
Where this goes next
A limit needs three decisions: how many, over what window, counted against whom. The algorithm is how you track them.
Fixed window counters is the simplest of those algorithms, and the burst it lets through is what every algorithm after it exists to fix.

