System Design Handbook · llms.txt
In a system design interview, you're given a short, open prompt such as "Design a URL shortener" or "Design the Twitter timeline," and about 45 minutes to talk through how you'd build it. There is no single correct answer. The interview is an open-ended conversation, and you are expected to lead it.
That's what makes it different from a coding interview. A Palantir engineering post on these interviews, How to ace a systems design interview, says that whatever design you produce "is just a side effect." What the interviewer actually cares about is "the thought process behind your design choices." The same post warns that the prompts look simple but are "wide and bottomless," and reminds candidates that "there is no single right answer to a real-world problem. Everything is a tradeoff."
This chapter gives you four steps that keep the conversation on track. Use them on every practice question in the handbook. Each of the worked design questions follows the same four steps, so you can compare your answer with one that's laid out the same way.
A rough way to split 45 minutes, which you should adjust to the question and the interviewer:
| Step | Rough time |
|---|---|
| 1. Outline use cases, constraints and assumptions | 5–10 minutes |
| 2. Create a high-level design | 10 minutes |
| 3. Design the core components | 15 minutes |
| 4. Scale the design | 10 minutes |
We'll use one example throughout: "Design a URL shortener," a service like TinyURL or Bitly that turns a long web address into a short link and redirects anyone who opens it. The handbook's full answer is in Design a URL shortener.
Before designing anything, find out what you're building and how big it is. Ask questions to pin down the use cases and the constraints, and say your assumptions out loud.
Questions worth asking for almost any system:
Sort the answers into two lists:
Also say what you're leaving out, such as billing or fraud detection. It shows you're managing scope on purpose.
Then estimate. Turn the answers into a few numbers: requests per second at peak, storage over a few years, and how much data is hot enough to cache. For the URL shortener, the handbook's design assumes 100 million new links a month and 100 redirects per new link. That works out to about 39 writes and 3,860 redirects per second on average, and about 3 TB of storage over five years. Two conclusions fall out at once: the system is very read-heavy, and the data is small enough that the real challenge is serving reads quickly, not storing them. The estimation chapter teaches the method.
If the interviewer doesn't give you a number, propose one and say it out loud. A clearly stated assumption is better than a long pause.
Now sketch the whole system with all of its important parts, before going into detail on any of them.
POST /api/v1/urls to create a link and GET /<code> to follow one, and a table that maps each short code to its long URL.Keep this step short. Its job is to agree on the shape of the system with the interviewer, so the rest of the time is spent on the parts that matter.
Pick the most important parts and go into detail on each. Often the interviewer will steer you toward one. For the URL shortener, the core components are:
Generating and storing the short code.
The worked design compares both approaches in Generating the short code and gives the schema.
Translating a short code back into the long URL. Each redirect is a lookup by code: check the cache, fall back to the database, then reply with an HTTP redirect. Even the choice of status code matters. A 301 lets browsers cache the redirect and skip your servers next time, while a 302 sends every click through you, so you can count it. See 301 vs 302.
The API and the object-oriented design. Define the requests and responses exactly, and, if asked, the main classes in the code.
For each component, explain the options you considered and why you picked one. That reasoning is what the interviewer is listening for.
Finally, look for the bottlenecks, given the constraints from step 1, and fix them. Common questions to ask yourself:
For the URL shortener, the estimates in step 1 already point the way. Redirects outnumber new links 100 to 1, so a cache in front of the database serves most of them. Link creation is slow enough that one database could take it for a while, but billions of rows over five years mean planning how to shard the table.
Everything is a trade-off. For each fix, say what it costs: more parts to run, data that may be briefly out of date, or extra latency. Discuss more than one option, then pick one and say why. The scalability chapter walks through the usual fixes in the order systems tend to need them.
You may be asked to estimate numbers by hand at any point in the interview. Three resources help:
Google's Jeff Dean argues that every engineer should be able to estimate how well different designs will perform this way, before building any of them. High Scalability's 2011 post, Google Pro Tip: Use Back-of-the-Envelope Calculations to Choose the Best Design, summarizes his advice with a worked example.
These come up again and again in practice interviews:
Questions and assumptions, not boxes. Who uses it and how: do people upload, follow others and scroll a feed? Which features are in scope: comments, likes, stories? How many daily users, how many uploads a day, how big is a photo, and what's the ratio of views to uploads? Then state the numbers you'll assume, turn them into rough requests per second and storage, and say what you're leaving out. Only then start sketching.
Because the interviewer is judging your reasoning, not the diagram. A box labelled "cache" tells them you know caches exist. Saying "redirects outnumber new links 100 to 1, so a cache will serve most of them" shows you can connect a requirement to a design choice.
The two options fail in different ways. Hashing the URL and keeping only part of the hash can make two different URLs produce the same short code, so you need a plan for collisions, such as checking the database and trying again. A counter never collides, but every server needs unique numbers, so you need a way to hand them out without one server becoming a bottleneck. Choosing one, and saying why, is the kind of decision the interview is about.
Go back to the numbers from step 1, multiply them by ten, and find what breaks first. Maybe the database can't handle the reads, the app servers run out of capacity, or the data no longer fits on one machine. Then propose a fix for each bottleneck, such as caching, more app servers behind the load balancer, or sharding, and say what each fix costs. Don't add components the new numbers don't need.
Previous: How to use this handbook · Next: Scalability