How to think about any design
easy 30 minYou do not need to have seen the problem before.
Video lesson · Chapter 1 of 5
A map with a thousand pins
Five questions for any design
1:30Reel coming soon
Theory
Read or listen first. About 1 min.
What it is
This topic is about the thinking that happens before and during a design: what to ask, what to build first, and when to add something.
A system design is a plan for how parts such as services, databases and caches work together to do a job for people. The job comes first. The parts are answers to questions the job raises.
Why it exists
Interview prompts are open on purpose, and real projects are too. Without a method, people either freeze or draw everything they know.
A small set of questions gives you a place to begin on a problem you have never seen, and a reason for every part you add.
A short history
1945
George Pólya publishes How to Solve It: understand the problem, make a plan, carry it out, look back.
1975
John Gall writes that working complex systems grow from working simple ones, now called Gall's law.
Late 1990s
Extreme programming spreads the advice to build only what is needed now.
2016
Google publishes its Site Reliability Engineering book, followed by a workbook that teaches design with numbers.
Words to know
- Requirement
- Something the system must do or a quality it must have.
- Target
- A requirement with a number.
- Hard part
- What makes this system different from a simple store and show.
- Trade-off
- What you give up to get something else.
- Source of truth
- The store whose answer wins.
How it works
Step through the idea, or press Play.
Ask. Five questions tell you what matters and what is hard
Understand it
Start here
The lemonade stand
Picture a child selling lemonade. Nobody begins by building a factory. They pour a few cups, see what goes wrong, and fix that one thing. Good system design feels the same.
The five questions
Ask these before you draw
- 1
Who does what?
Name the actors and their actions. They become your features and endpoints.
- 2
What must never go wrong?
Money lost, seat sold twice, message leaked. This decides where you need strict correctness.
- 3
What is the hardest thing here?
Every design has one part that makes it different. Find it, name it, and save time for it.
- 4
What breaks first as it grows?
Reads, writes, storage, connections, one hot item, distance. Use a number.
- 5
What am I giving up?
Freshness, cost, simplicity, some availability. If you cannot name it, you have not decided yet.
From question to design
Use them
Three prompts you have not practised
| Question | Library seat booking | School bus tracker | Recipe sharing |
|---|---|---|---|
| Who does what? | Readers book, librarians block seats | Parents watch, buses report | Cooks post, others save and search |
| Must never go wrong | One seat, two readers | A stranger sees a child's stop | A saved recipe disappears |
| Hardest | The 9:00 rush on a few seats | Private, live positions | Search by what is in the kitchen |
| Breaks first | Many writers on the same seats | Open connections at 7:45 | Photo storage and search reads |
| Giving up | Seat map 2 s old | Position 10 s old | New recipe searchable in a minute |
Grow it
Smallest version first
The improvement loop
Grown
- Correct from the first version
- Each box has a reason
- Easy to remove a box and say what fails
- Time left for the hard part
Assembled
- Ten boxes in three minutes
- Nothing works end to end yet
- "Why Kafka?" has no answer
- The hard part gets two minutes
The skeleton
The bones most systems share
Client, CDN, load balancer, API gateway, services, cache, database. It is a checklist: when something fails a target, look here for where the fix could live. Draw only the bones this system needs.
A request through the bones
Listen
Words that point at a part
Some words in a prompt hint at a well-known part. Treat the hint as a candidate. Check it with a number before you draw it.
Eleven hints
| You hear | The limit | Candidate | Not needed when |
|---|---|---|---|
| Real-time, live, chat | Waiting between polls | WebSockets or server-sent events | Updates are rare: poll |
| Search, typeahead | Scanning text | Inverted index (Elasticsearch) | Small data: database text search |
| Analytics, trending | Volume and counting | Kafka and stream processing (Flink) | Yesterday's numbers are fine: nightly job |
| Background job, email | User waiting | Message queue (RabbitMQ, SQS) | The work takes milliseconds |
| Global, static, media | Distance | CDN (CloudFront, Akamai) | Users sit in one region and data is private |
| Video, image upload | Storage cost and I/O | Blob storage (S3), direct upload | Tiny icons |
| Payment, booking | Correctness | Transactions and idempotency keys | Nothing is scarce or paid for |
| Sensor data, metrics | Write rate | Time-series database (InfluxDB) | A few writes a second |
| Nearby, location | Two-dimensional search | Geohash, quadtree, Redis geo | About a thousand places: scan |
| News feed, timeline | Read load | Cache and fan-out | Few followers: query on read |
| Spikes, viral | Overload | Load balancer, autoscaling | Headroom already covers the spike |
Where you have met them
Open connection
Slack, Discord, trading screens, live scores.
Inverted index
Google Search, Amazon product search, GitHub code search.
Stream processing
Trending topics, recommendations, ad analytics.
Queue
Email, image processing, report generation.
CDN and blob storage
Netflix video, Instagram photos, Dropbox files, static sites.
Transactions
Card payments, ride booking, hotel booking.
Time series
Server metrics, smart homes, stock tickers.
Spatial index
Driver matching, nearby restaurants, map games.
Fan-out
Social timelines and activity updates.
Autoscaling
Holiday sales, product launches, breaking news.
Numbers
Let a number decide
Per day to per second
Live positions
Worked example
Ride hailing in four steps
"Riders can book a ride and see drivers in real time." The four steps are: lay the foundation, find the hard part, define the data flow, plug in the special parts.
How it opens
Interviewer
Design a ride-sharing service like Uber.
You
I would like to clarify the scope. Riders request rides, see nearby drivers in real time and get matched. Should I include payments and trip history?
Interviewer
Yes, include payments. Focus on matching and the real-time side.
You
I hear two hard parts: real-time positions and matching by location. They suggest an open connection and a spatial index. Let me check both against the numbers, then build up from a simple booking flow.
What makes each app hard
| App | The hard part | The special parts |
|---|---|---|
| Ride hailing | Live positions | WebSockets and a spatial index |
| Social feed | Reading millions of feeds | Cache and fan-out |
| Video site | Streaming huge files | CDN and blob storage |
Ride hailing, complete
How a position travels
- 1
Send
The driver's phone sends GPS every 3 seconds over a WebSocket.
- 2
Update
The location service updates Redis at once, so "nearby" is fresh.
- 3
Publish
The same point goes to Kafka without waiting.
- 4
Archive
An archive job writes trip history to Cassandra.
Defending it
Interviewer
Why Redis for positions, and not the main database?
You
At a million drivers it is about 333,000 small writes a second, and losing one position costs nothing because the next arrives in 3 seconds. Redis geo commands (
GEOADD,GEOSEARCH) keep a geohash index in memory and answer in about a millisecond.Interviewer
Two riders request the same driver at once. What happens?
You
The claim is a conditional update in the trip database: set the driver to matched only if still free. One wins and the other is offered someone else. An idempotency key on the booking makes a network retry safe.
Interviewer
And if a driver goes offline in the middle of a ride?
You
We watch heartbeats. After 30 seconds without a position we mark the driver as possibly offline and tell the rider. After a 2 minute grace period we look for another driver. The trip is stored in PostgreSQL, so restarting the live services loses nothing.
Interviewer
What changes at 100 times the load?
You
Split positions by city, so each has its own Redis. Partition Kafka the same way. The new problem is trips that cross a boundary; a routing layer sends each request to the right region.
Speak
Tell it as a story
| Part | Time | Sentence to fill in | Remember |
|---|---|---|---|
| Opening | 30 s | "I will design {system} for {scale}. The hard parts are {two or three}, and I will address them with {ideas}." | Own words; two or three challenges; show you know the scale |
| Main flow | 2 min | "Let me follow one request: {first}, then {next}..." | Client to database; latency at each hop; why each part exists |
| Deep dive | 5 min or more | "The trickiest part is {challenge}. Here is how I handle it." | Hardest part; trade-offs; failure and recovery |
| Wrap-up | 1 min | "We handle {challenge} with {solution} and reach {target}." | Key decisions; what you would do with more time; invite questions |
The same four, for ride hailing
- 1
Opening
"I will design this for 10 million rides a day in 50 cities. The hard parts are live positions, avoiding double booking at peak and picking a good driver. I will use WebSockets, transactions and a spatial index."
- 2
Main flow
"When a rider opens the app we read nearby drivers from Redis, in under 50 ms. Positions arrive every 3 seconds over WebSockets and go on through Kafka to the archive."
- 3
Deep dive
"The trickiest part is double booking. A conditional update lets one request win, and an idempotency key covers retries."
- 4
Wrap-up
"Positions live in Redis with lookups under 100 ms, trips in PostgreSQL, history in Cassandra. With more time: surge pricing, arrival estimates and region failover."
When you freeze
Getting unstuck
Four ways back
Summary
The whole topic in one minute.
You can design something new by asking five questions, building the smallest version, and fixing one break at a time.
Words in a prompt suggest parts; numbers decide whether you need them. Say what you chose, why, and what it costs.
- Five questions come before the first box.
- The smallest correct design first; then one break, one fix.
- A word suggests a part; a number decides.
- One source of truth, everything else is a copy.
- Choose, give the reason, name the cost, say what would change your mind.