Design the architecture for Spotify - the world's largest audio streaming platform with 615 million monthly active users and a catalog of 100 million tracks. Your design must cover:
- Audio streaming - serve audio files in multiple quality levels (low 24 kbps → very high 320 kbps → lossless 1,411 kbps). The player pre-buffers the next 30 seconds and seamlessly transitions between songs with gapless playback.•Content ingestion - artists/labels upload tracks via Spotify for Artists. Each track is transcoded into multiple formats (OGG Vorbis, AAC, FLAC), tagged with metadata, and distributed to CDN edge nodes.•Personalization engine - powers Discover Weekly, Release Radar, Daily Mixes, and the home feed. Uses collaborative filtering, content-based analysis (audio features via ML), and contextual signals (time of day, mood, listening history).•Search - search across 100 M tracks, artists, albums, podcasts, and playlists with type-ahead autocomplete in < 50 ms.•Offline mode - premium users can download playlists for offline listening. DRM (Widevine/FairPlay) protects content.•Social features - shared playlists, friend activity feed, collaborative queue ("Group Session").•Royalty calculation - for every stream, calculate the fractional royalty owed to artists/labels based on the user's subscription revenue and total streams. This is a massive batch compute job.
The key challenge is low-latency audio streaming with personalization at massive scale, combined with a complex royalty/payment system.
Design Spotify's music streaming platform - audio delivery, personalized playlists, offline mode, and social features for 600 M users. Build this architecture under realistic production constraints, then validate tradeoffs in the design lab simulation.
Request path: The solution keeps ingress, service logic, and stateful dependencies separated so each layer can scale independently.
Reference flow: Web Clients -> DNS -> CDN Edge -> Load Balancer -> API Gateway -> Core Service -> Primary SQL DB -> Redis Cache