Module 1 / What is system design? / Worked example: from one sentence to a design

Lesson10 minModule 1 · lesson 8 of 9

Worked example: from one sentence to a design

Use the process on a real request.

Let's apply everything so far to a single sentence from a manager: "We want people to order food from nearby restaurants." We will go step by step, keeping the design as simple as the numbers allow.

Walking the process

Step 1 of 7

Clarify

Ask: customers, restaurants and drivers, or just ordering? Payment inside the app? One city or many? Decide the first version covers one city, customers and restaurants, with card payment through an outside provider.

Customer appAPI serverDatabaseMenu cacheImage storageorder andbrowseorders,restaurantsmenus(later)images
The first version and the upgrade path it points to.

Notice what we did not do. We did not add queues, microservices or a distributed database. The estimate said the load is modest, so the simplest design is also the right one. The stress step told us where we will grow first, which means the team knows what to watch and the design can evolve without a rewrite.

Decision: single relational database for orders
Why: 12 writes/sec peak, 146 GB/year; needs correctness (no lost orders)
Given up: single point of failure; mitigated with a standby copy
Revisit when: peak writes exceed ~1,000/sec or data exceeds a few TB
A decision record: short, with the reasoning and a trigger to revisit.
Question 1

Why is a single database a reasonable first choice here?

Question 2

What does the stress step suggest improving first?

Your turn

Write one decision record line (decision, why, what you gave up) for storing images in file storage instead of the database.

Stuck? Use the same three parts as the example.

What to remember

  1. Turn a sentence into questions, then lists of functional and non-functional needs.

  2. Estimate before sketching.

  3. Pick the simplest design the numbers allow.

  4. Stress it to find where to grow first.

  5. Record the decision, the cost and when to revisit.