Skip to content

Spotify — Detailed#

flowchart TB
  subgraph Clients
    Desk
    Mob
    Web
    Connect([Spotify Connect devices])
  end

  subgraph Edge
    CDN[Music CDN<br/>Akamai / Fastly / GCP]
    GW[Backend Gateway]
  end

  subgraph Catalog
    CAT[Catalog Service]
    TR[(Tracks metadata)]
    ALB[(Albums)]
    ART[(Artists)]
    PL[(Playlists)]
  end

  subgraph Audio[Audio Pipeline]
    LABEL([Label ingest])
    DRM[DRM packaging]
    ENC([Encoders<br/>Ogg Vorbis, AAC, FLAC])
    BITRATE[96 / 160 / 320 kbps + lossless]
    OBJ[(Object store)]
  end

  subgraph Discovery
    HOME[Home]
    SEARCH[Search]
    DAILY[Daily Mix]
    WEEKLY[Discover Weekly]
    RADAR[Release Radar]
    PODCAST[Podcasts]
  end

  subgraph Reco
    CG([Candidate Gen])
    RANK([Ranker])
    GENRE([Genre embeddings])
    TASTE[Taste profile]
    NLP[Natural language playlist]
  end

  subgraph Playback
    PSVC[Playback Service]
    QUEUE[[Queue Manager]]
    OFFLINE[Offline cache]
    SHUFFLE[Smart shuffle]
    GAPLESS[Gapless / crossfade]
  end

  subgraph Social
    SHARE[Share / Friend feed]
    COLL[Collaborative playlist]
    BLEND[Blend]
  end

  subgraph Analytics
    PLAY_LOG[Playback events]
    KAFKA[[Kafka]]
    BQ[(BigQuery / Snowflake)]
    PAY[Royalty calculator]
  end

  subgraph Ads[Ads - free tier]
    ADSVR[Ad server]
    AUC[Auction]
  end

  Clients --> CDN
  Clients --> GW --> Catalog
  CDN --> OBJ
  Audio --> OBJ
  GW --> Discovery
  Discovery --> Reco
  Reco --> Taste[TASTE]
  GW --> Playback --> CDN
  Playback --> PLAY_LOG --> KAFKA --> BQ
  Social --- Playback
  Ads --- Playback
  PAY --- BQ

    classDef client fill:#dbeafe,stroke:#1e40af,stroke-width:1px,color:#0f172a;
    classDef edge fill:#cffafe,stroke:#0e7490,stroke-width:1px,color:#0f172a;
    classDef service fill:#fef3c7,stroke:#92400e,stroke-width:1px,color:#0f172a;
    classDef datastore fill:#fee2e2,stroke:#991b1b,stroke-width:1px,color:#0f172a;
    classDef cache fill:#fed7aa,stroke:#9a3412,stroke-width:1px,color:#0f172a;
    classDef queue fill:#ede9fe,stroke:#5b21b6,stroke-width:1px,color:#0f172a;
    classDef compute fill:#d1fae5,stroke:#065f46,stroke-width:1px,color:#0f172a;
    classDef storage fill:#e5e7eb,stroke:#374151,stroke-width:1px,color:#0f172a;
    classDef external fill:#fce7f3,stroke:#9d174d,stroke-width:1px,color:#0f172a;
    classDef obs fill:#f3e8ff,stroke:#6b21a8,stroke-width:1px,color:#0f172a;
    class Connect client;
    class CDN,GW edge;
    class CAT,DRM,BITRATE,HOME,SEARCH,DAILY,WEEKLY,RADAR,PODCAST,TASTE,NLP,PSVC,OFFLINE,SHUFFLE,GAPLESS,SHARE,COLL,BLEND,PLAY_LOG,PAY,ADSVR,AUC,Taste service;
    class TR,ALB,ART,PL,BQ datastore;
    class QUEUE,KAFKA queue;
    class LABEL,ENC,CG,RANK,GENRE compute;
    class OBJ storage;

Audio storage & delivery#

  • Ogg Vorbis historically; AAC for Apple, FLAC for HiFi.
  • Bitrates: 96, 160, 320 kbps (free / premium / very high).
  • Files stored in object store, fronted by CDN.
  • Tracks immutable once ingested; new master = new id.

Playback flow#

  1. Client requests track_id → control plane returns CDN URL + license.
  2. Client downloads chunks ahead (10–30 s buffer).
  3. Telemetry every play emits a "stream" event for royalties + reco.

Recommendation#

  • Collaborative filtering on listen graphs.
  • Audio analysis features (tempo, key, valence) for cold start.
  • NLP on playlist titles & genres.
  • Discover Weekly: candidate set + personalized ranker.

Spotify Connect#

  • Device discovery + control: phone controls playback on speaker / TV.
  • Streams come from CDN to the playback device, not via phone.

Royalty calc#

  • Per-stream play log → publisher splits via daily batch job.
  • 30-second threshold for monetized streams.

Glossary & fundamentals#

Concepts referenced in this design. Each row links to its canonical page; the tag column shows whether it is a high-level (HLD) or low-level (LLD) concept.

Tag Concept What it is Page
HLD CDN edge caching for static assets cdn
HLD Pub/Sub & message brokers topics, consumer groups, delivery semantics pub-sub-pattern
HLD Observability metrics, logs, traces, SLOs observability
LLD Immutability immutable types, persistent collections immutability