- Designing a Chat System
Real-time messaging end to end. Polling, long polling, server-sent events and WebSockets — what each costs and when each is right; the connection registry that lets one server find a user connected to another; message ordering when clocks disagree; storage that supports "load older messages" cheaply; group chat fan-out and the point at which it stops working; presence, delivery receipts and offline delivery.
- Designing a URL Shortener
The classic warm-up question, worked properly. Requirements and estimates, base62 encoding against hash-and-truncate, how to handle collisions without a retry loop that never terminates, the 301-versus-302 decision that also decides whether you get analytics, the read path and its cache, custom aliases, and expiry that does not require scanning the table.
- Designing a Unique ID Generator
Four ways to mint an id at scale and the single tradeoff that decides between them: sortability against coordination. Database auto-increment, UUIDv4 and v7, a ticket server, and Snowflake — with the bit layout worked through, the clock-skew failure everyone forgets, and why a system can want two ids for the same row rather than one.
- Rate Limiting
Four algorithms and what each one does at the boundary: fixed window and its doubling bug, sliding log, sliding window counter, and the token bucket that wins most of the time. Where the limiter belongs, how to identify a caller without handing them a way to reset their own quota, why the counter must be atomic, and the 429 contract a client can actually back off against.
- Concurrency – Double Booking and Distributed Locks
Two guests, one room, the same millisecond. Why the check-then-write everyone writes first is always wrong, optimistic against pessimistic locking, the database constraints that make a race impossible rather than unlikely, idempotency keys for requests that must not run twice, and distributed locks — what they cost, how they fail, and why they belong last on the list rather than first.