Skip to content
BytePatterns

Design Ride Matching

System Design Cases: lesson 9 of 20

The write rate is the problem; the search is one cell lookup.

Lesson 9 of 20 · 7 min

Design Ride Matching

Step 1 of 11

Fifty thousand drivers pinging every four seconds is 12 500 writes a second.

The Idea

Find a nearby driver within seconds, from a map where every position is stale after four. Assume 50 000 active drivers in one city, each pinging its location every four seconds — 12 500 writes a second against a far smaller number of ride requests.

Real-World Example

A taxi rank organised by street. The dispatcher never scans the whole city: they look at the blocks around you, then at the ring of blocks beyond, and stop as soon as somebody is free.

The Tradeoff

Indexing positions by grid cell turns "who is near me" into a handful of lookups and makes the cell boundary a lie, so the neighbours must be read too. Keeping those positions in memory is what survives the write rate; the durable record only appears once a trip is accepted.

Your turn

Put the steps in the right order.

  1. Offer the ride to the best candidate and hold it until they answer
  2. Write each driver's ping into its grid cell in memory
  3. Read the rider's cell and its eight neighbours
  4. Rank the candidates by road ETA, not straight-line distance

Mini quiz

1 / 3

The eight neighbouring cells are read as well because:

New lessons land every few weeks

Leave an address and we will tell you when the next one is up. That is the only reason we will use it.

One address, stored so we can email you. Nothing else, ever.