Sunday, February 17, 2013

Put Spotify in AWS

Affärsvärlden wrote an interesting article about Spotify regarding their business model. I stopped using it since they started to limit hours of free usage. The reason I am doing this, (not only because I'm bored at airport waiting for my wife and daughter to arrive.) I have a hunch, using cloud might be cheaper for them.

Business reason: Spotify is driving a low margin business, where main cost is music fees and revenue is advertisement and paid user.
Technical reasons: 20 million active users with 20 million songs, adding 20.000 songs daily

Low margin with high volume. Wait, aren't we talking about Amazon here? I do believe at Spotify there are top engineers. But this blog is my personal estimate based on above numbers. How can we leverage cloud instead of spending time on build infrastructure or re-inventing the wheels.

Design princip, there is no challenge when you know the answers, but base some fundamental from "high availability and scalability sites" on internet. Spotify deliver content(music) to end users. So naturally the following technologies should be used.
  • A CDN infront music files
  • Resilience storage for songs - S3
  • P2P for data distribution between users
  • NoDB for user information, such as session and updates
  • Map Reduce for search
  • Spot instances for extra calculation power for some analysis 
Lets make some assumptions
  • An average song is 4Mb. 80Tb data in total. 2.4Tb new song per month.
  • An average user listen to 4 hours music daily. 2.4 Billion hours per month.
  • 60% of traffic is people listen to same or similar music that handle by P2P network
  • 30% of traffic is handed CDN network
  • 10% of traffic is origin to S3
  • 60 servers distributed over EU/US/Japan for handling web, db and other services
This will cost about 30000-40000 USD / month. A lot money? Not if you have to build whole infrastructure by yourself. This is about 3 millions SEK per year, only 0.5% of their total operation cost. Well, you do the math.

Note: Cloudfront is unfortunately more expensive than other CDN.

No comments: