Skip to content
Low Level Design Mastery Logo
LowLevelDesign Mastery

Design Music Streaming Service like Spotify

Design a high-scale media platform with real-time streaming, playlists, and recommendations.

What is the Music Streaming Service Problem?

Section titled “What is the Music Streaming Service Problem?”

Design a music streaming service similar to Spotify that allows users to search, play, and manage songs, create and share playlists, stream music in real-time, get personalized recommendations, and download songs for offline playback. The system should handle millions of concurrent users, provide low-latency streaming, and support social features like following users and sharing playlists.

In this problem, you’ll design the core orchestration between content discovery, real-time streaming states, and social interactions like sharing and following.


Design a service that allows millions of users to discover music, create social connections, and stream high-quality audio with minimal buffering.

Functional Requirements:

  • Library Management: Catalog songs, albums, and artists with detailed metadata.
  • Search: Find content by title, genre, or artist with low latency.
  • Playback Control: Support play, pause, skip, shuffle, and repeat modes.
  • Playlists: Create, share, and collaborate on music collections.
  • Recommendations: Suggest songs based on user history and likes.
  • Social Features: Follow users and see their real-time listening activity.
  • Offline Mode: Download and manage songs for playback without internet.

Non-Functional Requirements:

  • Scalability: Handle millions of concurrent users and massive media requests.
  • Low Latency: Music must start playing almost instantly.
  • Thread Safety: Ensure consistent states for shared playlists and user profiles.
  • Extensibility: Easy to add new content formats (like Hi-Fi audio or Video).

The system coordinates between the ContentManager, PlaybackService, and RecommendationEngine.

Diagram
classDiagram
    class MusicPlayer {
        -PlaybackState state
        -List~Song~ queue
        +play()
        +pause()
        +skip()
    }
    
    class PlaybackState {
        <<interface>>
        +handleAction()
    }
    
    class Song {
        -String id
        -String url
        -Metadata metadata
    }

    class Playlist {
        -String name
        -User owner
        -List~Song~ tracks
        +addTrack(song)
    }

    class RecommendationService {
        -RecommendationStrategy strategy
        +getSuggestions(user)
    }

    MusicPlayer --> PlaybackState
    MusicPlayer o-- Song
    Playlist o-- Song
    RecommendationService --> RecommendationStrategy

Diagram

A player shouldn’t allow a “skip” action if it’s already in a “stopped” or “buffering” state without specific logic.

Solution: Use the State Pattern. Define PlayingState, PausedState, and BufferingState. Each class handles the commands (play, pause, next) based on the specific rules of that state, ensuring the UI and Backend are always in sync.

One week you might use “Collaborative Filtering,” and next week you might switch to “Neural Network Recommendations.”

Solution: Use the Strategy Pattern. The RecommendationService accepts a RecommendationStrategy interface. This decouples the content-serving logic from the complex ML math, allowing for easy A/B testing of new algorithms.

When a user with 1 million followers plays a song, notifying all 1 million followers in real-time can freeze the system.

Solution: Use Asynchronous Buffering (Observer Pattern). Instead of immediate pushes, the system writes the activity to a high-speed message queue (like Kafka). Workers then batch these updates and push them to active followers only, avoiding massive spikes in processing.


By solving this problem, you’ll master:

  • State Management - Coordinating complex hardware/software playback.
  • Metadata Modeling - Handling nested relationships (Artist > Album > Song).
  • Social Graph Logic - Managing “Following” relationships and activity feeds.
  • Scalable Patterns - Using Strategies and Observers to handle massive traffic.

Ready to see the full implementation? Open the interactive playground to access:

  • 🎯 Step-by-step guidance through the 8-step LLD approach
  • 📊 Interactive UML builder to visualize your design
  • 💻 Complete Code Solutions in Python, Java, C++, TypeScript, JavaScript, C#
  • 🤖 AI-powered review of your design and code

After mastering the Music Streaming Service, try these similar problems: