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

E85644104e56d9f8be2fcea8b20f5e97?s=128

Bradley Whittington

October 03, 2013
Tweet

More Decks by Bradley Whittington

Other Decks in Technology

Transcript

  1. The things I’ve seen, living with MongoDB Brad Whittington VP

    web products - Mxit
  2. What we use MongoDB for Primary data store for a

    few consumer products. Motribe mobile social network - JudgeME & MxPix Mxit Launch
  3. JudgeMe

  4. None
  5. 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
  6. MongoDB docs == MongoDB + EC2 =

  7. db.serverStatus() rs.add(...) MMS

  8. MongoSQL? Mongo is *not* a relational database This is bad:

    { _id:... friend_id:... user_id:... }
  9. 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.
  10. 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
  11. 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
  12. 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
  13. 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.
  14. db.currentOp() db.killOp() db.repair() db.currentOp().inprog.forEach( function(d){ if(d.waitingForLock && d.lockType != "read")

    printjson(d) })
  15. 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
  16. Read http://aphyr.com/tags/jepsen Aphyr / Jepsen / Call me maybe

  17. @darb github.com/bradwhittington speakerdeck.com/u/bradwhittington/ Questions?