How to run a ride-sharing design in a 45-minute interview: geospatial cells, a million location updates per second, atomic driver claims, matching and surge pricing.
Published September 21, 2026
This lesson is the interview version: how to structure the answer and which deep dives to expect. The full reference design is the case study Design Uber / Ride Sharing in this chapter.
A ride-sharing platform connects two moving populations, riders and drivers, in real time. Its hardest parts aren't the usual CRUD. They are tracking millions of moving points, finding the nearest available drivers in milliseconds, and making sure one driver is never assigned to two riders.
The key observation to state: location data is huge, hot, and short-lived. You only care where a driver is now, so it doesn't belong in the durable trips database.
Driver app β location every ~4s ββΆ Location service ββΆ In-memory geo index (by cell)
β β²
βββΆ stream (Kafka) ββΆ trip tracking, analytics, ETA models
Rider app β request ride ββΆ Trip service ββΆ Matching service β query nearby ββ
β β
β βββΆ offer to driver (push / persistent connection)
βΌ
Trips DB (durable: trips, fares, states)
REQUESTED β MATCHED β DRIVER_ARRIVING β IN_PROGRESS β COMPLETED / CANCELLED).Scanning every driver per request is impossible. You need to partition the map into cells:
cellId β set of available driverIds, sharded by cell across location servers. Redis's GEOADD/GEOSEARCH is a reasonable single-cluster answer at moderate scale.When a driver moves across a boundary, remove them from the old cell and add them to the new one. Since only the latest position matters, updates overwrite rather than append.
A million updates per second is fine because they're small, overwrite-only and in memory. Shard location servers by region/cell. Apps can send updates less often when the driver is idle or stationary. The raw stream also goes to Kafka for trip replay, analytics and ETA models, off the hot path.
Two matching requests may pick the same nearest driver at the same moment. Each match must atomically claim the driver:
SET ... NX with a TTL in Redis).Offer to the best candidate. If there's no response or a decline, move to the next. For busy areas you could offer to a few at once, where the first to accept wins via the same atomic claim. Drivers hold a persistent connection, so offers arrive instantly. Push notifications are the fallback.
Per cell, compare demand (open requests) with supply (available drivers) over a short window, and set a multiplier from that ratio, smoothed so it doesn't flicker. The multiplier is quoted and locked when the rider confirms, so the price doesn't change mid-request.
Q: Why not use PostGIS for nearby-driver queries? A: A spatial index (PostGIS with GiST) handles proximity queries well at moderate scale, and is a fine answer for a smaller service. At a million position updates per second, the problem is the write rate: constantly updating indexed rows is expensive and hurts the database used for durable data. An in-memory, overwrite-only cell index is built for exactly this pattern.
Q: How do you compute ETA? A: Straight-line distance is only a rough filter. Real ETA needs routing on the road graph with current traffic. That's done by a routing service (graph algorithms with precomputed shortcuts, like contraction hierarchies), plus models trained on historical trip times. Matching typically shortlists candidates by distance, then ranks the shortlist by ETA.
Q: What happens if the rider's phone loses connection after the match? A: The trip lives on the server, not in the app, so the match stands. The driver still gets the pickup location, and when the rider reconnects the app fetches the current trip state. Timeouts in the state machine (for example the driver waiting at pickup for N minutes) resolve abandoned trips.
Q: How would you shard the trips database? A: By trip ID for writes and by rider/driver ID for history queries, often with a separate read store for each access pattern. Active trips are a small, hot set and can be held in a fast store. Completed trips move to cheaper storage for history and analytics.