Yelp - Design Consideration - storage calculation


Can you please elaborate the calculation here?

Course: Grokking Modern System Design Interview for Engineers & Managers - Learn Interactively
Lesson: Design Considerations of Yelp - Grokking Modern System Design Interview for Engineers & Managers

You are storing SegmentID → {List of places in that Segment}
This is done with the formula:
Total Size = Number of segments x (Segment ID size in Bytes + no. of Places per segment * Place ID in Bytes)

  • There exist 60 M miles sq radius in earth. If each segment is 10 mile Sq radius → you have 6 M segments
  • you have 500M places. Consider uniform distribution of places per segment. Then number of places per segment = 500M/6M = 83.33 Places per segment ID
  • 1 segment ID will have 83.33 places
  • Total size of one record = 8Bytes for SegmentID + 8Byte * 83.333 places = 674.67 bytes
  • For 6 M segments: 6 Million * 674.67 bytes = 4.048 GB

Note: The text incorrectly says TB but it should be GB.

Hi Mansoor.

We are glad you reached out to us. The calculation performed here approximates our storage need to design Yelp.

Total_Area_of_Earth = 60M sq miles.
Search_Radius = 10 miles.
Num_of_Segments => 60/10 = 6M.

We assume 500M places (Num_of_Places) will be in the Total_Area_of_Earth.
We are assuming each Segment_ID and Place_ID to take 8 bytes.

Total_Space = (Number_of_Segments * Segment_ID_size) + (Num_of_Places * Place_ID_size) = (6M * 8) + (500M * 8)
= 48000000 + 4000000000 => 4048 MB or 4.048 GB

We are also adding these detailed calculations to the lesson in the next update.
I hope that clears up the confusion. If you have any other questions, feel free to reach out to us.

Thank you.

@micro_service_3699 Thank you for the detailed response.