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.