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

MongoDB 2.2 New Features

MongoDB 2.2 New Features

Overview of some of the new features in the upcoming MongoDB 2.2 release

Sridhar Nanjundeswaran

July 25, 2012
Tweet

More Decks by Sridhar Nanjundeswaran

Other Decks in Programming

Transcript

  1. 2 2.2 Aug ‘12 2.0 Sept ‘11 1.8 March ‘11

    Journaling Sharding and Replica set enhancements Spherical geo search Index enhancements to improve size and performance Authentication with sharded clusters Replica Set Enhancements Concurrency improvements Aggregation Framework Multi-Data Center Deployments Improved Performance and Concurrency
  2. 4 • Concurrency improvements – DB Level Locking – More

    yielding • Aggregation Framework • Tag aware sharding or geo-sharding • Read Preferences • TTL Collections • Shell enhancements • More…
  3. 5 • DB Level Locking – Write operations lock at

    db level, not globally • Replication can happen in parallel to write (client db vs. local) – Global lock for journaling, fsync etc. only – db.serverStatus() enhanced to show lock stats per db • Yielding on page fault – Started with 2.0 – Remove holding write lock on disk access for updates also – Stats available as part of db.serverStatus() • db.serverStatus().recordStats • db.serverStatus().extra_info
  4. 6 • Replaces most common uses of map/reduce • Implemented

    in C++. Hence better performance than interpreted JavaScript • Operators can be chained similar to Unix pipes • Framework allows easy implementation of new operators • Pipeline and compute operators : $project, $unwind $group, $sort, $skip, $add, string functions • Use $match and $sort early in the pipeline. Query optimizer can use indexes
  5. 7 • Operators – $project – specified fields, compute values

    etc. – $unwind – stream arrays – $group – aggregate on key • Document with tags (array of strings). E.g. db.posts.aggregate( {$unwind : "$tags"} , {$group : {_id : "$tags", total :{$sum : 1}}}) • Doc - http://docs.mongodb.org/manual/applications/aggr egation/
  6. 8 • Most common use - • Implemented as generic

    tags on shard members – geographically locate data – distribute based on usage • Add tags to shards – sh.addShardTag( "shard0000" , "a" ) • Specify range by tag – sh.addTagRange( "test.foo" , { _id : -1 } , { _id : 1000 } , "a" ) • More info – https://github.com/mongodb/mongo/blob/master/jstests/ slowNightly/balance_tags1.js
  7. 9 • Consistent nomenclature across drivers and mongos • Modes

    – Primary (default), Primary_Preferred, Secondary, Secondary_Preferred, Nearest • Replica set tags – Read support for replica set tags
  8. 10 • Auto expire data by setting a TTL •

    Use field in document to specify expiry. – db.log.events.ensureIndex({“expiryDate": 1}, {expireAfterSeconds: 3600}) • Separate mongod process regularly removes • Can be used with replication and sharding • Constraints – Should have a date type value – Cannot be compound – Cannot be used on capped collection
  9. 11 • Verbose mode – Shows number of documents affected,

    time taken > db.foo.update({},{$set:{newfield:10}},false,true) > set verbose true set verbose to true > db.foo.update({},{$set:{newfield:10}},false,true) Updated 2 existing record(s) in 2ms • slaveOk – Settings similar to drivers – Greater control from shell or scripts – > db.getMongo().setSlaveOk() – > db.setSlaveOk() – > db.foo.setSlaveOk() • Enhanced editing features
  10. 12 • Replication – replsetSyncFrom – specify who to sync

    from • Tools – mongooplog – tool for replaying oplog – Authentication support and concurrency statistics in mongotop and mongostat • Query optimizer – Many improvements not directly visible to user – Better support for $in + sort + limit • Map/reduce – Choose initial split points for sharded output
  11. 13

  12. 14 • Download – http://www.mongodb.org/downloads • Release notes – http://docs.mongodb.org/manual/release-notes/2.2

    • Resolved issues – https://jira.mongodb.org/secure/IssueNavigator.jspa?mod e=hide&requestId=10907 • Backward breaking changes – https://jira.mongodb.org/secure/IssueNavigator.jspa?requ estId=11225
  13. 15 • Standard incremental update. Hence a drop in replacement

    • Standalone – Shutdown and replace • Replica Set – Rolling upgrade starting with secondaries • Sharded Cluster – Mongos, Config servers and then rolling upgrade of shards • More details at http://docs.mongodb.org/manual/release- notes/2.2/#upgrading
  14. 16

  15. 17 • Operational enhancements – Integration with external authentication systems

    – Simplified sharding setup – Further reductions in fragmentation • New features – Built in full-text search • Performance improvements – Further concurrency improvements – Improved aggregation framework performance – More efficient usage of indexes, including multiple indexes on a single query
  16. 18 @mongodb conferences, appearances, and meetups http://www.10gen.com/events http://bit.ly/mongofb Facebook |

    Twitter | LinkedIn http://linkd.in/joinmongo download at mongodb.org We’re Hiring ! [email protected] @snanjund