Spotify
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Design Spotify: the 60-second story

    Design Spotify

    Tap a song. Hear it before your thumb leaves the glass.

    100M+ tracks, 788M users, 184 markets. The bytes are easy. Fast starts, royalty-grade play counts and per-country rights are hard.

    4.2 MB

    one 3½-minute song at 160 kbps

    Unlike video, audio is small. Every format of every track is about 5.5 PB, and the top 100,000 tracks fit on one CDN server.

    Where do 250 ms go between tap and sound?

    Never open a connection on the tap. Keep connections warm, hold keys as day-long leases, and ask for just the first 64 KB.

    In 2010, 61% of plays were predictable: the last track ended, or the listener pressed next.

    The trick

    Fetch the next track 30 s before the end and trim encoder padding. The join is gapless.

    When does a song pick its quality?

    Bad: Every few seconds, like video

    Machinery built for gigabyte films.

    Good: Once, as the track starts

    A 160 kbps song downloads 12× faster than it plays on 2 Mbps.

    Asha and Ravi insert into the same gap at once

    Integer positions would collide. Fractional keys don’t. Between c and m you can mint h. Both inserts survive, and nothing is renumbered.

    700k/s

    playback events at peak

    Royalties are split by these counts, so this is a ledger, not a dashboard. At-least-once into a durable queue; exactly once in the ledger.

    Nine days offline. How do downloads stay licensed?

    1. Each file encrypted once with its own key
    2. Keys wrapped to the phone’s secure hardware
    3. Licences expire in 30 days
    4. Check-in uploads plays, then renews

    Remember

    Three planes. Catalogue: rights and search, filtered by market. Audio: small encrypted files from CDN edges and device caches. Events: at-least-once in, exactly once in the royalty ledger.