Location & mobility · Advanced
Ride hailing
Uber-style matching over an in-memory hexagon index of drivers, with surge pricing from the location stream.
Every part, and why it is there
Rider app
A rider asks for a car and wants a driver within seconds. Requests are rare compared with the constant chatter of driver locations.
Driver app
Every online driver sends a GPS fix every few seconds. With a million drivers that is hundreds of thousands of writes per second, the biggest load in the system.
API gateway
Authenticates riders and drivers and routes trip calls to the trip service and driver sessions to the connection gateway.
Trip service
Owns the trip lifecycle: requested, accepted, en route, completed. It quotes the fare using the current surge multiplier and asks dispatch for a driver.
Dispatch / matching
Finds available drivers in the hexagons around the pickup, ranks them by ETA, and offers the trip to the best one. It locks that driver while the offer is pending so two riders cannot get the same car.
ETA service
Straight-line distance lies (rivers, one-way streets), so candidates are ranked by real road travel time from a routing engine.
Driver connection gateway
Holds a persistent connection to every driver app. PUT /drivers/:id/location receives pings every few seconds, and it pushes trip offers back down the same connection instantly.
Driver geo index (H3 cells)
Driver positions keyed by hexagon cell, in memory, overwritten on every ping. A database would struggle with the write rate and nobody needs yesterday’s position here.
Location stream
Every ping is also published here, so analytics, surge and trip tracking can consume locations without adding load to dispatch.
Surge pricing
Counts open requests and free drivers per hexagon every minute and raises prices where demand outruns supply, which pulls drivers toward busy areas.
Surge multipliers
The latest multiplier per hexagon, read by the trip service when it quotes a fare. A small, hot key-value lookup.
Trips DB
Durable record of every trip, fare and state change. Written a few times per trip, unlike locations which change every few seconds.
Asked in interviews at
- amazon
- meta
- salesforce
- visa
Concepts used here
- Geohash: Build a short code like xn76fg for any spot on Earth, so “ramen near me” becomes “codes that start with xn76fg”, one read on an ordinary database index.
Learn more
- Design Uber w/ a Ex-Meta Staff Engineer: System Design Interview breakdown (Hello Interview)
- H3: Tiling the Earth with Hexagons (Uber Engineering)
- Uber Tech Day: What's My ETA? The Billion Dollar Question (Uber Engineering)
- H3: Uber's hexagonal hierarchical spatial index (Uber Engineering)
- Design Uber (Hello Interview)
- DeepETA: how Uber predicts arrival times using deep learning (Uber Engineering)