Design Location Based App

  • Yelp or Nearby Friends

  • Proximity server

Requirements and Goals of the System

Functional Requirements:

  1. Users should be able to add/delete/update Places.

  2. Given their location (longitude/latitude), users should be able to find all nearby places within a given radius.

  3. Users should be able to add feedback/review about a place. The feedback can have pictures, text, and a rating.

Non-functional Requirements:

  1. Users should have a real-time search experience with minimum latency.

  2. 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:

  1. LocationID (8 bytes): Uniquely identifies a location.

  2. Name (256 bytes)

  3. Latitude (8 bytes)

  4. Longitude (8 bytes)

  5. Description (512 bytes)

  6. 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

  1. LocationID (8 bytes)

  2. ReviewID (4 bytes): Uniquely identifies a review, assuming any location will not have more than 2^32 reviews.

  3. ReviewText (512 bytes)

  4. Rating (1 byte): how many stars a place gets out of ten.

System APIs

API for searching

search(api_dev_key, search_terms, user_location, radius_filter, maximum_results_to_return, 
    category_filter, sort, page_token)

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