Knowledge Guide
HomeSystem DesignCapacity Estimation

hard Drill: memory for a rate limiter

Drill

A rate limiter tracks a sliding-window counter for 50M active users, ~50 bytes per user entry (key + counter + timestamp). Can it live in memory on one node? What if you add per-API-key limits (10 keys/user)?

✅ Worked solution & bounds check

Worked solution

  • Per-user: 50M × 50 B = ~2.5 GB ⇒ easily one Redis node.
  • Per-API-key (×10): 500M × 50 B = ~25 GB ⇒ still one large node, but now plan to shard.

Gate: rate-limit state is small and hot ⇒ in-memory (Redis) with TTL eviction. The real design questions are algorithm (token vs leaky bucket) and atomicity (Lua/INCR), not capacity. Memory only forces sharding past ~hundreds of GB.

🤖 Don't fully get this? Learn it with Claude

Stuck on Drill: memory for a rate limiter? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🪜 Hint ladder (no spoilers)

Progressively stronger hints — you still solve it.

I'm working on the problem **Drill: memory for a rate limiter** (System Design). Give me a HINT LADDER: start with the tiniest nudge, then wait. Only reveal the next, stronger hint when I ask. Do NOT show the full solution unless I type 'show solution'. Keep me doing the thinking. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🎨 Explain the approach visually

See the technique, not just code.

Explain the optimal approach to **Drill: memory for a rate limiter** with a VISUAL walkthrough: trace it on a small concrete example using ASCII art / a step-by-step diagram, narrate what changes each step, then give time & space complexity with a one-line derivation. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🔍 Review my solution

Catch bugs, edge cases, sub-optimality.

I'll paste my solution to **Drill: memory for a rate limiter**. Review it for correctness, missed edge cases, and time/space complexity, then coach me toward the optimal — don't just rewrite it. Ask me to paste my code now. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🔁 Drill the pattern

Lock in recognition with look-alikes.

Give me 2 problems that use the SAME underlying pattern as **Drill: memory for a rate limiter**. For each, let me attempt first, then review my answer and name the trigger signal that reveals the pattern. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes