Grow a design
medium 35 minStart with the smallest system that does the job.
Video lesson · Chapter 1 of 5
Record the reason for each version
One break, one fix
1:20Reel coming soon
Theory
Read or listen first. About 1 min.
What it is
Growing a design means starting from the smallest system that works and changing it in steps. Each step answers one problem that the previous version could not.
It is the opposite of drawing the final picture from memory.
Why it exists
A small system can be explained, tested and trusted. From there, each addition has a visible reason.
Growing also tells you when to stop. If no target is missed, there is nothing to add.
A short history
1975
John Gall's Systemantics: a complex system that works has evolved from a simple one that worked.
1990s
Extreme programming popularises "you aren't gonna need it" and frequent small steps.
1999
Martin Fowler's Refactoring describes improving software in small safe changes.
2000s onwards
Cloud platforms make it practical to add capacity and parts after launch.
Words to know
- Version
- A complete design that does the job within its limits.
- Break
- The first target a version misses.
- Headroom
- How far you are from a limit.
- Over-engineering
- Parts without a reason.
- Migration
- Moving from one version to the next while running.
How it works
Step through the idea, or press Play.
Version 1. Correct, complete and small
Understand it
Start here
The village and the river
A village needs to cross a river. Nobody begins with a great bridge. They lay stones, and use them until something does not work. Each change answers one problem, and each has a price.
The loop
Four sentences per version
Grow or stop
| Say | Example | If you cannot say it |
|---|---|---|
| It breaks here | "Reads, 10,000 a second at 7:45, and I plan one database for that." | You have not found a break |
| So I change this | "Keep the newest position in Redis." | You are adding a favourite part |
| It costs this | "A position can be a few seconds old, and Redis can fail." | You have not decided yet |
| Now the next limit is | "A database failure at 7:45." | You do not know whether to go on |
Version 1
Small, but correct
Version 1 is small in parts, not in care. It does every chosen feature and keeps the rule that must never break. It is not a prototype that loses data.
A good version 1
- Every feature, end to end
- The "never" rule is enforced by the database
- Data is backed up
- You can walk one request through it
- Two or three boxes
A poor version 1
- Only the feature you like
- "We will add checks later"
- Seven boxes, nothing connected
- A queue because queues are good
- No backup of data that must not be lost
A version 1 for most prompts
Find the break
Ask with a number
Walk the targets in order and compare each with what the current version can do. The break is the first one that fails. These are the usual places.
Seven places a design breaks
Reads
Too many a second for one store. Index, cache, replicas.
Writes
Too many a second. Batch, queue, bigger machine, then split.
Size
Data or files outgrow one place. Object storage, partitions, deletion.
Contention
Many want one thing. A rule that lets one win, then a waiting room.
Connections
Many are open at once. Gateways that only hold connections.
Distance
The network uses up the time. Edge, regions.
Failure
One part down breaks a promise. A standby, retries, a reduced mode.
Headroom: how long until it breaks?
Fix it
The smallest change first
For one break there are several fixes. Try them from cheap to heavy, and stop at the first that meets the target with room to spare.
| Break | Try first | Then | Only then |
|---|---|---|---|
| Slow reads | An index, a smaller query | Cache with a short life | Replicas, a search engine |
| Many writes | Batch them | A bigger machine, a queue | Split the data |
| Large files | Resize, compress | Object storage | CDN |
| Must be live | Poll less often | Server-sent events | WebSockets with gateways |
| One machine fails | Backup and a tested restore | Standby with automatic failover | A second region |
Choosing a fix
Worked example 1
School bus tracker, four versions
Targets: a parent sees only their own child's bus, a position at most 10 seconds old, 99.9% on school mornings. The plan is one district first, then a whole city, then a live map.
Grow the bus tracker
Version 1: One district
Forced by: The features: a bus reports, a parent looks, the school sets stops. 50 buses and 2,000 parents.
- What changes
- One service and PostgreSQL. A bus sends a position every 5 seconds, so 10 writes a second. Parents poll every 10 seconds, so 200 reads a second. Every read checks that this parent has a child on this bus. Nightly backup.
- What it costs
- Almost nothing. One thing to run.
- What breaks next
- Nothing yet. For one district, stop here. The next limit is reads, if a city joins.
Say: It already protects the child's stop. Two hundred reads a second need no cache.
Check the numbers
Worked example 2
Recipe sharing, five versions
Targets: pages in 300 ms for 95 of 100 requests, search in 500 ms, a posted recipe is never lost, 99.9%.
Grow the recipe site
Version 1: Launch
Forced by: Post, view and search. 100 recipes a day, four photos each.
- What changes
- One service and PostgreSQL. Photos on the machine's disk: 100 × 4 × 500 KB is 200 MB a day. Search with a plain query. Nightly backup of both, copied elsewhere.
- What it costs
- A disk failure loses up to a day. That misses "never lost", so this version is for a private trial only.
- What breaks next
- The promise not to lose a recipe, before any load.
Say: It works end to end, and I know which promise it does not keep yet.
Exceptions
What cannot wait for version 4
Growing step by step works because most changes are easy to make later. A few are not. Find them in version 1, spend a minute on each, and leave the rest.
Now or later?
| Choice | Why it is hard to change | In our two systems |
|---|---|---|
| Main key | Every record and link uses it | A recipe gets an ID that does not depend on one database |
| Who may see what | A leak cannot be undone | The parent check is in version 1 |
| Where data may live | Laws and contracts | Children's data stays in the home region |
| Public calls | Others depend on them | Photo links go through our own domain |
Stop
Knowing when to stop
- 1
Read the targets aloud
Tick each one with the number that meets it.
- 2
Remove each box in your head
If no target fails, the box goes.
- 3
Say what you did not build
"No shards: 91 GB in five years."
- 4
Name the next limit and its trigger
"At about 10,000 page reads a second I would cache pages."
When they push past the stop
Interviewer
Would you not use Kafka here?
You
Which target would it help? Writes are 0.1 a second and nothing else reads them as they happen. Today it is a part to run with no job.
Interviewer
Say five teams want every new recipe.
You
Then there is a job. I would write each event to a table in the same transaction as the recipe, and publish from it. A log such as Kafka fits when several readers need their own position. The cost is running it, and duplicates that readers must handle.
Summary
The whole topic in one minute.
Begin small and correct. Find the break with a number, make the smallest fix, say what it costs, and repeat.
Stop when every target is met, and say that you are stopping.
- Version 1 is small in parts, not in care.
- One break, one fix, with a number and a cost.
- Cheap fixes first: remove load, grow what you have, then add.
- The first break may be a promise, not a load.
- Stop aloud: what is met, what is not built, what would change it.