Yelp or Nearby Friends
Proximity server
Requirements and Goals of the System
Functional Requirements:
Users should be able to add/delete/update Places.
Given their location (longitude/latitude), users should be able to find all nearby places within a given radius.
Users should be able to add feedback/review about a place. The feedback can have pictures, text, and a rating.
Non-functional Requirements:
Users should have a real-time search experience with minimum latency.
Our service should support a heavy search load. There will be a lot of search requests compared to adding a new place.
Scale Estimation
500M daily user * 2 times per day * 5 queries per time / 86400 seconds ~ 50k QPS
Peak hour: * 2 ~ 100k QPS
Assuming 500M places
Database Schema
Each location:
LocationID (8 bytes): Uniquely identifies a location.
Name (256 bytes)
Latitude (8 bytes)
Longitude (8 bytes)
Description (512 bytes)
Category (1 byte): E.g., coffee shop, restaurant, theater, etc.
Total size: 8 + 256 + 8 + 8 + 512 + 1 => 793 bytes
reviews, photos, and ratings of a Place
LocationID (8 bytes)
ReviewID (4 bytes): Uniquely identifies a review, assuming any location will not have more than 2^32 reviews.
ReviewText (512 bytes)
Rating (1 byte): how many stars a place gets out of ten.
System APIs
API for searching
Basic System Design and Algorithm
Two different use case:
Location of a place doesn’t change that often, we don’t need to worry about frequent updates of the data.
Objects do change their location frequently, e.g., people or taxis
Last updated