Media & streaming · Intermediate

Spotify music streaming

Byte-range audio from CDNs, a BFF over catalogue and playlists, and an event pipeline for royalties.

Every part, and why it is there

Spotify apps

Play the first part of a track almost instantly, then buffer ahead in chunks. They also report every play, skip and pause, which matters as much as the playback itself.

Audio CDN

Audio files are fetched in byte ranges from commercial CDNs. Popular tracks are always hot at the edge; long-tail tracks may come from origin on the first play.

Encoded audio

Each track stored once per codec and quality (low to very high, plus lossless). Immutable files, perfect for object storage behind a CDN.

API gateway

Authenticates the user and routes calls to the right backend for the client type.

Client backend (BFF)

A backend-for-frontend shapes data for each app (phone, desktop, car) so one screen is one call. It fans out to the catalogue, playlists and recommendations.

Catalogue service

Artists, albums, tracks and where each track’s audio file lives. Read millions of times, changed rarely.

Catalogue store

Metadata for over 100 million tracks, replicated across regions so every lookup is local.

Playlist service

Create, edit and share playlists, including collaborative ones. Edits are stored as a history of changes so two people adding songs at once do not overwrite each other.

Playlist store

Billions of playlists, each a document of track ids plus its change history.

Precomputed recommendations

Discover Weekly, Daily Mixes and Home shelves, computed in batch and stored per user. Serving them is a single key lookup.

Event gateway

Receives play, skip and pause events from every client. It just validates and forwards so clients never wait.

Event delivery (Pub/Sub)

A durable, managed message bus carrying hundreds of thousands of events a second. Losing events would mean paying artists wrongly, so delivery must be reliable.

Data pipelines

Batch and streaming jobs that count streams for royalties and charts and train recommendation models, writing results back to the recommendation store.

Data lake

Every event ever, partitioned by hour. The raw material for analytics, A/B tests and model training.

Asked in interviews at

  • amazon
  • databricks
  • oracle

Learn more

All system design examples