Ride-hailing dispatch
Real-time rider–driver matching: GPS pings stream through competing consumers into a geospatial index, presence tracks who's really online, and surge pricing closes the loop.
What this design does
Matching a rider to a driver is a freshness problem: the answer is only right if the geo index knows where every driver was two seconds ago. Here GPS pings flow through a stream consumed by competing workers into an H3-cell index, presence separates 'connected' from 'actually available', and a surge calculator watches the same stream to price supply against demand. The match itself is then a cheap k-nearest lookup — all the hard work happened before the request arrived.
The patterns it composes
- Competing consumers — location workers scale horizontally; each ping is processed once
- Geospatial index (H3 cells) — k-nearest drivers is a cell lookup, not a table scan
- Presence — heartbeats distinguish online, on-trip and gone-dark drivers
- WebSocket gateway — offers reach drivers in milliseconds over held connections
- Streaming windows (surge) — demand/supply ratios per cell, computed continuously
Import it, attach your own numbers, and verify the design against failures — or read the engineering notes.