{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreiaeqv73up466b7hesdy23u6vcuaksnvyfiviyp255cdovwfyiw5tu",
    "uri": "at://did:plc:5sgu76a53rz3n6unbykmovqy/app.bsky.feed.post/3mloh7mebi2i2"
  },
  "description": "A replica set is MongoDB's name for a group of database nodes that maintain the same data and provide automatic failover. One node is the primary (accepts writes); the rest are secondaries that asynchronously apply the primary's operation log. If the primary becomes unreachable, the secondaries elect a new primary among themselves.\n\n\nHow it works\n\nWrites go to the primary, which records them in its operation log (oplog). Secondaries tail the oplog and apply the same operations locally, eventuall",
  "path": "/engineering-glossary/replica-set-database-replication/",
  "publishedAt": "2026-05-12T18:46:39.000Z",
  "site": "https://sahilkapoor.com",
  "tags": [
    "MongoDB",
    "Replication",
    "Sharding",
    "Distributed Systems",
    "Eventual Consistency"
  ],
  "textContent": "**A replica set** is MongoDB's name for a group of database nodes that maintain the same data and provide automatic failover. One node is the primary (accepts writes); the rest are secondaries that asynchronously apply the primary's operation log. If the primary becomes unreachable, the secondaries elect a new primary among themselves.\n\n## How it works\n\nWrites go to the primary, which records them in its operation log (`oplog`). Secondaries tail the oplog and apply the same operations locally, eventually matching the primary's state. Reads can be served from secondaries with explicit read preferences, trading freshness for read scaling.\n\n## Membership and elections\n\n  * **Primary.** Receives all writes; only one at a time.\n  * **Secondaries.** Replicate from the primary; can serve reads with appropriate read concern.\n  * **Arbiter.** Votes in elections but holds no data; used for odd member counts when adding another data-bearing node is unjustified.\n  * **Hidden, priority-0, delayed.** Special-purpose secondaries that never become primary, used for backups, analytics, or disaster recovery.\n\n\n\n## Read and write concerns\n\n  * **Write concern.** How many replicas must acknowledge a write before it returns. Higher values trade write latency for durability.\n  * **Read concern.** How recent the data being read must be: local, majority, linearizable. Stronger reads cost more.\n\n\n\nšŸ”—\n\n**Related Terms**\nMongoDB, Replication, Sharding, Distributed Systems, Eventual Consistency.",
  "title": "Replica Set",
  "updatedAt": "2026-05-13T19:14:34.852Z"
}