Why Choose Percona Server for MongoDB? Tyler Duzan Product Manager
Who Am I? My name is Tyler Duzan Formerly an operations engineer for more than 12 years focused on security and automation Now a Product Manager at Percona Have been using MongoDB in production for 5 years 2
Outline 3 Bio & Outline Percona Server for MongoDB Overview Using Percona Server for MongoDB Features Making the Choice Q&A
Percona Server for MongoDB Overview
What is Percona Server for MongoDB? First release in December 2015 Focused on performance and stability improvements layered on top of MongoDB Community Edition Addresses a need for deeper diagnostics and performance tuning capabilities Provides a place to develop new storage engines and strategies 5 Percona Memory Engine focused on high-performance reads with predictable latency MongoRocks focused on write-heavy workloads, supports LSM trees MongoDB Enterprise features available in an open-source release Expedited bug fixes for Percona Support customers and shared with the community
What is Percona Server for MongoDB? 6
Percona Server vs MongoDB Community Server Maintains drop-in compatibility with upstream Enhanced security capabilities LDAP Authentication Auditing Log Redaction New Storage Engines Percona Memory Engine MongoRocks Native Hot Backup Capability Works on both MongoRocks and Wired Tiger Integration with Percona Toolkit and PMM Enhanced Query Profiling 7
Using Percona Server for MongoDB Features
MongoRocks: RocksDB for MongoDB Different storage engines are not compatible with each others data files as they use different storage models Based on the RocksDB library from Facebook Uses LSM trees instead of B-Trees, optimized for write-heavy workloads Has native support for Snappy, LZ4, and Zlib compression to reduce storage requirements on disk To temporarily test the MongoRocks you can manually start MongoDB with the `--storageengine` command line flag and specify a new database path mongod --storageengine rocksdb --dbpath <newdatadir> For long term use, you can configure the storage engine in your MongoDB configuration file using the `storage.engine` configuration parameter 9
MongoRocks: RocksDB for MongoDB B-Tree: Data is stored on disk as chunks (pages/bau) and data is read and written to disk minimum one page at a time The tree has fewer levels than other patterns but search item involves comparisons at each level Optimizations: Minimize disk access Read and write in multiples of the page size 10
MongoRocks: RocksDB for MongoDB LSM-Tree: Writes are always fast regardless of data size, because it is append-only Reads must be serviced from memory or from disk Optimizations 11 Memtables help reduce reads to disk On-disk SSTable indexes are always loaded into memory All writes go directly to the Memtable indexes Reads check Memtable first, then SSTable indexes Compaction restructures on-disk SSTables to reduce disk usage and clean up tombstones
MongoRocks: RocksDB for MongoDB MongoRocks Pros vs Wired Tiger: Best space efficiency / Least disk usage Better write efficiency / Higher insert rate Better response times Additional compressions options That said: Wired Tiger is close, and has better read performance 12
Percona Memory Engine Different storage engines are not compatible with each others data files as they use different storage models Fully compatible with In-Memory Engine in MongoDB Enterprise To temporarily test the Percona Memory Engine you can manually start MongoDB with the `--storageengine` command line flag and specify a new database path mongod --storageengine inmemory --dbpath <newdatadir> For long term use, you can configure the storage engine in your MongoDB configuration file using the `storage.engine` configuration parameter Although Percona Memory Engine stores all data in memory, some diagnostics and statistics are still written to disk. 13
Percona Memory Engine Pros: Consistent latency on reads/writes While not as high-performance as something like Redis, it is significantly more performant than any on-disk database engine Allows full MongoDB query semantics in-memory Cons: No persistence to disk on the same node Requires specific architectural considerations if you need persistence 14
Percona Memory Engine Architectural Considerations You can mix/match different storage engines within the same ReplSet Percona Memory Engine utilizes shared internals with Wired Tiger, so blends best with it Usage examples For read-heavy workloads you can have Wired Tiger primary with several Percona Memory Engine secondary nodes Can create in-memory shards for hot data and age it into a different persistent shard Session Management / Caching where persistence is not a requirement 15
Importing Existing Data to New Engines For both MongoRocks and Percona Memory Engine you can migrate existing MongoDB data. For stand-alone instances: First dump your existing data Stop MongoDB and edit your configuration to set the new storage engine Delete the contents of the existing data directory Start MongoDB with the new configuration Finally, import your data from the dump 16 mongodump --out <dumpdir> mongorestore <dumpdir>
Importing Existing Data to New Engines For Replica Sets Change the engine in the configuration file on a secondary Example: storage.engine: rocksdb Remove/move dbpath contents Restart MongoDB on the node, when no longer lagged repeat on next secondary You can also run different engines on different members of a Replica Set if you are wanting to just test that engine. 17
Backup Improvements Hot Backup for both Wired Tiger and MongoRocks Example: admindb.runcommand( { createbackup: 1, backupdir: /my/backup/data/path } ) Hot backups run while other activity continues without impediment Significantly reduces recovery time as it s only requires the time to copy the hot backup into place Percona Labs also has a cluster-aware consistent backup tool for MongoDB being developed in the open on Github that s quite feature-filled 18
Query Profiling Rate Limit Query profiling can have a significant performance overhead in the default implementation Percona Server for MongoDB implements the ability to set a rate limit For example to profile all operations only for queries which are slower than 200ms and every 100th fast query, you would do the following: mongod --profile 2 --slowms 200 --ratelimit 100 Integrates with Percona Toolkit using the pt-mongodb-query-digest tool Is a useful tool for the administrator to understand the reasons why a query may have performance problems 19
Query Profiling w/ QAN QAN for MongoDB announced during the morning keynote on September 26th, 2017 Uses data gathered from query profiler to feed into PMM exporters Allows you to graph query metrics and gain a deeper understanding of the performance profile of your applications on MongoDB Expands PMM management capabilities for MongoDB 20
Auditing mongod --auditdestination=file --auditformat=json Fully compatible with auditing capabilities in MongoDB Enterprise Track and log user activity on the server: Auth-related operations (user and role management, login, logout, shutdown) Replication/Sharding re-configuration operations Failures on regular operations (reads, writes, schema updates, cursor operations) Supports multiple destinations: file, console, syslog Supports multiple output formats: BSON and JSON Assists administrators in enforcing organizational controls for compliance 21
Making the Choice
Evaluating Your Use Case Do you need a supported platform with modern security features? Percona Server for MongoDB provides auditing, log redaction, and LDAP authentication without requiring any licensing costs Are you concerned with write-heavy workloads in your MongoDB environment such as data aggregation? MongoRocks provides significant performance improvements over Wired Tiger in write-heavy workloads and is built-in to Percona Server for MongoDB Do you need to utilize MongoDB for providing caching layers, session management, or providing real-time analytics? Using the Percona Memory Engine provides consistent latency for read-intensive workloads 23
Open Source is About Choice 24 Percona is committed to supporting MongoDB in all of its flavors for our customers, whether you run MongoDB Community Edition, MongoDB Enterprise Edition, or Percona Server for MongoDB. Open source software is about choice, pick what is right for your use case whether that s Percona Server for MongoDB or something else We will continue to expand the datastore families we provide services and software for over time. With support for MySQL, MariaDB, and MongoDB, Percona provides unbiased care for customers running open-source databases
Questions?
Thank You Sponsors! 26
SAVE THE DATE! April 23-25, 2018 Santa Clara Convention Center CALL FOR PAPERS OPENING SOON! 27 www.perconalive.com