Glossary

Replica Set (MongoDB)

MongoDB’s unit of redundancy: one primary, two or more secondaries, and an election when the primary disappears. The configuration every production MongoDB runs, and the one that unlocks transactions and change streams.

General definition

Replica Set (MongoDB) is the name for a group of MongoDB servers, typically three, that keep identical copies of the data. One member is the primary and receives all writes; it records each change in its oplog, and the secondaries apply that log continuously to stay in sync. If the primary stops responding, the remaining members hold an election and promote a secondary, typically within fifteen seconds, and clients reconnect to the new primary through the driver without application changes.

The moving parts that matter when you run one:

  • Elections need a majority of voting members, which is why three is the minimum sensible size: with two, losing either one leaves no majority and the set stops accepting writes. An arbiter votes but holds no data and is a budget option, not a recommendation
  • Write concern controls durability. w: majority, the default since MongoDB 5.0, acknowledges a write only once most members have it, so a failover cannot roll it back
  • Read preference lets reporting or search traffic read from secondaries, accepting slightly stale data in exchange for spreading load
  • Priority and hidden members shape which nodes can become primary and which exist only for backups or analytics

A replica set is also a feature switch. Multi-document transactions and change streams, which many applications use for event-driven updates, require a replica set even on one node, so a single-member set is the normal development configuration and a three-member set the normal production one. Members can sit in different availability zones for high availability, and a member in a second region with a delayed or priority-zero role gives a warm copy for disaster recovery. Replication is not a backup: a bad delete replicates too, so a backup policy with point-in-time restore still belongs next to it.

Replication copies the whole dataset to every member; it adds safety and read capacity, not write capacity. When one primary can no longer absorb the write load or the data outgrows one machine, sharding splits the data across several replica sets, each of which stays replicated in the same way.

In the Ethora ecosystem

Ethora’s API stores apps, users, chats and the message archive in MongoDB, and both self-install routes start it as a replica set from the first boot: in the Docker Compose bundle a one-shot mongo-init step initialises the set, and the Helm chart runs MongoDB as a StatefulSet configured as a single-node replica set. That is why transactions and change streams work on a one-server install, and why moving to a redundant database later is a configuration change rather than a migration.

For production the chart offers the route most platform teams prefer: its external-databases values switch the bundled MongoDB off and point the API at a managed three-member replica set from your cloud provider or one run by your own team, with MySQL (for ejabberd), Redis and S3-compatible storage treated the same way. A dedicated server run by Ethora TechOps in your cloud account comes with this layout designed for your availability target.

Get started

Enterprise reliability, self-hosted or managed

Ethora offers SLAs, high availability and dedicated deployments for teams that need guarantees. Talk to our team.

Start Free
Free tier available Enterprise SLA No vendor lock-in