Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The things I've seen, living with MongoDB

The things I've seen, living with MongoDB

A short talk through some of the lessons learned about MongoDB at Motribe and Mxit

Bradley Whittington

October 03, 2013

More Decks by Bradley Whittington

Other Decks in Technology


  1. What we use MongoDB for Primary data store for a

    few consumer products. Motribe mobile social network - JudgeME & MxPix Mxit Launch
  2. Polytechnical university of hardknocks 1 week into my new job…

    Zero MongoDB experience Massive crashes and timeouts on our cluster Hundreds of requests per minute
  3. MongoSQL? Mongo is *not* a relational database This is bad:

    { _id:... friend_id:... user_id:... }
  4. The Data is Hot If you can’t fit all your

    data in RAM, make sure you are kind to your (network connected) hard drives. Reads from (networked) disks are (incredibly) slow.
  5. sort by rand() limit 1 MongoDB is all… One Solution!

    (see the help pages for more) Add random geospatial positions Geospatial indexing Query for objects near [x,y] Disks are all like
  6. I wish we had Capped Arrays*... Database with Capped Collections.Totally

    okay. For the first n00 000 collections. Then it’s a bad idea. A very bad idea. * Available in MongoDB 2.4
  7. A fresh start. Mxit Launch Platform for app creation Aim

    for ±single document per request Cache cleverly, aggressively Database per app 300 authors 9M pageviews/month 2M unique users 4 m1.small 1 amazon core, 1.7GB ram
  8. A fresh lesson Doing ensureIndex(..., {background:true}) inline in the request

    is sub-optimal. 60 indexing processes 3M document collection (not fully in RAM) Not ideal.
  9. MongoDB Love • Mongo terminal is JS • Recovery is

    quick, easy • Sharding is easy • Indexes are lovely • Be careful in your architecture / queries. Pure index queries are ++ • MongoDB is not a Relational DB