HACKER Q&A
📣 sijirama

Best geospatial indexing approach for real-time location systems in Go?


I'm building a real-time location-based notification system in Go where users need to receive updates relevant to their geographic position. I initially implemented this using Uber's H3 library with a room-based subscription model in Socket.IO, but I'm hitting some limitations. The main issue: When a user joins at one resolution (e.g., 8) and an event is created at another resolution (e.g., 9), the user may miss relevant updates due to the mismatch in H3's cell hierarchy. I've tried various solutions involving emitting to parent/child cells, but the code has become overly complex. I need a geospatial approach that:

Works efficiently in Go Handles thousands of concurrent users Delivers updates within 1-2 seconds Doesn't suffer from the hierarchical complexity issues I'm facing with H3

I'm considering:

Moving away from room-based subscriptions to direct geographic queries Using a different geospatial library (Redis GEO, S2, GeoHash) Rethinking how I use H3

Has anyone solved similar problems with real-time location-based systems? What approaches worked best in production?


  👤 timita Accepted Answer ✓
A binning method that is fast and does not suffer from the hierarchical issue you mention: quadtiles.

Looks like there is an implementation in Go [0]. I haven't tried the kind of geofencing you mention in memory, but I've had success with PostGIS.

[0] https://github.com/volkerp/goquadtree

Edit: that repo seems to be very old. Quadtiles have been implemented successfully in a variety of languages, you should be able to find something more suitable.