Chapter 51
Know the Tricks, Part 2
5. Ride-Sharing / Location Services (Uber, Lyft, Bolt)
The Trick: Geohashing with In-Memory Geospatial Index
Don't store driver locations in a regular database and query with distance calculations. Instead, use Redis with geospatial commands (GEOADD, GEOSEARCH). Driver locations are encoded as geohashes — nearby locations share a common prefix, making proximity queries blazing fast.
Why this matters: A PostgreSQL query scanning 2 million drivers for proximity is hopeless. Redis geospatial does it in milliseconds.
