MongoDB: Replica Set – master vs. slave

mongodbreplication

We think about moving from a master-slaves to MongoDB with replica-set.
Now I wonder if MongoDB replicas are also set up like read-only slaves or if each mongos is able to write and sync the others like a master-master farm?

This might reduce the single source of error (master down) and also balance the write-load for scaling with best performance (not only for read, but also write…).

Best Answer

A replica set can only have one primary at any particular time (one master) with the other nodes being secondaries (slaves) and so they are nothing like master-master (i.e. multi-master) replication.

You definitely should move to a replica set from master/slave configuration because that is the preferred and recommended way to replicate. From MongoDB docs: "replica sets are a functional superset of master/slave, and newer, more robust code".

When a primary fails, one of the secondaries will be automatically elected as a new primary (you can see the docs to see the details of how that happens).

You cannot get write balancing from having a replica set - you can only distribute writes by sharding in MongoDB.