Medium
Atlassian

Implement an In-Memory Rate Limiter Object-Oriented Design Interview

Design and implement an in-memory rate limiter as an object-oriented TypeScript module, with handwritten tests and discussion of concurrency considerations.

1. Problem Statement

Implement a rate limiter. Start by asking any clarifying questions, then design and code an in-memory solution.

2. Live Coding Format

Work in the provided coding workspace while explaining your decisions to the live interviewer. Validation may use inline tests, examples, comments, or a verbal walkthrough.

3. Key Focus Areas

  • 1
    Algorithm choice and justification (fixed window vs sliding log vs token bucket)
  • 2
    Correct window-boundary enforcement
  • 3
    In-memory state management per key
  • 4
    Clock injection for testability
  • 5
    Concurrency: race condition identification and mitigation strategy
  • 6
    Handwritten tests: within-limit, at-limit, and over-limit cases

4. What Strong Candidates Should Demonstrate

  • Clarify the rate limiting contract: window type (fixed/sliding), granularity (per-user or global), and enforcement semantics (allow/deny vs consume/wait).
  • Choose and implement a correct in-memory algorithm — fixed window counter, sliding window log, or token bucket — and justify the tradeoff.
  • Discuss concurrency hazards (read-modify-write races) without needing to implement a full thread-safe solution in a 40-minute round.
  • Validate with handwritten test cases covering the window boundary and burst scenarios.

Want interactive feedback?

Practice this problem in the live coding workspace while the interviewer probes your clarification, implementation, trade-offs, and validation.

Start Interview

Core Concepts

Object-Oriented DesignAlgorithm DesignConcurrency AwarenessTesting