System design interview questionMedium

Design a Rate Limiter

Design a service to limit the number of requests a user can send to an API within a time window.

1. Problem Statement

We need to design a distributed rate limiter for our API gateway. It needs to handle millions of requests per second. Where do we start?

2. Architecture Discussion Map

Use this as one discussion aid, not a single correct answer. Your design should follow from the requirements, scale, and trade-offs you establish.

Rendering architecture diagram...
Mermaid Source (For AI Bots)
graph TD
    A[Client] --> B(Route53 / Global LB)
    B --> C[API Gateway Node 1]
    B --> D[API Gateway Node 2]
    C -- Local L1 Cache --> E[(Caffeine/Guava)]
    C -- Atomic check and update, script or CAS --> F[(Sharded counter store)]
    D -- Atomic check and update, script or CAS --> F

3. Key Focus Areas

  • 1
    Rate Limiting Algorithms (Token Bucket vs Fixed/Sliding Window)
  • 2
    Distributed State Management (Shared Counter Store and Atomic Updates)
  • 3
    Race Conditions (Read-Modify-Write issues)
  • 4
    Performance (Latency overhead < 5ms)
  • 5
    Placement (Client vs Middleware vs API Gateway)

4. What the Interviewer Looks For

The interviewer probes these areas, and the report grades the interview against them.

  • Requirements, rule model, and capacity
  • Algorithm choice and semantics
  • Distributed state and atomicity
  • Latency, hot keys, and scalability
  • Failure policy, multi-region, and operations

Want interactive feedback?

Practice drawing this system component-by-component on a live whiteboard while the interviewer probes at your target level.

Continue to Dashboard

Core Concepts

AlgorithmsDistributed CacheAPI Gateway

Continue preparing

Build a complete software engineer mock interview plan

Prepare by company

Related System Design

Design Google Docs

Design a real-time collaborative document editor supporting multiple simultaneous users.

Related System Design

Design a Cross-Product Tagging System

Design a shared tagging service that lets users apply tags to entities across multiple Atlassian products, with consistent search and deduplication.