Wrap Up
In this chapter, we have presented the design for proximity service. The system is a typical LBS that leverages geospatial indexing. We discussed several indexing options:
-
Two-dimensional search
-
Evenly divided grid
-
Geohash
-
Quadtree
-
Google S2
Geohash, quadtree, and S2 are widely used by different tech companies. We choose geohash as an example to show how a geospatial index works.
In the deep dive, we discussed why caching is effective in reducing the latency, what should be cached and how to use cache to retrieve nearby businesses fast. We also discussed how to scale the database with replication and sharding.
We then looked at deploying LBS in different regions and availability zones to improve availability, to make users physically closer to the servers, and to comply better with local privacy laws.
Congratulations on getting this far! Now give yourself a pat on the back. Good job!
Chapter Summary
Reference Materials
- Yelp: https://www.yelp.com/
- Map tiles by Stamen Design: http://maps.stamen.com/
- OpenStreetMap: https://www.openstreetmap.org
- GDPR: https://en.wikipedia.org/wiki/General_Data_Protection_Regulation
- CCPA: https://en.wikipedia.org/wiki/California_Consumer_Privacy_Act
- Pagination in the REST API: https://developer.atlassian.com/server/confluence/pagination-in-the-rest-api/
- Google places API: https://developers.google.com/maps/documentation/places/web-service/search
- Yelp reservation API: https://docs.developer.yelp.com/docs/reservation
- Regions and Zones: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html
- Redis GEOHASH: https://redis.io/commands/GEOHASH
- POSTGIS: https://postgis.net/
- Cartesian tiers: http://www.nsshutdown.com/projects/lucene/whitepaper/locallucene_v2.html
- R-tree: https://en.wikipedia.org/wiki/R-tree
- Global map in a Geographic Coordinate Reference System: https://bit.ly/3DsjAwg
- Base32: https://en.wikipedia.org/wiki/Base32
- Geohash grid aggregation: https://bit.ly/3kKl4e6
- Geohash: https://www.movable-type.co.uk/scripts/geohash.html
- Quadtree: https://en.wikipedia.org/wiki/Quadtree
- How many leaves has a quadtree: https://stackoverflow.com/questions/35976444/how-many-leaves-has-a-quadtree
- Blue green deployment: https://martinfowler.com/bliki/BlueGreenDeployment.html
- Yext: Maps and Location Support: https://www.yext.com/platform/features/maps-and-location-support
- S2: http://s2geometry.io/
- Hilbert curve: https://en.wikipedia.org/wiki/Hilbert_curve
- Hilbert mapping: http://bit-player.org/extras/hilbert/hilbert-mapping.html
- Geo-fence: https://en.wikipedia.org/wiki/Geo-fence
- Region cover: http://s2geometry.io/devguide/s2cell_hierarchy
- Bing map: https://bit.ly/30ytSfG
- MongoDB: https://docs.mongodb.com/manual/tutorial/build-a-2d-index/
- Geospatial Indexing: The 10 Million QPS Redis Architecture Powering Lyft: https://www.youtube.com/watch?v=cSFWlF96Sds&t=2155s
- Geo Shape Type: https://www.elastic.co/guide/en/elasticsearch/reference/1.6/mapping-geo-shape-type.html
- Geosharded Recommendations Part 1: Sharding Approach: https://medium.com/tinder-engineering/geosharded-recommendations-part-1-sharding-approach-d5d54e0ec77a
- Get the last known location: https://developer.android.com/training/location/retrieve-current#Challenges
Finished reading?
Mark it complete to track your progress.