Skip to main content

What do secondary nodes do?

Secondary nodes are Replica Set nodes that hold a copy of Primary's data and constantly synchronize with it, reading operations from the oplog. They don't accept writes directly, but play important roles for performance and fault tolerance.

Secondary's main tasks

  1. Replicate data from Primary Secondaries read the operations log (oplog) and apply it on themselves, keeping an identical state. That's what keeps the cluster consistent.
  2. Take over from Primary on failure If Primary fails, Secondaries take part in an election, and one of them becomes the new Primary. That's what gives auto-failover and high database availability.
  3. Handle read operations (optionally) If readPreference is set (e.g. to secondary), some read requests can be pointed at Secondary. That takes load off Primary and increases throughput under heavy load.

What this all adds up to

Secondary nodes:

  • hold a real-time backup copy
  • provide fault tolerance
  • can scale reads
  • take part in electing a new Primary

Summary

Secondary nodes are the "backup and reading" nodes of a Replica Set, keeping an up-to-date copy of the data, ready to replace Primary if it goes down, and able to take on read load.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.