In MongoDB, which feature is particularly useful for ensuring data…
2023
In MongoDB, which feature is particularly useful for ensuring data availability and reliability in case of hardware failure or network issues?
- A.
Sharding
- B.
Indexing
- C.
Replication
- D.
Aggregation
- E.
Caching
Attempted by 11 students.
Show answer & explanation
Correct answer: C
Concept
High availability and reliability in a database mean the data stays accessible and intact even when a server crashes or the network breaks. The technique that achieves this is replication: keeping multiple synchronized copies of the same data on separate servers, so that if one copy becomes unreachable, another can continue serving the data with little or no loss.
Application
In MongoDB, replication is implemented through a replica set, a group of mongod instances that hold the same data set:
One member acts as the primary and receives all writes.
The other members are secondaries that asynchronously copy the primary's oplog and apply the same operations, so each holds a full copy of the data.
If the primary fails due to hardware or network issues, the remaining members hold an automatic election and promote a secondary to primary, so the database keeps serving requests.
This redundancy together with automatic failover is what makes the data highly available and resilient during a failure; with a majority write concern, acknowledged writes survive a primary outage as well.
Contrast
Sharding distributes data across machines to scale horizontally and handle large volumes; it addresses capacity and throughput, not survival of a node failure on its own.
Indexing builds data structures that speed up query lookups; it improves read performance, not fault tolerance.
Aggregation processes and transforms data through a pipeline to compute results; it is a query/analytics tool, unrelated to availability.
Caching keeps frequently used data in fast memory to reduce latency; it improves speed but does not protect the stored data when a server goes down.