system design · system-design
Design Apple Music (Streaming + Recommendations)
Catalog, recommendations, offline playback, CDN, royalties. Music streaming at scale.
Theory
Explanation
Intuition first, formal definition second. Skim the bullets if you already know this; read the prose if you don't.
Music streaming = catalog × encoding × CDN × recommendation. Distinct: offline downloads (DRM), cross-device sync, royalty accounting per stream.
Catalog stores track + album metadata + license terms per region. Encoding produces ladder of bitrates (AAC, ALAC lossless, Dolby Atmos). CDN streams to clients. Recommendation: ALS embeddings + listen history + Beats curation. Offline downloads: download decryption key on tap; encrypted file on disk; license refresh on app open. Royalty service: per-stream event aggregated nightly for rights-holder payouts.
When to use
Audio streaming, podcast platforms.
When not to
Live radio (use streaming gateway).
flowchart LR Track[Track Master] --> Encode[Encoder · AAC/ALAC/Atmos] Encode --> CDN[Music CDN] Client([Client]) --> Cat[Catalog API] Client --> Lic[License Server] Client --> CDN Client -.listen event.-> Log[[Listen Log · Kafka]] Log --> Royalty[Royalty Aggregator] Log --> Reco[Recommendation] Reco --> Client
Key insights
- License refresh decouples offline downloads from connectivity.
- Lossless adds 5x bandwidth, tier UI to opt-in.
- Royalty must be auditable, per-stream event log retained 7 years.
- Recommendation blends ML + human curation (Apple Music Editorial).
- Cross-device library sync uses iCloud Music Library, separate sync product.