Proximity Server/Yelp - System Design
First created 2021年01月17日
A system with Read heavy/Write little
placeId 8 bytes
name 256 bytes
latitude 4 bytes
longtitude 4 bytes
category 1 byte
description 512 bytes
Functions
Function1(Core): Given a location, a user can search all the nearby places within a give radius.
Function2: A user can add his/her favourite places.
Function3: A user can post feedback/review to a place: rating(required) + text/pictures(optional).
Function1(Core): GET /search
parameters: keyword, radius, category(optional), max_return(optional), (optional)sortOrder, (optional)filter, (optional development)next_token
return: A JSON containing information about a list of popular places matching the search query. Each result entry will have the place name, address, category, rating, and image. (Copied from reference link)
Function2: POST/add DELETE/remove (to/from favorite list)
parameters: placeId
Function3: POST/add
parameters: placeId, rating, review text(optional), photo_urls(optional)
Schema
Business Profile DB
placeId (Primary Key) | placeName | Address | Category | Description | [ReviewInfo(ReviewText, [mediaId1,2,3,...])]
Business Media DB
mediaId (Primary Key) | placeId | mediaURL | userId
Review DB
reviewId (Primary Key) | placeId | text | userId
Partition
1. By region or zipcode
This could cause the issue of hot places. To avoid one of the server in the cluster receive too many requests.
2. By locationId
This could make a request querying too many shard servers. May not be efficient.
3. By Geohash/Google S2
To avoid the issue of hot shard, try to make that cells are continuous in one shard and adjust the number of cells in one shard by the number of places.
Cache
in memory service
Between client and application servers
Between application servers and backend servers
Load Balance
Round Robin (distributed equally)
More intelligent: also take traffic/load/server status as consideration by periodically querying backend server then adjusting their weights
CDN(Other)
Reference
[1] https://medium.com/swlh/design-a-proximity-server-like-nearby-or-yelp-part-1-c8fe2951c534
[2] https://codeburst.io/design-a-proximity-server-like-yelp-part-2-d430879203a5
[3] https://www.educative.io/courses/grokking-the-system-design-interview/B8rpM8E16LQ

浙公网安备 33010602011771号