Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does every server in a MongoDB replica set need to have exactly the same RAM?

Can I set up a replica set in MongoDB 1.8 using servers with different amounts of RAM?

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

If yes, what are the pros and cons?

like image 726
Seamus Abshere Avatar asked May 12 '11 22:05

Seamus Abshere


People also ask

How much RAM do I need for MongoDB server?

MongoDB requires approximately 1 GB of RAM per 100.000 assets. If the system has to start swapping memory to disk, this will have a severely negative impact on performance and should be avoided.

How does replica set work in MongoDB?

MongoDB achieves replication by the use of replica set. A replica set is a group of mongod instances that host the same data set. In a replica, one node is primary node that receives all write operations. All other instances, such as secondaries, apply operations from the primary so that they have the same data set.

What is true about replication in MongoDB?

What is MongoDB Replication? In simple terms, MongoDB replication is the process of creating a copy of the same data set in more than one MongoDB server. This can be achieved by using a Replica Set. A replica set is a group of MongoDB instances that maintain the same data set and pertain to any mongod process.

What is the default minimum number of nodes in an atlas replica set?

MongoDB Atlas replica sets have a minimum of 3 nodes and can be configured to have a maximum of 50 nodes.


1 Answers

No, you do not need equal RAM. (Yes, you could set up a replica set as described.)

MongoDB uses memory-mapped files for all caching, which means that cache paging is handled by the operating system. The replicas with more memory will keep more of the database in memory; those with less will page more to disk.

MongoDB will eventually bring the entire database into memory if it can. If you're using two replicas for reads and one for writes, you might want to use the 5gb and 4gb machines for reads, so they are more likely to be hitting RAM.

like image 115
Paul Rosania Avatar answered Nov 15 '22 10:11

Paul Rosania