Design Uber: location, matching, and trip service
Uber
Guided ModeStep 6 β Event Queue
Request Flow
Publish MatchConfirmed
When a match is confirmed, the Matching Service publishes one event to the Queue: { event: 'MatchConfirmed', trip_id, driver_id, rider_id, ts }. Takes <5ms. Matching is done.
Fan-out to consumers
Trip Service creates the trip record. Billing pre-authorises payment. Push Service sends 'Driver on the way!'. All three consume the same event from the Queue in parallel β without any of them calling each other.
Resilience
If Trip Service restarts, messages queue up and replay when it recovers. The Matching Service is completely unaffected β it already returned a response to the rider before the queue was even consumed.
Why We Need This
Without the queue, Matching Service calls Trip Service, Billing, and Push synchronously. A slow billing pre-auth (500ms) blocks the rider from seeing 'Driver matched'. The queue makes all downstream processing async, cutting rider-visible latency by 3x.
Key Insight
The queue is an availability boundary. Downstream consumers can fail, restart, and replay β none of it affects match dispatch latency. This is the core value of event-driven design.
Step 6 of 8
