Autocoder

System Design Interview Questions with Worked Designs

Last updated 2026-11-19

System design rounds reward structure and numbers, not memorised architectures. This page works through the questions that recur: a URL shortener with real capacity arithmetic, a rate limiter, a news feed, chat, unique ID generation and search autocomplete, with the trade-offs you should say aloud at each step.

If you are early in your preparation, read system design for freshers first. The building blocks have their own pages: caching, load balancing, message queues and distributed systems. The approach is in how to crack a system design interview.

FormatOpen-ended design, 35 to 60 minutes
Skills testedRequirements, estimation, components, trade-offs
LevelMedium to hard

A framework you can say out loud

Clarify functional requirements and scale, estimate load and storage, define the API and data model, sketch the high-level components, then go deep on one or two hard parts, such as the ID scheme or the feed fan-out. End with bottlenecks, failure handling and what you would monitor.

Do not jump to technology names. Say what each component must do, then pick a tool and state what you give up by choosing it.

Numbers worth memorising

System Design Interview Questions with Worked Designs: questions with worked answers

  1. 1

    What steps do you follow in a system design interview?

    easy

    First clarify requirements: features in scope, users, read-to-write ratio, latency and consistency needs. Then estimate traffic and storage. Define the API and the main entities. Draw a high-level diagram with clients, load balancer, services, cache, database and queues. Deep-dive on the component that carries the most risk. Finish by discussing bottlenecks, replication, failure modes, monitoring and what you would improve with more time. Time-box each step so you reach the end.

  2. 2

    Do the capacity estimate for a URL shortener with 100 million new URLs per month and a 100:1 read-to-write ratio.

    medium

    Writes: 100 million per month over about 2.6 million seconds is roughly 40 writes per second. Reads at 100:1 are about 4,000 per second, with peaks perhaps two to three times that. Storage: keep records for five years, 100 million times 60 months is 6 billion records; at about 500 bytes each (long URL, short code, timestamps, owner) that is about 3 TB, which fits a sharded or single large database. Short code length: base62 with 7 characters gives 62 to the power 7, about 3.5 trillion, comfortably above 6 billion. Reads dominate, so a cache holding the hottest 20 percent of codes removes most database load.

  3. 3

    Design a URL shortener: components, ID generation and trade-offs.

    hard

    API: POST /urls with the long URL returns a short code; GET /{code} returns a 301 or 302 redirect. Use 302 if you need analytics on every click, since 301 is cached by browsers. Components: load balancer, stateless app servers, cache (code to URL), database keyed by code, and an analytics queue. ID generation options: hash the URL and take 7 characters, which needs collision handling and gives the same code for the same URL; or use a counter encoded in base62, which is collision-free but predictable and needs a coordinator, often fixed by giving each app server a pre-allocated range of the counter; or generate random codes and rely on a unique constraint with retry. The database is key-value shaped, so a sharded key-value store or a relational table sharded by code works. Expiry, abuse checks and custom aliases are extensions.

  4. 4

    Design a distributed rate limiter.

    hard

    Pick an algorithm: token bucket (allows bursts up to bucket size, refills at a steady rate), leaky bucket (smooth output), fixed window counter (simple, but allows double the limit across a window edge), sliding window log (exact, memory heavy) or sliding window counter (approximation with two counters). For a cluster, keep counters in Redis with atomic operations, keyed by user or API key, using a Lua script so check and update are atomic. Place the limiter at the API gateway, return 429 with a Retry-After header, and decide what to do when Redis is down: fail open for availability or fail closed for protection. Rules should be configurable per client and endpoint. Local in-memory limits with periodic sync trade accuracy for lower latency.

  5. 5

    Design a news feed: fan-out on write versus fan-out on read.

    hard

    Fan-out on write pushes a new post into every follower's precomputed feed list at write time, which makes reads very fast, but a user with 50 million followers causes 50 million writes. Fan-out on read assembles the feed at read time by fetching recent posts from everyone the user follows, which is cheap for writes but slow for reads. The usual answer is hybrid: push for ordinary users, pull for celebrities, and merge at read time. Store feeds as lists of post IDs in a cache, hydrate post content separately, rank with a scoring service, and paginate with cursors. Accept that feeds are eventually consistent.

  6. 6

    Design a chat system such as WhatsApp at a high level.

    hard

    Clients keep a persistent WebSocket connection to a gateway tier; a session service maps user to gateway. A sent message goes to a chat service, which assigns a per-conversation sequence number for ordering, persists it, and forwards it to the recipient's gateway if online or to a push notification service if offline. Store messages in a write-heavy store partitioned by conversation id, such as Cassandra or HBase. Delivery receipts are small acknowledgements flowing back. Group chat fans messages out to members, with a size cap. Presence is kept in a cache with heartbeats and short expiry. Trade-offs: ordering is per conversation, not global; end-to-end encryption means the server cannot search message content.

  7. 7

    How do you generate unique IDs in a distributed system?

    medium

    Options: UUIDs (no coordination, 128 bits, random so poor index locality), database auto-increment with multiple masters using different offsets (simple but awkward to scale), a ticket server (a single point of failure unless replicated), and Snowflake-style IDs. A Snowflake ID packs 41 bits of millisecond timestamp (about 69 years), 10 bits of machine id and 12 bits of sequence (4,096 IDs per millisecond per machine) into 64 bits, so IDs are roughly time-ordered and sortable. The weak point is clock skew; refuse to issue IDs if the clock moves backwards.

  8. 8

    Design search autocomplete.

    hard

    Data structure: a trie where each node stores the top-k completions for its prefix, so a lookup walks the prefix and returns the cached list in O(length of prefix). Build it offline: aggregate query logs, count frequencies, rebuild the trie periodically, and serve from memory or from a key-value store keyed by prefix. Layer in a browser or CDN cache for the most common prefixes and debounce keystrokes on the client. Handle freshness with a small real-time layer for trending queries, filter offensive terms and shard the trie by the first characters. Latency target is under 100 ms.

  9. 9

    How would you scale a relational database?

    medium

    In order of cost: add indexes and fix queries; add a cache; use read replicas to scale reads, accepting replication lag; partition large tables; and finally shard by a key such as user id, which complicates joins, transactions across shards and resharding. Vertical scaling buys time first. Mention that sharding by hash spreads load evenly while range sharding supports scans but creates hot spots, and that cross-shard transactions need two-phase commit or sagas. See DBMS interview questions for the base concepts.

  10. 10

    How do you decide between SQL and NoSQL in a design?

    medium

    List the access patterns. Need joins, transactions across entities and flexible queries, choose relational, as for payments or inventory. Need very high write throughput, key-based access and simple horizontal scaling, choose a key-value or wide-column store, as for messages or events. Need flexible documents read as a unit, choose a document store. Many systems use several. Justify with load numbers instead of fashion. See NoSQL interview questions.

  11. 11

    How do you make a payment API idempotent?

    hard

    The client generates an idempotency key per logical operation and sends it with the request. The server stores the key with the request fingerprint and the result in the same transaction as the side effect, using a unique constraint on the key. If the same key arrives again, the server returns the stored response and does not charge again. If a request is in flight with the same key, return a conflict or wait. Keys expire after a retention window. This makes retries after timeouts safe, which matters because networks drop responses.

  12. 12

    Offset versus cursor pagination: which scales?

    medium

    Offset pagination (LIMIT 20 OFFSET 100000) makes the database skip and discard rows, so deep pages get slower, and inserts between requests cause duplicates or gaps. Cursor (keyset) pagination returns the last seen key and asks for rows after it, such as WHERE id < :last ORDER BY id DESC LIMIT 20, which uses an index and stays fast and stable. The cost is that you cannot jump to arbitrary page numbers. Use cursors for feeds and infinite scroll.

  13. 13

    How do you handle a hot key or a celebrity user?

    medium

    Detect the hot key through metrics, then reduce its load. Cache aggressively, with an in-process cache in front of a shared one. Replicate the hot value across several cache keys (key#1 to key#N) and pick one at random per read. For writes, buffer and batch counter updates. Shard a hot partition further by adding a suffix or splitting the entity. For feeds, treat celebrities with fan-out on read, as above.

  14. 14

    Design a file storage service such as Drive at a high level.

    hard

    Split files into fixed-size chunks (for example 4 MB), hash each chunk and upload chunks in parallel, so a failed upload resumes and unchanged chunks are not re-uploaded. Store chunk bytes in object storage and file metadata (name, owner, chunk list, version, permissions) in a database. Deduplicate by chunk hash. A sync service notifies clients of changes through a message queue or long-poll. Handle conflicts by keeping both versions when two edits collide. Trade-offs: smaller chunks improve dedup and resume but increase metadata; encryption at rest and sharing permissions add complexity.

  15. 15

    What do 99.9 and 99.99 percent availability mean in numbers, and how do you achieve them?

    medium

    In a 365-day year, 99.9 percent allows about 8.76 hours of downtime and 99.99 percent about 52.6 minutes. Components in series multiply availability: two services at 99.9 percent each give about 99.8 percent together. To raise it, remove single points of failure with redundancy across zones, health checks and automatic failover, use timeouts, retries with backoff and circuit breakers, deploy gradually with rollback, and have monitoring that pages on user-visible errors. See load balancing questions.

Frequently asked questions

How long should I prepare for system design?

Plan several weeks for a first pass: learn the building blocks, then practise six to ten classic designs aloud with a timer.

Do freshers get system design questions?

Usually a light version or a low-level design problem. See the freshers page for what to expect.

Is there one correct answer in system design?

No. Interviewers evaluate your reasoning, your numbers and whether you state the trade-offs of your choices.

Should I draw diagrams?

Yes. Keep them simple: boxes for components, arrows for requests, and labels for data stores and queues.

Related guides

More in CS Fundamentals Interview Questions

See all in this section