Crushing Tech Education

Crushing Tech Education

Share this post

Crushing Tech Education
Crushing Tech Education
Design Yelp | Proximity Service | QuadTree | GeoHash
Copy link
Facebook
Email
Notes
More
User's avatar
Discover more from Crushing Tech Education
Join a community of engineers and technical managers dedicated to learning System Design.
Over 3,000 subscribers
Already have an account? Sign in
System Design

Design Yelp | Proximity Service | QuadTree | GeoHash

How to design a Yelp using multiple implementations of Proximity Service

SWE's avatar
SWE
Jun 10, 2023

Share this post

Crushing Tech Education
Crushing Tech Education
Design Yelp | Proximity Service | QuadTree | GeoHash
Copy link
Facebook
Email
Notes
More
Share

Designing a proximity server with a Quadtree Or GeoHash data structures can efficiently handle proximity queries and represent a world map as a data structure. Here's a system design for a proximity server using Quadtree:

  1. Data Storage: We store the location data of objects/entities that need to be tracked or queried for proximity. We use a sharded database store the coordinates and metadata of objects/entities.

  2. Quadtree Generation: First, we generate a Quadtree structure based on the spatial extent of the objects/entities. Then we break down the area of interest into smaller quadrants recursively, forming a hierarchical tree structure. Each node in the Quadtree represents a quadrant and contains objects/entities falling within that quadrant.

  3. Quadtree Construction and Indexing: We construct the Quadtree by inserting objects/entities into the appropriate quadrants based on their coordinates. Assign a maximum capacity to each quadrant to control the depth and size of the tree. And implement indexing mechanisms to efficiently retrieve objects/entities within a given quadrant.

  4. Proximity Queries: When we receive a proximity query, we traverse the Quadtree to identify the specific quadrants relevant to the query. We calculate the distance between the query location and the boundaries of each relevant quadrant and determine if the distance falls within the desired proximity range.

  5. Distance Calculation: For the objects/entities identified in the relevant quadrants, calculate the actual proximity or distance between the queried location and each object/entity. We use appropriate distance calculation algorithms, such as Haversine formula or Vincenty's formula, depending on the accuracy requirements.

  6. Caching: We implement caching mechanisms to improve the performance of frequently queried or computed results. Cache the results of proximity queries and computed distances to reduce the load on the database and improve response times.

Here's a more detailed explanation in the video 👇‍

Thank you for reading this edition of the newsletter!

Thanks for reading Crushing Tech Interview! Subscribe for free to receive new posts and support my work.

Share this post

Crushing Tech Education
Crushing Tech Education
Design Yelp | Proximity Service | QuadTree | GeoHash
Copy link
Facebook
Email
Notes
More
Share

Discussion about this post

User's avatar
Starting an Architecture Review Team
How to start, manage, and deliver!
Feb 25, 2024 • 
SWE
 and 
Fran Soto
13

Share this post

Crushing Tech Education
Crushing Tech Education
Starting an Architecture Review Team
Copy link
Facebook
Email
Notes
More
3
Design a Coding Contest Platform like Leetcode
Remote code execution engine and database design.
Feb 3, 2024 • 
SWE
12

Share this post

Crushing Tech Education
Crushing Tech Education
Design a Coding Contest Platform like Leetcode
Copy link
Facebook
Email
Notes
More
6
Design Stock Exchange | HLD | Data Model | Reliability
Design a stock exchange, process buy and sell orders efficiently in memory
Jan 6, 2024
2

Share this post

Crushing Tech Education
Crushing Tech Education
Design Stock Exchange | HLD | Data Model | Reliability
Copy link
Facebook
Email
Notes
More

Ready for more?

© 2025 Crushing Tech Education
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share

Copy link
Facebook
Email
Notes
More

Create your profile

User's avatar

Only paid subscribers can comment on this post

Already a paid subscriber? Sign in

Check your email

For your security, we need to re-authenticate you.

Click the link we sent to , or click here to sign in.