How it works
Start with the reason for throttling, which means refusing or delaying requests beyond an agreed allowance: protect an expensive endpoint, contain abuse, or allocate a fair share of capacity. Specify the key (authenticated user, API key, IP address, or a combination), the operation, the allowed amount, and the time period. A per-IP login limit can punish people behind a shared network; a per-user limit does not help before sign-in. The correct identity depends on the threat and product contract.
As an example, a login endpoint might use two rules: 5 failed attempts per account in 15 minutes to stop password guessing, and 300 attempts per IP address per minute to stop one machine trying many accounts. An office of 2,000 people behind one address stays under the second rule unless more than 300 sign in within a minute, and one person’s typos lock only their own account. GitHub’s REST API splits identity in a similar way: 60 requests per hour by IP address for unauthenticated callers, and 5,000 per hour by account for ordinary signed-in users.
State whether the quota must be strict, whether brief bursts are useful, and what happens when the store is unavailable. Decide if excess requests are rejected, delayed, or queued; a synchronous API commonly returns HTTP 429 with a useful retry signal. Set latency and accuracy targets before selecting an algorithm. Limits also cost a lookup per request and block some real users. For internal batch work you control, a queue with a fixed worker count is often simpler.
A university shares one public IP, and students report being blocked from signing in. What would you revisit?
A single IP quota is treating many legitimate users as one client. Use a policy that considers account or device identity where trustworthy, and retain a separate IP-level abuse guard with a suitable threshold.
Use this as a guide for self review; written answers are not graded.Keep in mind
- A rate limit is a policy scoped to an identity and operation.
- Define burst, failure, and client response behavior before implementation.