// Heavy Systems + Your Rehearsal

The rehearsal: design it from scratch

System Design track · 20 min

By the end of this lesson you can
  • Run the four steps (requirements, estimate, sketch, deep dive) on a problem you have never seen.
  • Let the numbers pick the architecture, and point to the earlier lesson behind each box.
  • Recall the defaults of the whole track in one minute.

The whiteboard is blank again. But this time, nothing you draw will be new. You have drawn every box before, piece by piece, across five modules.

The prompt is fresh: design the backend of a ride-hailing app, like Uber or Careem. The moves are not. Let's run the whole playbook from scratch and watch it hold.

Step 1: requirements
  1. What it does: a rider requests a trip, the system matches a nearby driver, both see live location and an arrival time (ETA), and a price is shown up front and charged at the end.
  2. Cut the scope hard: no shared rides, no booking ahead, no surge-pricing details, no payment reconciliation. One core loop done well beats ten features sketched badly.
  3. How well it must work: a match within a few seconds, locations that feel live, and no lost trips, because money and people's safety are involved.
Step 2: the quick math

Trips: 1 million a day ÷ 86,400 seconds ≈ 12 trip events per second on average. At an evening peak ten times higher, about 120 per second. One solid database handles that easily.

Locations are the monster. 500,000 active drivers, each sending their position every 4 seconds: 500,000 ÷ 4 = 125,000 writes per second, all day long. Riders watch those positions too, so reads reach hundreds of thousands per second.

Storage is small by comparison: 100 bytes × 125,000 per second × 86,400 seconds ≈ 1 TB a day, and most of it is useless within minutes. Conclusion: location data must never touch the main database.

The idea

Notice what just happened: you did not choose the architecture. The arithmetic did. 12 trips per second says a plain relational database with replicas. 125,000 location writes per second says a fast in-memory store, aware of geography, where each entry expires after a few seconds.

This is the lesson of back-of-the-envelope estimation, coming back at the end of the track: estimation is part of the design, not a warm-up before it.

Step 3: the sketch, and where each box comes from
  1. Rider and driver apps talk to an API layer behind a load balancer, with a rate limiter at the gateway. (Module 1: one server to millions; module 3: rate limiter.)
  2. A location service takes in driver pings, keeps them in a geo index in memory, and answers “who is near this point?”. Entries expire after a few seconds. (Module 3: key-value store.)
  3. A matching service takes a request, asks the geo index, and offers the trip to drivers one by one.
  4. A trip service owns trips in a relational database (requested, ongoing, completed), sharded by city if it grows, with IDs from a snowflake-style generator. (Module 1: data at scale; module 2: unique IDs.)
  5. When a trip ends, payment and the receipt go through a queue, and live positions flow to both apps over WebSocket. (Module 4: notification system and chat system.)
Step 4: the deep dive, matching is a geography problem

The hardest question hides inside matching: find available drivers within 2 km, fast. The naive way measures the distance to all 500,000 drivers on every request. That is dead on arrival.

A geohash turns a coordinate into a short string where nearby points share the same beginning. So “drivers near me” becomes a prefix lookup, plus the 8 neighbouring cells so you do not miss a driver just across a cell edge. Yes, prefixes again, like the trie in autocomplete.

A quadtree uses the same idea on the map itself: keep splitting the map into four squares, keep drivers in the smallest squares, and search only the branches near you. Both turn “check everyone” into “check the neighbourhood”.

Name the tool, then spend time on the trade-off

In the interview, you do not build a geohash library. You say: PostGIS if this lives in the relational database, Redis GEO if it lives in memory, S2 if the team already uses it. Then you spend your minutes on the questions that matter: how fresh does “nearby” need to be, and what happens when the matched driver never answers?

Knowing that the tool exists, and what it costs, is what a senior engineer brings.

Where this design breaks

Walk the failure paths before the interviewer does. A driver accepts but the app crashes: give each offer a short timeout, then move to the next driver. A payment retry runs twice: put an idempotency key on the charge, exactly like the notification lesson. A big concert ends and 30,000 people request rides from one square kilometre: that cell becomes a hot spot, so split busy cells smaller, the same fix as a hot key in the caching lesson.

None of these answers is new. That is the point.

Test yourself

One question for the whole track: you have 45 minutes and a blank board. What do you do, and which defaults must already be in your head?

Answer in your head first, then check.

Takeaway

Five modules, one path. The foundations showed you why systems bend under load. The playbook gave you four steps and two core tools, consistent hashing and unique IDs. The distributed data module took you inside quorums, rate limiting and crawlers. Product-scale systems showed fanout and queues at work. And the heavy lifting, plus this rehearsal, proved that the moves carry over to a problem you have never seen. The whiteboard was never the subject. Your judgment was.

Do it this week

Pick a real system at work: an internal tool, a data pipeline, or a feature you ship every sprint. Write a one-page design doc with the four steps: requirements in three bullets, estimates with real numbers from your logs, a box sketch, and one deep dive into the part that genuinely worries you. Share it with one colleague and argue about it. That argument is the course, continuing.

What you can do now
  • Run the four steps (requirements, estimate, sketch, deep dive) on a problem you have never seen.
  • Let the numbers pick the architecture, and point to the earlier lesson behind each box.
  • Recall the defaults of the whole track in one minute.

Heavy Systems + Your Rehearsal