# Replication & Replica Sets — MongoDB

Source: https://www.geekswithgeeks.com/en/mongodb/mongo-replication

> Keep copies of data for high availability and redundancy.

## What is a replica set?

A **replica set** is a group of `mongod` servers holding the same data — one **primary** takes writes, and **secondaries** copy them.

## Why replicate?

It gives **high availability** (a secondary is promoted automatically if the primary fails), **redundancy**, and optionally lets reads scale across secondaries.

## Writes go to the primary

By default all writes target the primary node — reading from secondaries can return slightly stale data due to replication lag.
