πŸ’¬
βœ‰οΈ
πŸ“Έ
▢️

Loading…

Design Uber: location, matching, and trip service

UberGuided Mode

Step 2 β€” WebSocket Gateway

Request Flow

1

Persistent connection

Driver app opens one WebSocket connection on launch. GPS pings stream over this connection every 4 seconds β€” eliminating the TLS handshake overhead of repeated HTTP requests. 1M drivers Γ— 1 connection each.

2

4x less load

Batching to every 4 s (instead of 1 s) cuts the write rate from 1M writes/second to 250K writes/second β€” same accuracy for matching (a car at 60 km/h moves 67m in 4 s, acceptable for dispatch).

3

Push dispatch

When a driver is matched, the WebSocket gateway pushes the dispatch notification server-to-driver in <100ms β€” no polling loop. Rider gets real-time driver position updates the same way.

Why We Need This

250K GPS messages/second over HTTP requires 250K new connections/second β€” each with TCP handshake + TLS negotiation. WebSocket keeps connections alive, reducing connection overhead by 100x.

Key Insight

WebSocket is the right protocol for high-frequency bidirectional data. At 250K GPS messages/second, connection overhead of HTTP would exceed the data transfer itself.

Step 2 of 8