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

Scaling MongoDB to 10,000 rps & beyond

Scaling MongoDB to 10,000 rps & beyond

We use MongoDB heavily as our primary database. Here we talk about the operational issues and challenges we faced for scaling MongoDB to 10,000 rps & beyond

Helpshift Inc.

June 23, 2014
Tweet

More Decks by Helpshift Inc.

Other Decks in Technology

Transcript

  1. What’s MongoDB MongoDB is an open-source document database that provides

    high performance, high availability, and automatic scaling. A MongoDB document
  2. Why MongoDB • Schemaless • Faster Development in Early Stage

    • Easier to get started with compared to other NoSQL Solutions
  3. Master Slave Replication • Easier to maintain • No automatic

    failover • Compulsory downtime for all major administrative operations ◦ convert master-slave to replica set ◦ promote slave to be a master ◦ inverting master and slave
  4. Global Locks • 2.2 - Global locks for all write

    operations • 2.4 - “database” level locking • Global locks are only for certain operations • No “row” level locking yet
  5. Replica Sets • Automatic failover • Writes were lost without

    Write Concern • Use replica acknowledge • Priorities • Promotions and step downs
  6. Sharding • Scale writes efficiently • Choose right “shard key”

    to avoid “hot regions” • Different ways of taking backups in sharded environment
  7. Read Preference • Read operations return results from the primary

    • rs.slaveOk() / secondaryPreferred • Propagation delays • Stale data • Eventual Consistency • Write Concern
  8. Read Preference…. • Maintaining an availability during a failover •

    Tags can be added to secondaries ◦ “tags” : { “dc” : “east”, “disk”: “ssd” } • Tags can be used with “write concern” as well
  9. Miscellaneous • Working set needs to fit in memory "workingSet":

    { "pagesInMemory": 315253 } • repairDatabase() • XFS • AWS EC2 - LVM + RAID10 • sysctl.conf ◦ net.ipv4.tcp_keepalive_time = 300
  10. Future Directions (?) • TokuMX ◦ Transactions! ◦ 90% space

    reduction ◦ Drop in replacement for MongoDB 2.4 ◦ 10x Faster Indexing ◦ Reduced SSD wear ◦ No “Text Search” ◦ No “Geospatial Indexes”