Chapter 20. Durability
Durability is a property of database systems that guarantees that write operations that have been committed to the database will survive permanently. For example, if a ticket reservation system reports that your concert seats have been booked, then your seats will remain booked even if some part of the reservation system crashes. For MongoDB, we need to consider durability at the cluster (or more specifically, replica set) level.
In this chapter, we will cover:
How MongoDB guarantees durability at the replica set member level through journaling
How MongoDB guarantees durability at the cluster level using write concern
How to configure your application and MongoDB cluster to give you the level of durability you need
How MongoDB guarantees durability at the cluster level using read concern
How to set the durability level for transactions in replica sets
Throughout this chapter, we will discuss durability in replica sets. A three-member replica set is the most basic cluster recommended for production applications. The discussion here applies to replica sets with more members and to sharded clusters.
Durability at the Member Level Through Journaling
To provide durability in the event of a server failure, MongoDB uses a write-ahead log (WAL) called the journal. A WAL is a commonly used technique for durability in database systems. The idea is that we simply write a representation of the changes to be made to the database to a durable medium (i.e., to disk) before applying ...