HeadlinesBriefing favicon HeadlinesBriefing.com

Uber's Real-Time Agent Matching with Redis

DEV Community •
×

Uber, Swiggy, and Zomato solve a critical coordination problem: matching thousands of moving delivery agents to orders in under 100 milliseconds. Their architecture uses Redis for its in-memory speed, separating location data, availability state, and assignment locks into distinct data structures. This avoids the heavy write amplification and latency of search engines like Elasticsearch for this specific task.

The system processes agent location updates every 2-5 seconds. It uses spatial segmentation with geohash cells to prevent hot keys and scale horizontally. The matching flow first finds nearby agents via a geo index, intersects that with an availability set, and then attempts a sequential assignment using atomic locks. This minimizes agent spam and improves acceptance rates.

Key tradeoffs favor speed over durability, relying on Redis TTLs for failure recovery. Availability changes are cheap set operations, unlike constantly reindexing a geo key. The core principle is composing specialized data structures—geo for 'where,' sets for 'who,' and locks for 'who wins'—instead of overloading a single tool. This architecture is fundamental to the gig economy's real-time logistics.