A replica set is the concrete implementation of the larger topic of replication. Replication is the process of creating copies of a dataset. Each replica set consists of a primary and one or more secondaries. The recommended minimum is three mongod instances: one primary and two secondaries.
As you can see from the following diagram, the application client (for example, a Python application using the PyMongo client) conducts queries (reads) and saves data (writes) to the MongoDB database without being aware that a replica set is involved:
The read and write requests are by default accepted by the primary. Confirmation of availability between members of the replica set is maintained by the equivalent of a TCP/IP ping, referred to in the MongoDB documentation as a heartbeat. The primary maintains a log of performed operations called the operations log (oplog), which is shared between replica set members. The process of synchronization involves...