MongoDB at Turntable.fm

Online music distribution has continually been a hotbed of innovation. But last year, when giants like Spotify were making their entry into the US market, a small startup in New York City took over the desktop music scene. Turntable.fm, a listening party for the web, powered by MongoDB, was an overnight success, and captured the screens and headsets of the New York City tech scene. A year later, we sat down with Billy Chasen to discuss his team’s decision to use MongoDB in their stack and get some advice on best practices for MongoDB.

What is Turntable.fm?

Turntable is a way to listen to music with other people online, at the same time. It tries to recreate the idea of hanging out together and taking turns playing music, except online.

Can you describe your technology stack?

Our backend uses mongodb, memcache, along with python and python frameworks, like tornado and cherrypy. Our frontend is pretty much entirely javascript.

How are you using MongoDB at Turntable.fm?

Aside from holding all important information (such as user data and room names), we use mongo to also handle the current room state for all our rooms and users online.

Turntable.fm was an overnight success. What have you learned about MongoDB from growing so rapidly?

Mongo can take a lot of abuse and allowed us to move fast. The trick was optimizing our inefficient queries and other operations while we were quickly growing.

At the New York MongoDB User Group last summer, you talked about some MongoDB “gotchas” that you experienced. What changes have you made (if any!) since then to address some of the issues you encountered?

All of those mongo gotchas were basically things we had to find and then fix. The gotchas are now of larger scale (write lock issues, scaling with replica sets, etc…)

What advice do you have for startups just getting started with MongoDB?

-Try to stay on top of what queries your actually making and what indexes you will need. If you’re aware of that from the beginning, it’ll save some headaches later on. But don’t try to scale everything from day one. The first step is making sure people like your product.

-Just make sure the indexes you are making are being properly used (sometimes you may even have to send mongo hints if you have several indexes). Using explain() and verifying what you think is happening is actually happening.

-Make sure you understand how composite indexes and how to properly create them based on your data.
-Monitor your mongo server with something like munin and/or nagios to make sure the cpu isn’t spiking (a clear indicator that you may be missing an index)

Tagged with: turntable.fm, startup, music, replica sets, queries, tornado, cherrypy, MongoDB, Mongo, NoSQL, Polyglot persistence, 10gen