Should each server in the MongoDB replica set have exactly the same RAM?

Is it possible to configure a replica set in MongoDB 1.8 using servers with different amounts of RAM?

  • server1: 5gb
  • server2: 2gb
  • server3: 4gb

If so, what are the pros and cons?

+6
source share
2 answers

No, you do not need equal RAM. (Yes, you can customize the replica set as described.)

MongoDB uses memory-mapped files for all caching, which means that the caching operating system is being processed by the operating system. Replicas with more memory will store most of the database in memory; those with less will be larger on disk.

MongoDB will eventually dump the entire database, if possible. If you use two copies for reading and one for writing, you can use 5gb and 4gb machines for reading, so they are likely to beat RAM.

+4
source

Yes, you can configure the replica this way.

If so, what are the pros and cons?

Here's a doc explaining the basic functions of replica sets. Let's take a look at them taking into account the differences in RAM.

Pros:

  • More computers mean better data backup . Having a 2GB node at least means that you have another copy of the data.
  • Having 3 complete nodes in a replica set simplifies one maintenance .

Minuses:

  • The presence of servers of different sizes is not suitable for automatic failover . Let's say that your 5 GB server is the main one. What happens when it goes down and the 2 GB server wins the election? You still have an automatic crash, but your performance probably dropped sharply.
  • Reading scaling may not work very well. Depending on your read patterns, sending reads to a 2 GB server can result in many additional disk accesses and lower performance.

So, the big problem here is indeed one of the characteristics. If you just do this to install dev, then this will basically work. But in production, you run the risk of fully charging your application. If your application is used to run on 4 GB + RAM, and then suddenly drops to 2 GB, it may become unusable.

Most production plants want to switch to another computer with the same power.

+2
source

Source: https://habr.com/ru/post/887979/


All Articles