# System Design Interview: Design a Rate Limiter

Aced (formerly Exponent) publishes a public search API over its indexed pages; the guide is at https://www.aced.io/agents/agent-access.

Source: https://www.aced.io/blog/rate-limiter-system-design
Source observed: 2026-11-04T22:02:47.766Z
Last checked: 2026-11-04T22:02:47.766+00:00
Indexed: 2026-11-05T01:42:42.725+00:00

---

# System Design Interview: Design a Rate Limiter

We use this system design mock interview to walk through designing a rate limiter. Hozefa, an engineering manager at Meta, answers the mock interview. The article also points to our [Strategies for Improving Availability](https://www.aced.io/courses/system-design-interviews/availability-strategies?ref=exponent-blog.ghost.io) lesson.

## Course preview

Learn system design fundamentals and video examples in our [System Design Interview Course](https://www.aced.io/courses/system-design-interviews?src=blog-top-callout&ref=exponent-blog.ghost.io).

Three common system design questions highlighted in the preview:

- Design Instagram — [watch an answer](https://www.aced.io/courses/system-design-interviews/mock-interview-design-instagram?src=blog&ref=exponent-blog.ghost.io)
- Build TinyURL — [watch an answer](https://www.aced.io/courses/system-design-interviews/url-shortener?src=blog&ref=exponent-blog.ghost.io)
- Design YouTube — [watch a sample answer](https://www.aced.io/courses/system-design-interviews/design-youtube?src=blog&ref=exponent-blog.ghost.io)

## What is a rate limiter?

A rate limiter blocks a user request and allows only a specified number of requests through during a specified period. We use rate limiters to reduce DDoS and malicious-user traffic, prevent overload, reduce the number of servers needed to handle excessive traffic, and manage computing power.

![Rate limiter diagram](https://storage.ghost.io/c/a5/f5/a5f5c2f0-4c62-43c7-891b-662a0b6d68b3/content/images/2022/11/rate-limiter-general-1-1.png)

*The diagram shows a rate limiter allowing some application requests through to processes while rejecting later requests to protect the system.*

## Prerequisites: identifying users to limit

We can segment traffic using a unique identifier such as `userID` or IP address. The example uses IP address because it narrows traffic to a set of addresses, while user IDs or internal identifiers are easier to spoof or recreate. After blocking a user, the system should notify them.

![Blocking and notification illustration](https://storage.ghost.io/c/a5/f5/a5f5c2f0-4c62-43c7-891b-662a0b6d68b3/content/images/2022/11/rl-section-2.png)

*The illustration shows potentially hazardous traffic being identified, blocked, and returned with an error code.*

We return **HTTP 429, “Too Many Requests,”** when a user sends too many requests in a given period. We also consider server-side logging so we can analyze traffic patterns later.

## How to rate limit

The appropriate algorithm depends on what we want to optimize.

### Token bucket

Each request costs one token. The bucket refills at a constant rate of tokens per second. When no tokens remain, requests stop and the system returns HTTP 429 instead of forwarding them.

![Token bucket API rate limiter](https://storage.ghost.io/c/a5/f5/a5f5c2f0-4c62-43c7-891b-662a0b6d68b3/content/images/2022/11/rl-section-4-1-1.png)

A real-world policy might allow **1,000 requests from the Western US every hour**. Token buckets are simple, but traffic spikes can cause many users to miss the response they want, requiring repeated bucket-size tuning; the article describes this approach as not very popular.

### Fixed window

A fixed-window system limits responses within a fixed time window. For example, if we allow **1 request per minute** and a user visits at 0:34, the next visitor waits **0:26** before the clock resets.

![Fixed-window counter API rate limiter](https://storage.ghost.io/c/a5/f5/a5f5c2f0-4c62-43c7-891b-662a0b6d68b3/content/images/2022/11/rl-section-4-3.png)

Fixed windows can create a burst near the end of one window followed by a large gap before requests are processed again.

### Sliding window

Sliding windows adjust the processing timeframe dynamically instead of using a fixed clock. Traffic-based systems require ongoing adjustment of window and limit sizes as request patterns fluctuate. For a Twitter-style design, the article favors a sliding window so requests move with time and the system can accommodate traffic spikes and dips.

## Components and server-side placement

A sliding window can be configured using values such as:

- How many counters each window needs
- The sliding scale

The rate limiter should run on the server. Client-side enforcement is easier to forge or bypass; server-side enforcement gives more control over traffic flow.

![Client and server rate limiter](https://storage.ghost.io/c/a5/f5/a5f5c2f0-4c62-43c7-891b-662a0b6d68b3/content/images/2022/11/rl-section-3-1.png)

*The diagram places clients on one side and API servers with a rate limiter on the server side.*

The design includes:

- Client(s)
- API and rate-limiting middleware
- A rules engine defining the algorithm and whether traffic is identified by IP address, geography, or user ID
- A high-throughput cache that records request counts and supports blocking decisions
- A parallel logging service for future analysis

![Rate limiter middleware architecture](https://storage.ghost.io/c/a5/f5/a5f5c2f0-4c62-43c7-891b-662a0b6d68b3/content/images/2022/11/rl-section-3-2-2.png)

The middleware returns a successful request to the API service when allowed and returns HTTP 429 when blocked. Logging can place data in long-term storage so it can be analyzed without adding strain to the live system.

![Rate limiter with Redis logging](https://storage.ghost.io/c/a5/f5/a5f5c2f0-4c62-43c7-891b-662a0b6d68b3/content/images/2022/11/rl-section-3-3.png)

To speed rule access, we can add a cache between the rules engine and rate limiter so the limiter reads cached rules instead of querying the rules engine on every request.

### Core requirements

- Run server side.
- Block based on IP or `userID`.
- Send HTTP 429 when a user is blocked.
- Include a logging mechanism for future use.

## Distributed environment

In a single data center, requests pass through one rate limiter and the same web-server set. In a distributed environment, use a load balancer to spread requests across servers and data centers, with a rate-limiter implementation in each data center.

The cache must scale horizontally and be shared across the distributed network. Separate caches would limit traffic per data center rather than globally. Options include a read cache and write cache with synchronization, or one common read/write cache shared across all data centers.

Rules can have multiple cache instances because they generally persist and do not change frequently. They do not need the same distribution pattern as request counters.

The article does not favor different geographic rate-limit rules. Users could mimic request locations or use a VPN to bypass geography-specific logic, so a consistent worldwide rule set is easier to manage and throttle.

## Notes from the interviewer

Rate-limiter system design is open-ended and has several valid solutions. Google, Amazon, and Stripe have different implementations:

- [Google](https://www.aced.io/companies/google?ref=exponent-blog.ghost.io)
- [Amazon](https://www.aced.io/companies/amazon?ref=exponent-blog.ghost.io)
- [Stripe](https://www.aced.io/companies/stripe?ref=exponent-blog.ghost.io)

In a system design interview, focus on requirements and constraints, then address likely pain points and objections. A perfect production-scale solution is not expected in a 30-minute interview.

- [Create your free account](https://www.aced.io/signup?src=blog)

## Related blog posts

- [The 10 Best System Design Books to Sharpen Your Skills](https://www.aced.io/blog/best-system-design-books) — a month ago · 9 min read
- [How to Whiteboard for System Design Interviews](https://www.aced.io/blog/how-to-whiteboard-for-system-design-interviews) — a month ago · 8 min read
- [The Top 30 Engineering Manager Interview Questions of 2022](https://www.aced.io/blog/top-30-engineering-manager-interview-questions) — a month ago · 8 min read
- [Stripe System Design Interview (2026 Guide)](https://www.aced.io/blog/stripe-system-design-interview) — a month ago · 8 min read

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fblog%2Frate-limiter-system-design&trace=t_679ff9ab98f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Aced (formerly Exponent)’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://www.aced.io/agents/agent/faq?q={question}&trace=t_679ff9ab98f3`

[Tool guide and examples](https://www.aced.io/agents/agent-access) · [OpenAPI](https://www.aced.io/agents/api/public/v1/openapi.json) · [Page TLDR form](https://www.aced.io/agents/agent-tools/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fblog%2Frate-limiter-system-design). Opening a form does not execute a tool.