$30 off During Our Annual Pro Sale. View Details »

MongoDB 2.2 At the Silicon Valley MongoDB User Group

mongodb
August 18, 2012

MongoDB 2.2 At the Silicon Valley MongoDB User Group

mongodb

August 18, 2012
Tweet

More Decks by mongodb

Other Decks in Technology

Transcript

  1. 1
    Ben Becker,
    Software Engineer, 10gen
    [email protected]

    View Slide

  2. 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

    View Slide

  3. 3
    2.2 - rc0 released on 7/19
    2.2 - rc1 released today!
    2.2 - out soon!

    View Slide

  4. 4
    • Concurrency improvements
    – DB Level Locking
    – More yielding
    • Aggregation Framework
    • Tag aware sharding or geo-sharding
    • Read Preferences
    • TTL Collections
    • Shell enhancements
    • More…

    View Slide

  5. 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
    – Avoid holding write lock on disk access for updates also
    – Stats available as part of db.serverStatus()
    • db.serverStatus().recordStats
    • db.serverStatus().extra_info

    View Slide

  6. 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

    View Slide

  7. 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/

    View Slide

  8. 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

    View Slide

  9. 9

    View Slide

  10. 10
    • Consistent nomenclature across drivers and mongos
    • Modes
    – Primary (default), Primary_Preferred, Secondary,
    Secondary_Preferred, Nearest
    • Replica set tags
    – Read support for replica set tags

    View Slide

  11. 11
    • Auto expire data by setting a TTL
    • Use field in document to specify expiry.
    – db.log.events.ensureIndex({“expiryDate": 1}, {expireAfterSeconds: 3600})
    • Dedicated mongod thread 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

    View Slide

  12. 12
    • 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

    View Slide

  13. 13
    • 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

    View Slide

  14. 14

    View Slide

  15. 15
    • 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

    View Slide

  16. 16
    • 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

    View Slide

  17. 17

    View Slide

  18. 18
    • 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

    View Slide

  19. 19
    @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]

    View Slide