-> Account APIs
POST /accounts
Get /accounts/{id}
-> User profile APIs
POST /user-profile
GET /user-profile/{id}
-> Subscribe
POST /subscribe
-> Request for content playback
GET /content/{id}
-> Search
GET /search?q={query}
-> Home feed
GET /feed
-> Progress tracking
POST /progress
req -
{
userId,
contentId,
duration_watched
}
GET /progress/{userid}/{contentId}
GET /progress/{userid}
API Gateway
Acts as the entry point for all client requests.
Responsibilities:
Distributes traffic across multiple instances of all services to improve scalability and availability.
Responsibilities
Geo content service
Feed Service
Progress Service
Recommendation Service
Responsibilties
score =
w1 * user_enagement
+ w2 * content_popularity
+ w3 * recency
+ w4 * ratings
Subscription Service
PostreSQL + Casandra
We use a hybrid SQL (PostgreSQL) + NoSQL (Cassandra) architecture.
SQL:
Account
Id (partition key)
passwordhash
UserProfile
Id (partition key)
accountId
name
language
region
Subscription
id
accountId (partition key)
plan
status
renewaldate
NoSQL
Content
id (partition key)
title
genre
description
rating
duration
manifestUrl
ContentGeoPolicy
Id
contentId (partition key)
Type - Allowed/Blocked
Regions
UserContentProgress
Id
userId (partition key)
contentid
durationWatched
last_position
UserPrefrences
userId (partition key)
genre_scores
last_updated
UserFeed (Fallback feed DB)
id
userId (partition key)
contentIds[]
updateAt
We use a distributed inverted index, where:
We will now deep dive into the following topics:
ABR is needed in system like this, because we dont want to return the entire video content when user requests to watch the video, that is not efficent and takes a very long time when videos are very large. Instead we implement ABR using HLS/DASH:
How it works
-> How do we determine user region and ensure proper security of no unauthorized access of content
User IP Geolocation
User profile region
We usually combine this, so formula is
if IP == user region from table
use it
else
apply rules:
travel execptions
subscription rights
Feed Service
-> How do we sync user progress acorss multiple device?
Scaling strategies
Failure handling:
Kafka failures
Subcription service crash
Redis failure