Featured article for the topic Design Uber · picked by the needcode team
Design Uber: geohashes, matching and surge pricing
Riya MenonFeatured AuthorPosted · 1 min read
Uber's core loop is simple to say and hard to build: find the nearest available drivers to a rider, fast, while millions of drivers move every few seconds.
Location updates#
Drivers send their position every 4 seconds. That is a write-heavy stream, so keep it in memory: a geospatial index keyed by geohash cell, updated in place.
Finding nearby drivers#
A geohash turns a latitude and longitude into a string where shared prefixes mean nearby cells. To find drivers near a rider, look up the rider's cell and its eight neighbours.
flowchart LR
Rider --> M[Matching service]
M --> G[(Geo index by cell)]
M --> D[Dispatch]
D --> DriverSurge pricing#
Surge is a ratio of open requests to available drivers per cell, smoothed over a few minutes so prices don't flicker.
Comments