Systems
Proximity Service
Functional requirements
- return all businesses based on a user’s location (latitude, longitude pair) and radius
- business owners can add, delete or update a business, but this information doesn’t need to be reflected in real-time
- customers can view detailed information about a business
Non-functional requirements
- low latency
- data privacy
- 5000 search QPS
- high availibility and scalability requirements
API design
|
|
Data Model
- read/write ratio
- data schema
Algorithms to fetch nearby business
- Geohash in redis
- Postgresql with PostGIS extension
- old school SQL query
several options
- two-dimensional search
- evenly divided grid
- geohash
- Geohash algorithms work by recursively dividing the world into smaller and smaller grids with each additional bit.
- boundary issues
- geohashing guarantees that the longer a shared prefix is between two geohashes, the closer they are. However, the reverse is not true.
- two positions can have a long shared prefix, but they belong to different geohashes
- quadtree
- a quadtree is a data structure that is commonly used to partition a two-dimensional space by recursively subdividing it into four quadrants until the contents of the grids meet certain criteria.
- Google S2
|
|