System design
Learn to answer any "design X" interview question by building the system and explaining each choice.
Not sure you know the basics? Find out in fourteen questions.
Each level is a harder kind of problem, so topics you've met come back tougher.
-
Safety briefing
OptionalPlannedStuck on a word like DNS or API? Short explainers, whenever you need them.
Show 14 topics- How the web finds a site (DNS)PlayContinueDone
- Addresses and connectionsPlayContinueDone
- TCP or UDP: whole or on timePlayContinueDone
- What a browser and a server say to each other (HTTP)PlayContinueDone
- Cookies: how a site remembers youPlayContinueDone
- Client and server: never trust the clientPlayContinueDone
- APIs: change one without breaking anotherPlayContinueDone
- Databases and indexesPlayContinueDone
- What a server is made ofPlayContinueDone
- Busy servers and waiting linesPlayContinueDone
- How long each step takesPlayContinueDone
- Measuring speed, load and errorsPlayContinueDone
- Alerts and uptimePlayContinueDone
- Trace one request through one serverPlayContinueDone
-
More than one server
New gradLesson 1 openYou can keep one app running through a busy day.
Interview prep: the basics every answer is built on.
Load balancer10 lessonsSpread traffic and survive a dead server.
- One server meltsPlayContinueDone
- Bigger box or more boxesPlayContinueDone
- WorkersPlayContinueDone
- Share the trafficPlayContinueDone
- Stop calling the dead: health checksPlayContinueDone
- Choose how to sharePlayContinueDone
- Send each kind of request to the right serversPlayContinueDone
- The load balancer can die tooPlayContinueDone
- A whole building goes darkPlayContinueDone
- Tune itPlayContinueDone
- Design: lunch rushPlayContinueDone
Stateless servers9 lessonsAdd or remove servers without logging anyone out.
- Why did I get logged out?PlayContinueDone
- Sticky sessions and their catchPlayContinueDone
- Move sessions to a shared storePlayContinueDone
- Where did my photo go?PlayContinueDone
- The newsletter went out four timesPlayContinueDone
- Add and remove servers freelyPlayContinueDone
- Ship without downtimePlayContinueDone
- The new version is brokenPlayContinueDone
- Tune itPlayContinueDone
- Design: paydayPlayContinueDone
Picking a database10 lessonsChoose SQL or NoSQL and defend the choice.
- Tables and joinsPlayContinueDone
- Documents, key-value and othersPlayContinueDone
- When it must be all or nothingPlayContinueDone
- Rules the database keepsPlayContinueDone
- Two people bought the last ticketPlayContinueDone
- Saved means savedPlayContinueDone
- Too many connectionsPlayContinueDone
- The disk diedPlayContinueDone
- Start from the questions your app asksPlayContinueDone
- Tune itPlayContinueDone
- Design: pick the database for a blogPlayContinueDone
Cache8 lessonsAnswer most requests without touching the database.
- Stop asking the database twicePlayContinueDone
- Hit rate: how often the cache answersPlayContinueDone
- Old answers and when to expire themPlayContinueDone
- Writing through the cachePlayContinueDone
- One cache per server or one shared?PlayContinueDone
- Never cache someone's private pagePlayContinueDone
- The stampede after a cold startPlayContinueDone
- Tune itPlayContinueDone
- Design: front-page spike from coldPlayContinueDone
Before the gate2 lessonsTalk through your design, then fix a real config.
- Walk me through itPlayContinueDone
- Read the real configPlayContinueDone
Scored on cost, speed and errors.
- Traffic
- 2,000 visitors/s
- Lasts
- 10 min
- Budget
- About 4 servers
- Slowest pages
- Under 300 ms
- Errors
- Under 0.1%
-
Viral
Mid-levelPlannedYou can handle a sudden crowd and size a system before building it.
Interview prep: where design interviews begin.
Show 11 areas- Ask before you buildTurn a vague question into features, numbers, an API and data.
- Back-of-envelope mathsEstimate traffic and storage before you build.
- Files close to usersServe files and pages from close to each visitor.
- Read copiesSpread reads and handle data that lags behind.
- A copy far awayPut a read copy in another region for faraway users.
- Cache under a crowdBack from L3Survive millions of people wanting the same item.
- Rate limiterSlow down abusers without hurting everyone else.
- Unique IDsMake IDs on many machines that never clash.
- Timeouts and retriesGive up on slow calls and try again without piling on.
- Your first queueMove slow work out of the request.
- Locks on the doorsStore passwords, sign people in and keep secrets safe.
Gate: link shortener
Scored on cost, speed and errors.
- New links
- 100M a month
- Reads
- 10 per write
- Redirects
- Under 50 ms worldwide
- Uptime
- 99.9%
- Budget
- Fixed monthly
-
Too big for one machine
SeniorPlannedYou can design a whole product on your own.
Interview prep: the main interview target.
Show 16 areas- ShardingSplit data across machines and pick the right key.
- Consistent hashingAdd a machine without moving everything.
- Splitting the app into servicesSplit off services only where it pays.
- Queues and workersBack from L4Handle crashes, floods and bad jobs in a queue.
- Event logs and streamsLet many readers replay the same events.
- Safe retriesBack from L4Repeat a request without doing the work twice.
- Live connectionsKeep millions of WebSockets open.
- Fan-outDecide between push and pull for a feed.
- SearchFind words in millions of posts, and suggest as people type.
- LocationFind what is nearby and match riders to drivers.
- Media pipelineUpload, convert and stream video.
- Caches that stay correctBack from L4Update many caches when the data changes.
- A backup regionBack from L4Keep a second region ready to take over.
- How databases store dataBack from L3Pick how each kind of data is stored.
- Many people, one thingSell the last seat once, even to a crowd.
- MonitoringSpot trouble in the graphs while it's still small.
Gate: chat app
Scored on cost, speed and errors.
- Users
- 50M a day
- Messages
- Under 200 ms
- Order
- Always kept
- Offline users
- Get everything on return
- Main region
- Fails once
-
Things break
StaffPlannedYou can keep a system correct while parts of it fail, and defend the tradeoffs.
Interview prep: staff-level tradeoff questions.
Show 17 areas- What "correct" meansSay exactly what each user sees after a write.
- Copies and quorumsDecide how many machines must agree.
- Network splitsChoose what stays up when machines can't talk.
- Time and orderPut events in order without trusting clocks.
- Leaders and consensusElect one leader, and never two.
- Data across servicesKeep data right across services without one big transaction.
- Two regions that both writeBack from L5Decide who wins when regions disagree.
- Stop one failure from spreadingKeep one slow part from taking down the rest.
- The slowest 1%Keep the slowest requests fast.
- Hot shardsBack from L5Split a busy shard while it keeps serving.
- Queues that fall behindBack from L5Slow the senders before the backlog sinks you.
- Streams with timeCount events per minute, even when they arrive late.
- Big-file storageStore huge files safely and cheaply.
- Error budgetsBack from L5Use failure numbers to decide when to stop shipping.
- Failure drillsPractise failures before they happen, and lead the response when one does.
- Keep it simpleWrite the design doc, choose build or buy, and cut parts.
- Money done rightKeep the books exact, down to the cent.
Gate: payments
Scored on cost, speed and errors.
- Machines
- One dies every hour
- Network
- Splits mid-run
- Regions
- Two, both take payments
- Payments lost
- Zero
- Double charges
- Zero
-
Planet scale
Senior staffPlannedYou can run a system worldwide and weigh cost, law and change.
Interview prep: senior staff questions on cost, law and change.
Show 10 areas- Worldwide trafficBack from L6Serve every user from the right region.
- Cells and blast radiusLimit how many users one failure can reach.
- Losing a region at peakBack from L5Move a whole region's users without losing data.
- Capacity planning and launchesBack from L4Plan and load-test a launch before it happens.
- Data rules by countryKeep each country's data where the law says.
- Cutting costSpend less without breaking your limits.
- Zero-downtime migrationBack from L4Change a live system while people use it.
- A platform for many teamsLet many teams build on one system safely.
- Abuse at scaleBack from L4Keep bots and fraud out of a big sale.
- Built to lastPlan years of work in steps that each ship.
Capstone: worldwide ticket sale
FreePass it for the trophy.
- Crowd
- 10M in 5 min
- Halfway
- A region goes dark
- Budget
- Cut by 30%