14 / 16
System Design Classics
The classic Staff interview designs: feeds, chat, payments, storage, real time.
Give each long URL a short base62 key from a collision-free ID source, store key → URL in a sharded key-value store, serve redirects from cache, and log clicks asynchronously, off the redirect path.
Enforce limits at the gateway with rules cached in memory and counters in a regional Redis updated by one atomic script; answer excess with 429 and Retry-After, and fail open if the limiter breaks.
Precompute each user's feed by pushing new post IDs into followers' cached lists, but pull posts from high-follower accounts at read time and merge; hydrate, rank, and page with cursors.
Clients keep a WebSocket to a gateway; the chat service gives each message a per-conversation sequence, stores it, then delivers to online recipients or via push; clients dedup and resync from their last-seen sequence.
Services emit events; the notification service dedups, checks preferences and caps, renders per channel, and queues sends by priority to channel workers that call APNs, FCM, email and SMS providers with retries.
Precompute the top-K completions per prefix offline from query logs, serve them from an in-memory index behind browser and CDN caches, and answer each keystroke well under 100 ms; merge a trending layer for freshness.
A URL frontier with one queue per host feeds fetch workers that obey robots.txt; new links pass a Bloom-filter seen-check, pages pass content dedup, and each host gets one request at a time.
Place keys on a consistent-hash ring, replicate each to N nodes, and wait for W write and R read acks; versions resolve conflicts, while gossip, hinted handoff and Merkle-tree repair ride out failures.
Partition keys across memory-only nodes by hash slot or consistent hashing, evict by LRU or LFU at a memory limit, replicate asynchronously for failover, and protect the database from hot keys and cold nodes.
Upload the original once in resumable parts, transcode it in parallel chunks into a bitrate ladder of short segments, and serve them from a CDN; the player picks a quality per segment.
Drivers stream GPS every few seconds into an in-memory index of H3 cells; a request searches nearby cells, ranks drivers by road ETA, claims one atomically, and a trip state machine runs to payment.
Index mostly static businesses by geohash cell; a search reads the user's cell plus its 8 neighbors from cache or read replicas, filters by exact distance, and widens the cell when results are few.
Record the payment intent, call the PSP with an idempotency key, and post the outcome as balanced double-entry ledger entries; webhooks and daily reconciliation against PSP reports catch whatever the synchronous path missed.
Move money between accounts on different shards as an idempotent debit-then-credit saga recorded in a double-entry ledger; the append-only log makes every balance reproducible, and reconciliation proves no money was created or lost.
Hold seats with one atomic conditional write that expires after ~10 minutes, charge with an idempotency key, then confirm only if the hold is still yours; a virtual waiting room meters the spike.
One session server per document orders every edit, transforms or merges concurrent edits (OT or CRDT), appends them to an operation log and broadcasts them; cursors travel on a separate, ephemeral presence channel.
Store each job's next run time; sharded schedulers claim due jobs and enqueue a run with a deterministic id; workers execute under heartbeated leases; delivery is at-least-once, so every job must be idempotent.
Split files into hashed blocks, upload only blocks the server lacks, commit the file as a hash list with a version check, and tell other devices to pull changes since their cursor.
Buffer samples through an ingest pipeline into a compressed time-series store sharded by series, downsample old data for long ranges, cap label cardinality, and evaluate alert rules on recent data, independently of what they watch.
Store each topic as partitioned append-only logs, replicate every partition from a leader to in-sync followers, acknowledge once they have the write, and let consumer groups pull by offset and commit their own position.
Log clicks to Kafka, drop duplicates by click id, count per ad per minute by event time with exactly-once output into an OLAP store, and reconcile against a batch recount of the raw log.
Count events per item in time buckets, keep a size-K heap over the counts, and sum buckets for sliding windows; switch to a count-min sketch when exact per-item counters stop fitting in memory.
Keep scores in a Redis sorted set: score updates and rank lookups are O(log N), the top 10 is one range read, and the set is a view rebuilt from the durable score store.