MMS • Raul Salas
Mongodb Replication and Fault Tolerance
There is a lot of confusion on when Mongodb Replication and Fault Tolerance solution is appropriate as well as what Replication is as well as what it is not. In this blogpost, we will take a closer look into Mongodb Replication.
What it is
Mongodb (Mongodb.com) replication provides Fault Tolerance. Fault tolerance is the property that enables a system to continue operating properly. In the event of the failure of (or one or more faults within) some of its components the ability of maintaining functionality when portions of a system break down is referred to as graceful degradation.
Mongodb Replication provide the ability to bring down a server for Maintenance. Tasks like Operating System patching, Mongodb patching, or replace hardware without taking a database outage.
Mongodb Replication provides the ability to perform other tasks on the Secondary hosts such as backups and redirected reads.
What it is not…
Mongodb replication is not a load balancer where writes can be balanced across multiple hosts.
Mongodb replication is not sharding aka Horizontal scaling. (That question has come up!)
So, let’s dive into the details of issues to consider when deploying a Replication High Availability solutions.
- Your business requires some level of fault tolerance. For example, an online store will suffer a significant financial loss if the database becomes unavailable for any amount of time.
- Typical reasons for outages are as follows: patching, hardware failure, network failure, and data center outage.
- You cannot have 2 masters, Mongodb provides a master – slave replication, where all writes occur on one host and are replicated to the other read only secondary hosts.
The next consideration is what level of fault tolerance your business requires. There are differing levels of fault tolerance as listed below:
|Number of Members||Majority Required to Elect a New Primary||Fault Tolerance|
The question is what is right fault tolerance configuration for your organization? The answer is a mix of budget and business considerations.
In order to achieve a Mongodb Replication and Fault Tolerance of 1, you will need a minimum of three hosts. So, if one host goes offline, there are still two other hosts to elect a primary.
In order to achieve a Mongodb Replication and Fault Tolerance of 2, you will need 5 hosts. This requires two additional hosts and duplicate storage for each host. This can drive up expenses quickly and You will need to financially justify the need. In addition, tolerance for data loss as well as downtime will need to be analyzed.
Financial applications, such as shopping carts for an online merchant would best be suited for fault tolerance of 2 as any data loss or downtime will result in a significant financial loss.
For most use cases, such as cache for a mobile app that allows customers to locate a doctor in the health plan or review their health coverage, a fault tolerance of 1 will be sufficient.
As you can see, Mongodb Replication and Fault Tolerance is a powerful method to ensure uptime and availability of your Mongodb hosted application.
Author: Raul Salas www.mobilemonitoringsolutions.com