← Lessons

quiz vs the machine

Platinum1810

System Design

The Ride Sharing Design

Matching riders to nearby drivers using geospatial indexing and live location.

5 min read · advanced · beat Platinum to climb

The core loop

A ride sharing service matches a rider requesting a trip to a nearby available driver, then tracks the trip in real time. The hard parts are finding nearby drivers fast and handling a constant stream of location updates.

Finding nearby drivers

  • Driver locations change constantly, so the system needs a geospatial index to answer who is near this point.
  • A common approach divides the map into cells, using a grid or a scheme like geohash, so a nearby query checks only the rider cell and its neighbors.
  • This turns a search over millions of drivers into a lookup of a few cells.

Live location

  • Drivers send frequent location pings, a high write rate the system must absorb.
  • Locations live in a fast store optimized for many small updates and proximity reads.
  • The rider sees the matched driver move in near real time over a push connection.

Matching

  • When a rider requests, the service finds candidate drivers nearby, ranks them by distance and other factors, and offers the trip.
  • The match must be consistent so two riders are not assigned the same driver.

Key idea

A ride sharing service matches riders to nearby drivers using a geospatial index over map cells, absorbs a heavy stream of driver location pings, and assigns trips consistently in real time.

Check yourself

Answer to earn rating on the learn ladder.

1. Why divide the map into cells for driver search?

2. What load do frequent driver location pings create?

3. Why must matching be consistent?