1 Proximity Service
1) requirements
Functional Requirements | Non-Functional Requirements | |
1 |
Return all businesses based on user's location (latitute and longitute pair) and radius (5km) |
Low latency.
|
2 |
Business owners can use Restful API to deal with a business.
|
Data privacy
|
3 | Custerms can view business detail |
High availability and scalibility requirements.
|
2) Basic Culculatiion
QPS |
Seconds in a day = 24 * 60 * 60 = 86400, round it up for 10**5. Users: 100 million Searches: 5 times. QPS: 100m * 5 / 10**5 = 5000 |
5000 |
Users | 100 million | |
Business | 200 million |
3) High Level Design
User API design |
Users search for business.
Parameters.
{ "radius": 10, "business": [business Object] } |
GET / search / nearby | |
Business API design |
Restful API.
|
||
Data model |
Read / Write Ration Read:
Write:
Schema
|
MySql. (PostgreSQL) |
|
Algorithms to find near by business |
1) Geohash problems:
2) Quatree
|
4) design diagram
Load Balancer |
receive requests (latitute, longitute, radius) from users |
Location-based service |
Responsibility
characters:
it is a multi location services.
|
Business Service |
|
Database Cluster |
Scale: 1) Business Table
2) Geo index Table
|
Redis Cluster |
Caching is not necessary. Because read geo index from database is fast enough. we can use cache to handle the spike during peak hours. We use caching to enhance the performance. |
1) key: geohash, value: [business_list] storage for value: 200 m * 32 bytes * 3 precisions = 17gb storage for key: negligible.
we deploy this cache globally to ensuer hive availability |
|
2) key: businessid, value: business_object |