Lesson 10 of 21
1. How to Approach a Design Question

1.9 What does a good high-level design look like?

3 min read+10 XP

Draw, Dive, Defend: solve it

At the architect's desk: A floor plan shows every room and how you walk between them. It doesn't show the wiring or the paint. And a good architect checks it by imagining walking through: front door, hall, kitchen. If you can't reach the kitchen, the plan is wrong.

In the interview: The high-level design is a diagram of the main components (boxes) and how requests flow between them (arrows). Two rules make it good:

  1. Start with the simplest design that meets every requirement. Add complexity only when the requirements or numbers demand it.
  2. Walk a request through it. Trace one real request, step by step. If some requirement has no path through your boxes, something's missing.

the URL shortener's first floor plan, with one redirect traced through it.

Figure: the URL shortener's first floor plan, with one redirect traced step by step. Clicks take the green path. The database is touched only on a miss.

Walking a redirect through it:

  1. The user clicks sho.rt/aB3x9Q.
  2. The load balancer sends the request to one of many identical app servers (Chapter 7).
  3. The app server checks the cache for aB3x9Q (Chapter 12).
  4. On a miss, it reads the database and puts a copy in the cache.
  5. It replies with a redirect to the long URL.

Creating a link takes a different path: the app server gets a new unique code from the ID maker (Chapter 10), saves it in the database, and returns the short URL.

Memory code: "Draw it simple, walk it through." The simplest plan that works, then trace a real request across it.