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

How BillGuard Does MongoDB

How BillGuard Does MongoDB

A description of the move BillGuard did to put its crowd sourcing brain on MongoDB given at the MongoIL meetup on March 7, 2012.

Aviv Ben-Yosef

March 07, 2012
Tweet

More Decks by Aviv Ben-Yosef

Other Decks in Programming

Transcript

  1. Recalculate in memory when server boots Works as long as

    you have one server and little data
  2. Time to upgrade Boot time became problematic as data grew

    Needed to sync across multiple servers
  3. A breeze to configure config = { "_id" : "bg",

    "members" : [ { "_id" : 0, "host" : "$MONGO_SERVER_A:27017" }, { "_id" : 1, "host" : "$MONGO_SERVER_B:27017" }, { "_id" : 2, "host" : "$MONGO_ARBITER:27017", "arbiterOnly": true } ] } rs.initiate(config); Now configure a master-master in MySQL...
  4. More big guns • Backing up the EBSs it sits

    on • Mongo Monitoring System (MMS)
  5. Upserts and atomic • No need to lock • No

    need to rollback • Just write atomically!
  6. Atomic use case - clusters • 2 users register with

    transactions from same merchant • no problem!
  7. >  db.merchants.update(        {name:  "yamit  2000"},    

       {$inc:  {users:  1}},        true) >  db.merchants.find() {  "name"  :  "yamit  2000",  "users"  :  1  } >  db.merchants.update(        {name:  "yamit  2000"},        {$inc:  {users:  1}},        true) >  db.merchants.find() {  "name"  :  "yamit  2000",  "users"  :  2  }
  8. Easily Indexable class MyEntity { @Id private ObjectId id; @Indexed

    private String widget; // ... } class MyEntityDao { public MyEntityDao() { // ... datastore.ensureIndexes(); } }
  9. ...and lotsa stuff • sweet queries: regex, awesome operators ($in,

    $inc, …) • map reduce (but no group by) • ids have timestamps and unique across servers