Lesson 1: Zero Downtime Maintenance with a MongoDB Deployment / Learn

Video Transcript (English)

Maintenance is an inevitable part of any software system and MongoDB is no different. And with MongoDB, you don’t have to give up high availability when performing maintenance.

In this video, we’ll identify some scenarios where maintenance is required. We’ll also review how MongoDB performs maintenance without losing high availability for users.

Whether you are new or a veteran to the software world, you are probably familiar with maintenance to some degree. Often, companies send notifications to alert their users of planned downtime for maintenance.

Depending on your application, downtime of any kind can be quite costly.

In 2019, one of the most popular social media companies experienced 14 hours of unexpected downtime. It was estimated that they lost over 90 million dollars of revenue.

This is obviously an extreme case, but it puts the cost associated with downtime into perspective.

MongoDB minimizes downtime by leveraging replica sets to do rolling maintenance. A replica set remains operational even if a node is unavailable. We can use this behavior to our advantage when performing maintenance so that we don’t lose high availability.

Before we look at an example, let’s first identify some scenarios that require maintenance in MongoDB. These scenarios include: Upgrading to a new version of MongoDB, upgrading drivers, security updates to the operating system, changes to replica set membership, and upgrading operating systems.

We strongly recommend using an alternate environment for testing the maintenance procedures before applying them to production. Ideally, you should use an environment that closely mirrors the production environment.

Let’s go through an example of how rolling maintenance works with a replica set. We want to upgrade each database's operating system in this three-member replica set.

First, we do a graceful shutdown on one of the secondaries and then restart it with the upgraded operating system. Then we wait for it to start and catch up to the other members in the cluster.

Once the secondary is caught up, we repeat the same process for the other secondary.

Next, we step down the primary to elect a new primary, and upgrade the previous primary’s operating system. Once that’s complete, we’ll have this member restart, now as a secondary, so that it can catch up with the other members.

This may seem cumbersome and a bit intimidating, especially when users depend on your application.

The good news is that if you’re using Atlas, all of this is done for you automatically with rolling maintenance. All you have to do is a little planning and a few button clicks in the Atlas dashboard.

You can learn about this in the Atlas Upgrades and Maintenance unit.

Awesome job! In this video, you learned that MongoDB minimizes downtime by leveraging replica sets to perform rolling maintenance.

Scenarios that require maintenance in MongoDB include: Upgrading to a new version of MongoDB, upgrading drivers, security updates to the operating system, changes to replica set membership, and upgrading operating systems.

Finally, you learned that Atlas simplifies the process of rolling maintenance by automating it for us.