Object-oriented design interview questionMedium
Atlassian

Implement an In-Memory Rate Limiter

Design and implement an in-memory rate limiter as an object-oriented module, validate it with concrete test cases, and discuss 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
    Concurrency: race condition identification and mitigation strategy
  • 5
    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 this round.
  • Validate with 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.

Continue to Dashboard

Core Concepts

Hidden because they name the technique, which a real interviewer would not tell you.

Show core concepts
Object-Oriented DesignAlgorithm DesignConcurrency AwarenessTesting

Continue preparing

Build a complete software engineer mock interview plan

Related Object-Oriented Design

Design an ATM Transaction Engine

Design an ATM that authenticates a card and PIN, and supports balance inquiry, cash withdrawal with denomination dispensing, and deposits, including session/state handling and hardware abstractions.

Related Object-Oriented Design

Design Blackjack and a Deck of Cards

Design a reusable deck of cards and a single-round Blackjack game: cards, suits and ranks, deck shuffle/deal, hand scoring with flexible ace values, player and dealer turns, and terminal outcomes (blackjack, bust, win/lose/push).

Related Object-Oriented Design

Design a Power Plant Electricity Allocator

Design a class-level system modeling a power plant that distributes electricity to multiple neighbourhoods, each with a stated demand, subject to the plant's total capacity.

Related Object-Oriented Design

Design a Car Rental System

Design a car rental domain model covering vehicle categories and vehicles, branches, customers and drivers, a rental date range, rate-based quotes, category reservations, vehicle assignment at pickup, and return inspection with extra charges — without overbooking a category or renting one vehicle for overlapping periods.