Estimate the scale of the system. Consider daily active users, read/write ratio, storage requirements, bandwidth, and any relevant QPS calculations...
Tweet - tweet:
GET /tweet/v1/tid
POST /tweet/v1/
Delete /tweet/v1/tid
Tweet - Like:
GET /tweet/v1/tid/like
POST /tweet/v1/tid/like
User:
GET /user/v1/uid
POST /user/v1
PATCH /user/v1/uid
Follower:
GET /follower/v1/uid
ADD /follower/v1/uid
Client
-> API Gateway
-> Auth Service
-> Timeline Service
-> Cache
-> Tweet Cache / Tweet DB
-> Ranking Service
Scalability
Tweet Table:
UID int, primary key
TID int
Timeline date, index
description String
Like int
User Table:
UID int, primary key
email var, index
Followers List
Following List
Gateway/Load balancer: Responsible for auth, and direct request to the specific server.
Tweet Server(Web Server): Work with Tweet and Like API, when received a Tweet, it push to the queue(Kafka) and wait for Tweet Scanner to process.
Tweet Scanner(Serveless/Lambda): process the Tweet and store the result into Mongo DB.
DB:
Store the Tweet and User data.
Feed Server:
Process the feed if cache is not hit.