Post Service
POST /posts
POST /posts/{id}/like
Media service
POST /media/uploads/complete
Feed Service
GET /feed?cursor=x
user service
POST /users -> create users
GET /users/{id}/profile -> returns user profile
POST /users/{id}/follow -> creates social graph between two users
Acts as the entry point for all client requests.
Responsibilities:
Distributes traffic across multiple instances of all services to improve scalability and availability.
Post service
Media Service
Feed Service
Responsibilites
Rank Service
Kakfa
Fanout service
Like aggregator service:
User service:
PostreSQL + Casandra
We use a hybrid SQL (PostgreSQL) + NoSQL (Cassandra) architecture.
Data Model:
User
id (PK, partition key)
username
profilepc
POST
id (PK, partition key)
userid
mediaIds[]
caption
createdAt
user -> post: 1:many relationship
PostMedia
id (PK)
url
postId (partition key)
Status -> pending, uploaded, failed
POST -> PostMedia : 1:many relatiopnship
Follow
followerId (paritionKey)
followeeId
Like
id
userId
postId
value (1,-1) liked, disliked
User <-> follow: many:many relationship
Now we will deep dive in these topics:
-> Viral posts - millions of likes/reads
This is solved by our CDN + Like aggregator serivce + Redis
CDN -
Redis
Likes
Kafka failures
Fanout service crash
Redis failure
CDN failure (REGIONAL)
fallback:
CDN → origin region → cross-region fetch