OpenBook
  • Problems
  • Tracks
  • How it works
  • Pricing
Start practicingSign In
Problems/Systems & Infra

3. Rate Limiter Middleware

Medium

Per-API-key sliding window limiter with correct headers and a shared store interface.

40 minute budget46.9% acceptancemiddleware · sliding window

Requirements

  1. 01Identify callers by the x-api-key header and allow each key a fixed number of requests per rolling window, shared across GET /ping and POST /echo.
  2. 02Return 429 with a retry-after header (whole seconds until the next request would be accepted) when a key is over its budget.
  3. 03Put x-ratelimit-limit, x-ratelimit-remaining and x-ratelimit-reset headers on every /ping and /echo response, accepted or not.
  4. 04Expose GET /limits/:key reporting { key, limit, used, remaining, reset }; it is never limited and does not count.
  5. 05The limiter must reach its state only through the Store interface in the starter, so the in-memory store can be swapped for Redis.

What the hidden tests check

  • Everything the interviewer tells you is checked, including exact header values on a 429.
  • The window slides rather than resets, budgets are per key, and the inspection route never changes the count.

4 more details are held back. In a mock interview they come out only when you ask the interviewer the right question; in practice they are listed in the workspace.

Sign in to start

Attempts, files and transcripts are saved to your account so the grader can review how you worked.

Sign inCreate an account
OpenBook

Practice for interviews where you build a feature with an AI assistant.

Early preview. Problems, grading and the interviewer are still changing.

Practice

  • Problems
  • Tracks
  • How it works
  • Pricing

Legal

  • Terms
  • Privacy
© 2026 OpenBook.