Ride Matching
Drivers and riders.
Now let's design the core of a ride sharing app. Drivers send their location every few seconds. Riders request a ride, and must be matched with a nearby, free driver, quickly and fairly.

- Drivers send locations
- Riders request rides
- Match quickly
Location update load
First, estimates. Half a million drivers online, each sending a location every four seconds. Run it. That's a hundred and twenty five thousand writes per second, all the time. These locations change constantly, and old ones don't matter. So they belong in memory, in something like Redis, not in a traditional database.
drivers_online = 500_000
every_seconds = 4
writes = drivers_online / every_seconds
print(f"location writes/sec: {writes:,.0f}")location writes/sec: 125,000
Matching a ride
Here's the matching flow. The rider requests a ride. The matching service finds free drivers in nearby geohash cells. It ranks them by distance and arrival time. It offers the ride to the best driver, who has a few seconds to accept. If they decline or time out, it goes to the next driver.
- Ride request
- Nearby free drivers
- Rank by ETA
- Offer to best
- Next if declined

Summary
Ride matching keeps driver locations in memory, finds candidates with geohashes, ranks them, and offers rides one driver at a time. Next, search autocomplete.
Key takeaways- ~125k location writes/sec
- Locations in memory
- Rank, offer, fall back