Design Spotify (Music Streaming)
Audio CDN with per-segment DRM, personalized playlists, search, social, and a recommender that closes the loop in minutes.
Intro
Spotify-class music streaming has the same ingest/playback split as YouTube but with audio (smaller, simpler) plus deeper personalization (Discover Weekly, Daily Mixes). The product differentiators — playlists, recommendations, social — drive most of the architectural complexity beyond the CDN.
Functional
- Stream tracks (encrypted) over an audio CDN.
- Search tracks / artists / albums / playlists.
- Personalized recommendations (Discover Weekly, Daily Mixes).
- User playlists + social (follow, share).
Non-functional
- Stream start latency p95 < 500 ms.
- 500 M MAU; ~80 M concurrent listeners at peak.
- Audio storage: 100 M tracks × 5 MB = 500 TB at multiple bitrates.
- DRM — encrypted segments; license server for keys.
Components
Audio CDN
Edge-cached encrypted segments.
License service
Issues per-session keys (Widevine / FairPlay).
Catalog service
Track / artist / album metadata.
Search
Elasticsearch with multi-language analyzers.
Playlist service
User playlists + collaborative.
Recommender
Online + offline; embedding-based.
Telemetry pipeline
Plays, skips, dwell → recommender + royalties.
Trade-offs
DRM at segment vs full-track
Pros
- Segment: per-session key; smaller blast radius.
- Full-track: cheaper compute.
Cons
- Segment: more license calls.
- Full-track: bigger key compromise.
Real-time vs batch recommendations
Pros
- Real-time: dynamic Daily Mix.
- Batch: cheap, weekly Discover Weekly.
Cons
- Real-time: model serving latency.
- Batch: stale by definition.
Scale concerns
- Hot tracks (new releases) — pre-position to CDN.
- License server load on session start storms.
- Royalties — every play must be counted accurately.
- Offline mode — encrypted local cache with TTL.