CSE Roadmap

Core tier · about 4 hours · 8 parts

Part 7 of 8 · 2 min read

Say it out loud

A short script for the interview.

What to say out loud and one follow-up

A strong answer follows the four steps of Level 0, page 6.

  1. Understand. Ask where it runs, what the key is, the scale, and whether it is a service or code. Write the requirements.
  2. High-level design. A middleware at the gateway, a rules cache, a shared in-memory counter store, a 429 reply.
  3. Deep dive. The race and the atomic store step, the shared store and sharding, the choice of method, headers, failing open.
  4. Wrap up. Hard against soft limits, limits at other layers such as IP level, regions with eventual consistency, monitoring, and advice for clients (use a cache, respect the limit, back off on retry).

Interview angle

Answer in your head first, then open it.

Where do you put the limiter?

At the gateway or a middleware on the server side. Clients cannot be trusted.

Which algorithm?

Token bucket by default for bursts. Sliding window when the limit must hold in any window. State the memory and accuracy cost.

How do many servers share counts?

A central in-memory store, sharded by client key, with atomic check-and-update.

What if the store fails?

Fail open for most rules, with an alert, and fail closed only where abuse is dangerous.

How do you know it works?

Refusal counts per rule, added latency, and complaints from valid users.

One follow-up to try. "Now the limit must hold across three regions, within 5 per cent." A good reply: each region keeps a local counter with a share of the global limit, shares usage every few hundred milliseconds, and rebalances shares to busy regions. Say that exactness costs latency, so 5 per cent is bought with background sync and not with a cross-region call per request.

Check yourself: 1. Which step of the framework covers the race condition? 2. What would you say about clients that want to avoid being limited? 3. In the three-region follow-up, why not call across regions for each request?

Words you will meet

Word Meaning
Middleware Code that handles each request before the real service
API gateway A front door that does limiting, login and routing
429 The status code "too many requests"
Atomic Done as one step that nothing can interrupt
Fail open Let requests through when the checker is broken
Eventual consistency Copies agree after a short delay
Hard and soft limit Never exceeded, or exceeded briefly