Reading preferences
Concept

Rate Limiting

Bound request rates using explicit identities, windows, and policies.

system design, rate limiting, capacity

Decide how much is allowed

A rate limiter enforces a policy such as three requests per minute per API key. It can protect shared capacity and reduce abuse, but it does not replace authentication, authorization, or capacity planning. A rejection can return HTTP 429 and, where appropriate, guidance on when to retry.

Public search API

For illustration, use a fixed one-minute window and allow three requests per key. The first three requests are accepted; a fourth in the same window is rejected. At the next window the count resets. This simple policy permits a burst on either side of a boundary; a token bucket is one alternative.

See the reasoning

Follow the example one step at a time

Count requests in a fixed window with a limit of three per key. This is a prepared teaching demonstration, not live code execution.

First two

window 12:00–12:01
accepted: 2 of 3

Two requests have used two slots.

Login attempts

An app can limit attempts using multiple signals, such as account and network, while avoiding permanent lockouts that an attacker could trigger against a victim. A shared IP can represent many people. Offer safe recovery and monitor false positives; never reveal sensitive account existence through responses.

Trade-offs and failure

Specify the key, time window, limit, response, and behavior when the limiter is unavailable. Multiple gateway instances require coordinated counters for a truly shared limit; local counters may allow more traffic than intended. Atomic updates, clock assumptions, fairness, and whether to fail open or closed depend on the risk and availability requirement.

Reflect on the concept

Four fixed questions to reinforce the reasoning. Answers are not saved or scored.

1. What is a rate limit?
2. What can happen at a fixed-window boundary?
3. Why choose the identity carefully?
4. What can an overly strict login limit cause?

References and further reading