Design Spotify
Understanding the Problem
🎧 What is Spotify? Spotify is a music streaming service. Users search a catalog of around 100 million tracks, press play and hear music almost instantly, build and share playlists, and move playback between phone, laptop, car and smart speaker. Audio files are tiny compared to video, so the challenge is less about raw bandwidth and more about making a huge catalog feel instant, and keeping user state (playlists, queues, positions) consistent across devices.
Two variants come up. Audible (or Spotify's own audiobooks) is the same streaming system with very long files, where the hard parts become resume position across devices and offline downloads. Voice-controlled playback ("Hey, play my workout playlist in the kitchen") adds a speech pipeline and remote control of other devices on top. We'll cover both: voice as a core requirement and audiobooks in a deep dive.
Functional Requirements
Core Requirements
- Users should be able to search for songs, albums and artists, and play any track with playback starting almost immediately.
- Users should be able to create, edit, follow and share playlists, including collaborative playlists edited by several people.
- Users should be able to control playback by voice, and on other devices (play on the speaker from the phone).
Below the line (out of scope)
- Recommendations (Discover Weekly, radio). We'll treat them as a list of track IDs from elsewhere.
- Royalty accounting and artist payouts (we'll emit play events but not design the pipeline).
- Podcasts, lyrics and social features.
- Ads in the free tier.
Non-Functional Requirements
Ask for scale. We'll assume 250 million daily active users listening about 2 hours a day, a catalog of 100 million tracks, and several billion playlists.
Core Requirements
- Playback should start within ~300 ms of pressing play, and the next track should start with no gap.
- The system should be highly available for playback (99.99%). Search and playlists can degrade briefly; music shouldn't stop.
- Playlist edits should be visible to the editor immediately, and to collaborators and followers within seconds. Concurrent edits must not lose anyone's change.
- A voice command should turn into music in about a second after the user stops speaking.
- Content must only play where it's licensed, and downloaded tracks must not be usable outside the app.
Below the line (out of scope)
- Strong global consistency for play counts.
- Building our own speech recognition models; we'll use them as components.
The numbers:
- Track size: a 3.5-minute track at 160 kbps is 160,000 ÷ 8 × 210 s ≈ 4.2 MB; at 320 kbps, about 8.4 MB. Storing a few quality levels per track (plus lossless, which is several times bigger) is tens of MB per track, and 100M tracks come to a few petabytes. Large, but nothing special for object storage.
- Concurrency: 250M users × 2 hours = 500M listening hours a day, so on average 500M ÷ 24 ≈ 21M people are listening at any moment, maybe 35M at peak.
- Bandwidth: 35M × 160 kbps ≈ 5.6 Tbps at peak. That's a CDN job, but a fraction of what video platforms push.
- Play starts: 500M hours ÷ 3.5 minutes per track ≈ 8.6B track starts a day, about 100k per second. Each one is an API call for authorization and a URL.
Compare this with /system-design/netflix: video bandwidth is 50-100× higher per user. Spotify's hard problems sit elsewhere. Audio is small enough to prefetch aggressively and cache on the device, so the "instant start" requirement is met mostly by the client. The server-side challenges are the read load on popular playlists, consistent shared editing, and the many devices a user expects to stay in sync.