How do apps like AirDrop, Nearby Share, Uber, etc. efficiently find nearby users?
Hey everyone,
I'm building a proximity-based payments app where users can discover other users nearby in real time.
My current approach is pretty straightforward:
- Users periodically send their GPS coordinates over Socket.IO.
- The backend keeps track of online users.
- Whenever someone updates their location, I calculate the distance to every other online user and return only the nearby ones.
I was planning to use the Haversine formula, but I recently came across Vincenty's formula and started wondering if that's the right approach.
My main questions are:
- Is Haversine sufficient for a 50–100m radius?
- At what scale does comparing every user become a bottleneck?
- Do production apps use geohashes/spatial indexing first and then calculate distances?
I'm trying to keep the MVP simple while avoiding a design that won't scale. I'd love to hear how you'd approach this or how similar systems are built in production.