Five minutes and an empty canvas
"What do you actually do in the first five minutes?" You place almost nothing. You run through a fixed loop of questions, the same six every time, whatever the system, so the big decisions do not get skipped and every box you eventually place has a reason to exist.
The order matters because each answer is the raw material for the next question. You cannot count the load of a system whose job you have not stated, and you cannot ask what happens when a box dies until you know which boxes a request passes through.
- Requirements. What must the system do (functional), and how well (scale, latency, availability)? Write the top three of each before drawing anything. That tells the next question what to count.
- Estimation. Back-of-envelope traffic, storage and bandwidth. The numbers decide whether you need one database or a sharded fleet.
- Data ownership. What entities exist, which service owns each, and what the primary keys are. Now requests have something definite to read and change.
- Read path, then write path. Trace one request of each kind end to end through your boxes. That lists the boxes a request depends on.
- Failures. For each of those boxes, ask what happens when it dies. Add redundancy or accept the risk explicitly. What you accept goes to the last question.
- Trade-offs. Say out loud what you gave up (consistency, cost, freshness). Every real design gives something up.
A school district wants lunch pre-orders across 24 schools and 18,000 pupils. Parents order by 9:00, and the kitchens read their totals at 9:05.
Six orders a second
What it must do: a parent orders or changes today's lunch until 9:00; the parent sees what was ordered; each kitchen sees its school's totals per meal at 9:05. How well: it takes the whole district's rush before the deadline, confirms an order within a couple of seconds, and stays up from 8:00 to 9:05 on school days, when an outage costs a child a lunch. Who stands outside the system and what each of them wants is its own decision, covered in Use cases, actors and the system boundary.
Those requirements hand over a deadline, so the orders will not spread evenly through the morning. Say 60% of pupils order on a typical day, which is 10,800 orders, and half arrive in the last 15 minutes: 5,400 orders in 900 seconds, or 6 a second, with perhaps 30 a second in the busiest moments. An order is around a kilobyte on the wire, so bandwidth is not a concern. At about 200 bytes a row and 190 school days, storage grows by about 400 MB a year before indexes. On the other side, 24 kitchens ask for their totals.
Those are assumptions to check with the district, and even several times over, one ordinary relational database handles this comfortably. A sharded multi-region fleet would be a wrong answer here, not a cautious one: you would pay to run machinery no traffic asked for. Back-of-envelope estimation shows the arithmetic.
Who owns an order, and who owns a total
An Order Service owns the two entities that matter here, orders and the day's menu. An order's primary key is the pupil plus the date, so a pupil has one row a day. Changing pasta to soup then updates the row instead of adding a second lunch.
The tempting next step is a Kitchen Service with its own running count, adding one per order. Now two services both "kind of" own how many pasta lunches there are, and one missed update makes them disagree: you have designed a consistency bug. So a total is derived from the orders when a kitchen asks, and nobody stores it.
Follow a read, then a write
At 9:05 a kitchen screen asks for its school's totals. The Order Service counts today's orders for that school, per meal, and returns them. Trace only this and the design looks finished. Read paths are usually the easy half; designs tend to break on writes, on contention, ordering and idempotency.
A parent taps Order at 8:59:58, on a weak signal outside the school gate. Whose clock decides the deadline? The service's, because a phone's clock can say anything, so this order may arrive at 9:00:03 and be refused. What if the phone times out and sends the order again? The key stops a second lunch: same pupil, same date, same row. A resend that lands after the parent changed to soup could still put pasta back, which the key alone does not stop; Idempotency & exactly-once illusions covers the general problem.
The trace also explains the five minutes in the brief: no new order is accepted after 9:00, and the gap is there for the orders already accepted to finish. So the design owes a requirement of its own: everything those orders still have to do, retries included, must commit or roll back inside the gap, or the 9:05 totals are not final. A database that is down is the next question.
What if this box dies at 8:55?
Put that question to each box the traces went through. If a single Order Service crashes at 8:55, parents get errors in the worst five minutes of the day. So run two instances behind a load balancer. The failure question put that box there; 30 writes a second would not have justified it. Load balancing & horizontal scaling covers the balancer itself.
The database is harder. A standby it can fail over to shortens an outage without removing it. Add that, or accept the risk, but say which.
The requirement nobody wrote down
The crash exposes something bigger. What does a kitchen do about a child with no order, whether the service was down or a parent forgot? No requirement says. Go back a step here, because patching the gap in place would leave the later answers wrong. The rule: when an answer contradicts or adds to an earlier one, return to the question that owned it and walk forward again.
So, back to requirements: the district decides that every enrolled pupil gets a meal, the default one if nothing was ordered. Estimation barely moves. Data ownership gains the pupil list, owned by the district's school records system, which this design only reads. The kitchen's read changes, because every enrolled pupil with no order, enrolled minus orders, now adds to the default meal's count. The failure question has a new box to look at, and the answer is a copy of the list the Order Service takes every night into its own database, so a records outage at 9:05 does not stop the kitchens. A detail that changes no earlier answer does not need the trip.
A first pass stays this small; the loop grows it where a number or a failure demands it.
What this design gave up
Said out loud, this design gives up three things. Freshness: a pupil enrolled this morning is missing from the kitchen's count until tomorrow. Cost: the kitchen cooks default meals for pupils who turn out to be absent, because the system knows who is enrolled and cannot see who came in. Availability: one database in one place is cheap, but it holds the orders and that copy of the list, so while it is down parents cannot order and kitchens cannot read. If an outage at 8:55 ends before 9:05, the totals count the orders already saved and give every other enrolled pupil the default meal, including those whose parents could not get through; if it outlasts 9:05, the kitchens have no totals until it comes back. When what you give up is consistency, Consistency models: strong vs eventual (CAP) is the article for that choice.
Aloud, before the first node
Before placing a node in URL Shortener, say the first answers aloud: the top three requirements of each kind, what the brief's 100:1 read-to-write ratio means for where the pressure falls, and who owns the mapping from alias to URL. A good run produces a small diagram where you can point at any box and say which question put it there. Expense Splitting makes a good second run: its data-ownership step decides which numbers are stored records and which are derived from them, the question Debt simplification: netting a group's balances works through.