What is the use case for a replica set?
MongoDB offers most of the advantages of using a replica set, some of which are listed as follows:
- Protection from data loss
- High availability of data
- Disaster recovery
- Avoidance of downtime for maintenance
- Scaling reads since we can read from multiple servers
- Helping to design for geographically dispersed services
- Data privacy
The most notable item that’s missing from the list is scaling writes. This is because, in MongoDB, we can only have one primary, and only this primary can take writes from our application server.
When we want to scale write performance, we typically design and implement sharding, which will be the topic of the following chapter. Two interesting properties of the way that MongoDB replication is implemented are geographically dispersed services and data privacy.
It is not uncommon for our application servers to be located in multiple data centers across the globe. Using...