Replication Strategy

There are a few things to think about when you are determining how to deploy a MongoDB replica set. The following sections discuss a few of the different factors you should consider before implementing a MongoDB replica set.

Number of Servers

You need to consider how many servers to include in a replica set. The number you use depends on the nature of data interaction from clients. If the data from clients is mostly writes, then you are not going to get a big benefit from having a large number of servers. However, if your data is mostly static and you have a large number of read requests, then having more secondary servers will definitely make a difference.

Number of Replica Sets

You should also consider the data. In some instances, it makes more sense to break data up into multiple replica sets, each containing a different segment of the data. This allows you to fine-tune the servers in each set to meet the data and performance needs. You should consider this only if the there is no correlation between the data such that the clients accessing the data would rarely need to connect to both replica sets at the same time.

Fault Tolerance

How important is fault tolerance to your application? It will likely be rare for your primary server to go down. If your primary server being down doesn’t really affect your application too much and the data can easily be rebuilt, you may not need replication. However, if you promise your customer seven-9s availability, then any outage is extremely bad, and extended outage is unacceptable. In such cases, it makes more sense to add servers to the replica set to ensure availability.

You might also consider placing one of the secondary servers in an alternative data center for support in instances when your entire data center fails. However, for performance’s sake, you should keep the majority of your secondary servers in your primary data center.


Note

If you are concerned about fault tolerance, you should also enable journaling, as described in Chapter 12. When you do this, transactions can be replayed even if the power fails in your data center.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.235.63