System Design: Foundations
What is system design?
Why a program that works for ten users can collapse at ten thousand, what "architecture" means, and how it differs from detailed design.
Imagine you open a small café. One person takes orders, makes coffee, and handles the till. It works. Ten customers an hour is no problem.
Now a review goes viral and two hundred people show up. Nothing about your coffee changed. Your setup is what broke: one person, one counter, one till. (The one person is now also crying, which is a monitoring problem we will get to.)
System design is the work of deciding how a piece of software should be set up so it keeps working as more people use it. It’s about the arrangement of parts, not the code inside them.
The three questions behind everything
Almost every system design decision answers one of these:
- What happens when there is more load? More users, more data, more requests.
- What happens when something breaks? A server dies, a network link drops, a disk fills up.
- What are we willing to give up? Speed, cost, simplicity, or perfect accuracy. You rarely get all of them.
A useful habit: whenever you read about a technique, ask which of the three questions it answers, and what it costs.
What the parts look like
A typical web product has a few kinds of parts. Each one is a later lesson here.
| Part | Job | Café version |
|---|---|---|
| Servers | Do the work | Baristas |
| Database | Remember things | The order book |
| Cache | Keep popular answers close | Pre-made drinks |
| Load balancer | Split the work | The person at the door directing queues |
| Queue | Hold work for later | Tickets on the rail |
So what is “architecture”?
You will see two words used almost interchangeably: system design and architecture. The way I use them:
Architecture is the set of decisions that are expensive to change later. Which parts exist, what each one is responsible for, how they talk to each other, and where the data lives.
In the café, that is: one counter or two? Do orders go on tickets or get shouted? Is the kitchen behind the till or in another building? You can repaint the walls any day. Moving the kitchen means closing for a week.
That framing, cost of changing your mind, is the most useful one I have found. It explains why architects fuss over some choices and shrug at others.
Architecture versus detailed design
These sit at different zoom levels. Neither is “more important”, but they answer different questions.
| Architecture | Detailed design | |
|---|---|---|
| Zoom level | Whole system, many parts | Inside one part |
| Typical question | Should orders go through a queue? | How does the order class validate a coffee size? |
| Who is affected by a change | Several teams, sometimes customers | Mostly the people working on that part |
| Cost of getting it wrong | High, slow to undo | Low to medium, usually local |
| Example choices | Separate services or one app; SQL or a document store; sync or async | Function names, class layout, which loop to use |
The boundary is blurry, and that is fine. A useful test: if I change my mind in six months, how many people and how many weeks does it touch? The bigger the answer, the more it belongs on the architecture side.
What a design actually produces
Design is not the same as drawing boxes. For a given system, I expect a design to leave behind:
- A list of parts and what each one is responsible for. If two parts both “own” the same thing, expect bugs.
- How the parts communicate. Calls, queues, shared storage, and what happens when a message is lost.
- Where data lives, and who is allowed to change it.
- The reasons. Why this and not the alternative. This is the part people skip, and it is the part you will want in a year.
A small worked example
Say we are building a link shortener: you paste a long URL, get a short one back, and visiting the short one redirects.
A first design is one server and one database table. That is a perfectly good architecture for ten users.
Now ask the three questions:
- More load? Reads (redirects) will vastly outnumber writes (creating links). So reads are the thing to make cheap, maybe with a cache in front.
- Something breaks? If the one server dies, every link is dead. So we want more than one server, and therefore something to split traffic between them.
- What do we give up? Do we need the exact click count right now, or is “roughly right in a minute” fine? The second is far cheaper.
None of that needed code. It needed asking what the system has to survive, then picking parts that survive it. Later lessons take each of those parts apart.
Common mistakes I want to avoid
- Designing for a scale you don’t have. Ten users do not need a hundred servers. Extra parts are extra things to break. Nobody ever got paged at 3am because the single server was too simple.
- Picking technology first. “We’ll use Kafka” is not a design. It is an answer to a question nobody has stated yet.
- Treating the diagram as the design. A diagram without the reasons and the failure cases is a nice picture.
What this course is, and isn’t
It is an attempt to understand each idea well enough to explain it simply, with fewer buzzwords than a conference talk. It is not interview prep, and it isn’t authoritative. When something here turns out to be wrong, it gets fixed and the updated date changes.
Next up: the forces that shape a design before any technology is chosen, namely business goals, constraints and risks.