Storage: 100M x 5MB = 500TB raw data
Streaming bandwidth:
Playlists:
POST /playlists
GET /playlists/{id}
PUT /playlists -> update/soft-delete playlist
req - {
status : 'InActive'
}
POST /playlists/{id}/song -> Add song
PUT /playlists/{id}/song -> soft-delete song from playlist
Playback:
GET /songs/{id}
Search:
GET /search?q=XYZ?cursor=id
-> returns: songs, artists, albums matching the query
GET /home-feed
-> returns users's personalized home feed (songs)
Like songs:
POST /songs/{id}/like
Acts as the entry point for all client requests.
Responsibilities:
Distributes traffic across multiple instances of all services to improve scalability and availability.
User Service/Playlist Service -> CRUD operations for both user and playlists
Streaming service:
Responsibilities
Search Service
Responsibilities
ElasticSearcgh
Event collection service
Responsibilties:
Kafka:
Flink:
Feature store / ML Model:
Feed/Recommendation Service:
Redis:
We use a hybrid SQL (PostgreSQL) + NoSQL (Cassandra) architecture.
Users
id
name
country (partition key)
Playlist
id
name
user_id (partition key)
status
PlaylistSongs
id
playlistId (partition key)
songId
position
Status
Songs
id
title
artist_id
album_id
duration
genre
-> artist id + album id as partition key
Artists
id
name
status
Albums
id
artist_id
songs[]
released_date
We will now deep dive in the following topics:
Client → Event Service → Kafka → Flink → Feature Store
Feature Store → Training Pipeline → Model Registry
Models are trained offline for stability, reproducibility, and cost efficiency. Versioned models are deployed via a Model Registry.
Instead of ranking 100M songs, we first generate ~500 candidates using:
This reduces ranking cost significantly.
Each candidate is scored using an ML model based on:
Top 50–100 songs are selected and precomputed into Redis:
Ranking Service → Redis → Home Feed API
Redis enables sub-50ms feed retrieval, with Cassandra as fallback.
Flink continuously updates user features. If a major behavior shift is detected (e.g., Rock → Jazz), we trigger partial feed regeneration to keep recommendations fresh.
Search is powered by Elasticsearch with an event-driven indexing pipeline:
Song Service → Kafka → Indexer → Elasticsearch
Search queries go through:
Client → Search Service → Elasticsearch → Metadata Enrichment → Response
Elasticsearch handles relevance ranking, while Redis/Cassandra is used for metadata enrichment.
System is horizontally scalable with cached hot queries.
The system is deployed across multiple regions for low latency and high availability.
Audio is served via CDN with fallback to object storage.
User → CDN Edge → Object Storage