Amplified Media

Spotify uses a peer-to-peer network (p2p)

Spotify uses some particularly clever streaming technology to deliver all that instant music. It’s been described in an academic paper by Spotify techno-wizards Gunnar Kreitz and Fredrik Niemelä, who included some very interesting statistics and analysis of their measurements taken during one week in the early part of 2010.

What I found most revealing is that Spotify is the only on-demand music streaming service that’s not web-based. Instead, it uses a peer-to-peer network (p2p) that can scale up to meet the demands of millions of users.

Only 8.8% of music playback comes from Spotify’s servers. The rest comes from the peer-to-peer network (35.8%) or your local cache (55.4%). The exception here is Spotify on smartphones, which gets all the music directly from the Spotify servers.

How Spotify Streams a Track


image source

  1. User clicks a track to listen to.
  2. If it’s in the cache, Spotify just starts playing it from there.
  3. Otherwise, the Spotify client requests the first 15 seconds of the track from the Spotify servers so that playback can start as soon as possible.
  4. At the same time, the client starts looking for the track on the peer-to-peer network.
  5. The rest of the track is streamed, from a combination of multiple sources if available (cache, multiple peers, Spotify servers). The more popular a track is, the more likely it will be streamed using the p2p network instead of the Spotify servers.
  6. When the track has 30 seconds to go, the Spotify client begins searching the p2p network for the next track.
  7. When the track has 10 seconds to go, if it hasn’t found the next track on the network yet, the client starts pre-fetching it from the Spotify servers.

Here is the link to download the full paper by Gunnar Kreitz, Fredrik Niemelä (PDF)
http://www.csc.kth.se/~gkreitz/spotify-p2p10/spotify-p2p10.pdf

Leave a Comment

Your email address will not be published. Required fields are marked *