53
Best Practices for Upgrading to MongoDB 3.2 Richard Kreuter MongoDB

Webinar: Best Practices for Upgrading to MongoDB 3.2

Embed Size (px)

Citation preview

Page 1: Webinar: Best Practices for Upgrading to MongoDB 3.2

Best Practices for Upgrading to MongoDB 3.2

Richard Kreuter MongoDB

Page 2: Webinar: Best Practices for Upgrading to MongoDB 3.2

• Upgrading the database itself is pretty easy.• Upgrading all the bits around the database is…

less easy.• The effort is worth it.

• We can help you.

Page 3: Webinar: Best Practices for Upgrading to MongoDB 3.2

What’s cool in 3.2

Page 4: Webinar: Best Practices for Upgrading to MongoDB 3.2

More use cases. Pluggable storage engines enables you to use MongoDB in more

projects with the same core database.

Mission-critical apps. MongoDB delivers major advances in the critical areas of

governance, high availability, and disaster recovery.

New tools for new users. Now MongoDB is an integral part of the tooling and

workflows of Data Analysts, DBAs, and Operations teams.

3.2 Overview

Page 5: Webinar: Best Practices for Upgrading to MongoDB 3.2

Document Validation

What you get • Implement data governance • Enforce data quality• Use familiar MongoDB queries to specify validation rules

More power to the DBAs • The DBA can specify which documents in a collection should be validated

– Pre-existing documents can be left unvalidated, optionally.• Validation failure consequences are tunable

• Hard error• Just a warning

Page 6: Webinar: Best Practices for Upgrading to MongoDB 3.2

Document Validation Example

The example on the left adds a rule to the

contacts collection that validates:

• The year of birth is no later than 1994

• The document contains a phone number and / or

an email address

• When present, the phone number and email

addresses are strings

Page 7: Webinar: Best Practices for Upgrading to MongoDB 3.2

Partial Indexes

{"_id" : 1234,"archived" : "true"... }

A partial index canignore all documentswhere ignoredis true.

Page 8: Webinar: Best Practices for Upgrading to MongoDB 3.2

$lookup Join

What you get • Equivalent to left outer join• Built into aggregation framework

$lookup: { localField : "stock", foreignField : "stockQuote", from : "other_collection", as : "joined_stock" }

Page 9: Webinar: Best Practices for Upgrading to MongoDB 3.2

Distributed Database Enhancements

Page 10: Webinar: Best Practices for Upgrading to MongoDB 3.2

Faster Failover for Replica Sets

• Enhanced algorithm detects failure and isolation of primary.• Clusters more resilient to overloaded or unreliable networks

What you get • <2 seconds failover (tunable with the electionTimeoutMillis)

How to upgrade:• Conceptually:

– cfg=rs.conf()– cfg.protocolVersion=1– rs.reconfig(cfg)

Page 11: Webinar: Best Practices for Upgrading to MongoDB 3.2

Config Servers as Replica Sets

Overview• Config server replica sets can span more than 3 data centers with up to 50 replica set

members supported

What you get • Simplified sharded deployments

– Config servers are deployed as replica sets• Improved metadata consistency • Easily scale to many data centers How to upgrade• New clusters only, or a cluster reboot (for now)

Page 12: Webinar: Best Practices for Upgrading to MongoDB 3.2

Storage Engines

Page 13: Webinar: Best Practices for Upgrading to MongoDB 3.2

Storage Engine Architecture in 3.2

Content Repo

IoT Sensor Backend Ad Service Customer

Analytics Archive

MongoDB Query Language (MQL) + Native Drivers

MongoDB Document Data Model

WT MMAP

Available for MongoDB 3.2

Man

agem

ent

Sec

urity

In-memory (beta) Encrypted 3rd party

Page 14: Webinar: Best Practices for Upgrading to MongoDB 3.2

WiredTiger is the Default

What you get • Best general-purpose storage engine• 7-10x better throughput• Up to 80% compression

“Out of the box” • No special configuration needed

Page 15: Webinar: Best Practices for Upgrading to MongoDB 3.2

7x-10x Performance, 50%-80% Less Storage

How: WiredTiger Storage Engine• Same data model, same query

language, same ops• Write performance gains driven

by document-level concurrency control

• Storage savings driven by native compression

• 100% backwards compatible• Non-disruptive upgrade

MongoDB 3.0MongoDB 2.6

Performance

Page 16: Webinar: Best Practices for Upgrading to MongoDB 3.2

50%-80% Less Storage via Compression

• Better storage utilization• Higher I/O scalability• Multiple compression options

– Snappy– zlib– None

• Data and journal compressed on disk• Indexes compressed on disk and in memory

Page 17: Webinar: Best Practices for Upgrading to MongoDB 3.2

Compression in action

Page 18: Webinar: Best Practices for Upgrading to MongoDB 3.2

Encrypted Storage

What you get • Encryption of sensitive data for regulated industries• ~ 15% overhead

• Better than many 3rd party encryption tools

Note• Based on the WiredTiger Storage Engine • Available in MongoDB Enterprise Advanced

How to upgrade• Rolling upgrade

Page 19: Webinar: Best Practices for Upgrading to MongoDB 3.2

In-Memory Storage

• Predictable throughput and latency• In-memory computing without trading away guarantees of disk-based

databases like – Rich query flexibility – Real-time analytics– Scalable capacity – Durability

• Durability via replica set secondaries (using mmap/wt)

Page 20: Webinar: Best Practices for Upgrading to MongoDB 3.2

One Deployment Powering Multiple Apps

Page 21: Webinar: Best Practices for Upgrading to MongoDB 3.2

New Tools for New Users

Page 22: Webinar: Best Practices for Upgrading to MongoDB 3.2

Data Analysts• BI Connector• $lookup

• Aggregation Enhancements: Faster & simpler real-time analytics

Page 23: Webinar: Best Practices for Upgrading to MongoDB 3.2

DBAsMongoDB Compass

• Visualize schema• View Documents• Graphically build queries• Authenticated access

Page 24: Webinar: Best Practices for Upgrading to MongoDB 3.2

OperationsIntegration with standard operational workflow reduces overhead• Start from global view of infrastructure: APM tools

integration, e.g. New Relic, AppDynamics.• Then, drill down: Profiler visualization in Ops Manager • Then, deploy: Automated index builds• Next, refine: Partial Indexes improve resource utilization

Page 25: Webinar: Best Practices for Upgrading to MongoDB 3.2

Ops Manager & Cloud Manager

Page 26: Webinar: Best Practices for Upgrading to MongoDB 3.2

Single-click provisioning, scaling & upgrades, admin tasks

Monitoring, with charts, dashboards and alerts on 100+ metrics

Backup and restore, with point-in-time recovery, support for sharded clusters

MongoDB Ops Manager / Cloud Manager

The Best Way to Manage MongoDB In Your Data CenterUp to 95% Reduction in Operational Overhead

Page 27: Webinar: Best Practices for Upgrading to MongoDB 3.2

How Ops Manager / Cloud Manager Helps You

Scale EasilyMeet SLAs

Best Practices, Automated

Cut Management Overhead

Page 28: Webinar: Best Practices for Upgrading to MongoDB 3.2

Query Perf. Visualizations & Optimization

Fast and simple query optimization with the

new Visual Query Profiler

• Query and write latency are consolidated and

displayed visually; your ops teams can easily

identify slower queries and latency spikes

• Visual query profiler analyzes the data it

displays and provides recommendations for

new indexes that can be created to improve

query performance

• Ops Manager and Cloud Manager can automate

the rollout of new indexes, reducing risk and

your team’s operational overhead

Page 29: Webinar: Best Practices for Upgrading to MongoDB 3.2

Ops Manager Backup Enhancements3.2 includes Ops Manager enhancements to improve

the productivity of your ops teams and further

simplify installation and management

• MongoDB backup on standard network-mountable filesystems;

integrates with your existing storage infrastructure

• Automated database restores; Build clusters from backup in a few

clicks

• Faster time to first database snapshot

• Support for maintenance windows

• Centralized UI for installation and config of all application and

backup components

Page 30: Webinar: Best Practices for Upgrading to MongoDB 3.2

These new capabilities and enhancements are why it's worth

upgrading to MongoDB 3.2.

Page 31: Webinar: Best Practices for Upgrading to MongoDB 3.2

Upgrading MongoDB in Outline

• Manual upgrades – lots of steps, but doable• Automatic – Ops Manager / Cloud Manager

Page 32: Webinar: Best Practices for Upgrading to MongoDB 3.2

Manual Upgrade

Page 33: Webinar: Best Practices for Upgrading to MongoDB 3.2

Upgrading a cluster manually

• Follow the steps in the fine documentation:– http://docs.mongodb.org/manual/release-notes/3.2-upgrade/– First result if Googling for “MongoDB Upgrade”

• It's critical to note that upgrade order matters:– For replica sets, first upgrade the secondaries, then the primaries.– For a sharded cluster, follow the 7 steps in the documentation.

Page 34: Webinar: Best Practices for Upgrading to MongoDB 3.2

Automatic

Page 35: Webinar: Best Practices for Upgrading to MongoDB 3.2

Upgrading a cluster with Automation

• Ops Manager / Cloud Manager is the easiest, fastest, and best way to upgrade a MongoDB deployment– One-click upgrades.– Rolling upgrades, so zero downtime.

Page 36: Webinar: Best Practices for Upgrading to MongoDB 3.2

Upgrades

• Select Desired Version from Dropdown

Page 37: Webinar: Best Practices for Upgrading to MongoDB 3.2

As you can see, upgrading the database software itself is pretty easy.

Page 38: Webinar: Best Practices for Upgrading to MongoDB 3.2

The fine details

• Backward compatibility & your application• Backward compatibility & your operations• Database behavior & performance• Enabling 3.2 Features

Page 39: Webinar: Best Practices for Upgrading to MongoDB 3.2

Backward Compatibility

Page 40: Webinar: Best Practices for Upgrading to MongoDB 3.2

Backward Compatibility: App

• Comprehensive documentation about incompatible changes– https://docs.mongodb.org/manual/release-notes/3.2-compatibility

• Highlights– You may need to upgrade your applications' drivers before upgrading

MongoDB!– Some commands/methods deprecated, removed, changed.

• Audit your codebase for uses of deprecated functionality.

Page 41: Webinar: Best Practices for Upgrading to MongoDB 3.2

Backward Compatibility: Ops

• Comprehensive documentation about incompatible changes– https://docs.mongodb.org/manual/release-notes/3.2-compatibility

• Highlights– Some settings deprecated, others mmapv1-only.– Stricter replica set configuration validation– mongo* tools' options changed– Legacy (pre-2.6) user account model removed

• Audit scripts & other infrastructure you've got around.

Page 42: Webinar: Best Practices for Upgrading to MongoDB 3.2

Database Behavior & Performance

Page 43: Webinar: Best Practices for Upgrading to MongoDB 3.2

Database Behavior & Performance

• Always test your application with the new database version before upgrading production– Apps sometimes rely on unspecified behaviors (e.g. stability of results

from unsorted queries)– Query optimizer improvements may affect index selection (check

important queries with explain)

Page 44: Webinar: Best Practices for Upgrading to MongoDB 3.2

Good practice: Test against Staging

• Run all your performance correctness tests against a staging environment for some time before upgrading production.

• Best practice: run a real application workload against a 3.2 staging environment, too.– Replicate the workload manually– Use Facebook’s Flashback tool

Page 45: Webinar: Best Practices for Upgrading to MongoDB 3.2

In our experience, upgrading everything around the database software is where the work is.

Page 46: Webinar: Best Practices for Upgrading to MongoDB 3.2

Recap

Page 47: Webinar: Best Practices for Upgrading to MongoDB 3.2

Upgrading Revisited

• Plan• Practice• Productionize

Page 48: Webinar: Best Practices for Upgrading to MongoDB 3.2

Plan Your Upgrade

• Review the compatibility notes– Audit apps, ops for deprecated details

• Upgrade drivers, scripts, if necessary– Might require some recoding, in edge cases

• Make sure you've got good tests– App behavior, performance, etc.

• Write a checklist of upgrade steps for your environments

Page 49: Webinar: Best Practices for Upgrading to MongoDB 3.2

Practice Your Upgrade

• Upgrade apps & database in staging environment• Test, test, test.

– If no problems appear within (say) a week of continuous testing, probably a decent candidate.

Page 50: Webinar: Best Practices for Upgrading to MongoDB 3.2

Productionize Your Upgrade

• Upgrade apps & database in production environment– Ideally, during minimum load/traffic conditions, just for good measure

Page 51: Webinar: Best Practices for Upgrading to MongoDB 3.2

MongoDB's team can help you!

Page 52: Webinar: Best Practices for Upgrading to MongoDB 3.2

How we help users upgrade

• MongoDB's Professional Services team offers consulting engagements specifically for upgrading:– To ensure upward compatibility for your apps, tools– To assist with performance & behavior testing around database upgrades– To prepare & execute upgrade plans with your team in your environments.

Contact us for more info: http://mongodb.com/upgrade