๐ Problem Description
Design a music streaming service like Spotify. Users can search and play songs, create playlists, follow artists, and get personalized recommendations. Handle audio streaming, content delivery, and offline mode.
๐ค Use Cases
1.
User wants to searches for a song so that sees search results
2.
User wants to plays a song so that audio streams with low latency
3.
User wants to creates playlist so that playlist saved and shareable
4.
User wants to downloads for offline so that can play without internet
โ Functional Requirements
- โขSearch songs, albums, artists, playlists
- โขStream audio with quality selection
- โขCreate and share playlists
- โขFollow artists and users
- โขPersonalized recommendations
- โขOffline playback
- โขCross-device sync
โก Non-Functional Requirements
- โขPlayback start < 200ms
- โขNo buffering during playback
- โขSupport 100M concurrent users
- โข99.99% availability
โ ๏ธ Constraints & Assumptions
- โขAudio licensing requirements
- โขMultiple audio qualities (128, 256, 320 kbps)
- โขLimited offline storage on devices
๐ Capacity Estimation
๐ฅ Users
500M users, 100M concurrent streams
๐พ Storage
100PB (50M songs ร 3 qualities)
โก QPS
Play: 100K/sec, Search: 50K/sec
๐ Bandwidth
10Pbps peak
๐ Assumptions
- โข 50M songs
- โข 3 quality versions per song
- โข Average song: 5MB (320kbps)
- โข 100M concurrent streams
๐ก Key Concepts
CRITICAL
Adaptive Bitrate Streaming
Adjust quality based on network conditions.
CRITICAL
CDN for Audio
Edge caching reduces latency and origin load.
HIGH
Pre-buffering
Buffer next song in playlist for gapless playback.
HIGH
Collaborative Filtering
Recommendations based on similar users.
๐ก Interview Tips
- ๐กStart with the audio streaming architecture
- ๐กDiscuss the recommendation system in detail
- ๐กEmphasize CDN usage for audio delivery
- ๐กBe prepared to discuss royalty tracking and licensing
- ๐กKnow the difference between streaming and downloading
- ๐กUnderstand the catalog management and metadata