How do you design “Find Nearby Rides” in Uber?
.
The figure shows a simple breakdown of how Redis can be used for this:
Geohash: A 52-bit integer created by interleaving the bits of latitude and longitude coordinates.
Sorted Sets: Redis stores driver IDs with geohashes as scores, enabling efficient location-based sorting.
Driver Location Update:
Redis command GEOADD drivers:current_location updates driver locations using latitude, longitude, and driver ID.
GEOADD drivers:current_location
Geohashes are stored in a sorted set for quick lookup.
Ride Request:
GEOSEARCH queries Redis for nearby drivers within a given radius from the user’s location.
GEOSEARCH
Redis returns driver IDs and additional info like availability or ETA from other data stores.
——
Read complete deep dive on “How to use Redis in system design interviews“ at read.systemdesignbluepr… to learn about more use cases of Redis.