...

/

Data Replication

Data Replication

Understand the models through which data is replicated across several nodes.

Data is an asset for an organization because it drives the whole business. Data provides critical business insights into what is important and what needs to be changed. Organizations also need to securely save and serve their clients’ data on demand. Timely access to the required data under varying conditions (increasing reads and writes, disks and node failures, network and power outages, etc.) is required to successfully run an online business.

We need the following characteristics from our data store:

  1. Availability under faults (failure of some disk, nodes, and network and power outages)
  2. Scalability (with increasing reads, writes, and other operations)
  3. Performance (low latency and high throughput for the clients)

Achieving the above characteristics is challenging (or even impossible) on a single node.

Replication

Replication refers to keeping multiple copies of the data at various nodes (preferably, geographically distributed) to achieve availability, scalability, and performance. In this lesson, we assume that a single node is enough to hold our entire data. We will remove this assumption while discussing the partitioning of data in multiple nodes. Often the concepts of replication and partitioning go together.

However, with many benefits like availability, replication comes with its complexities. Replication is relatively simple if the replicated data does not require frequent changes. The main problem in replication arises when we have to maintain changes in the replicated data over time.

Additional complexities that could arise due to replication are as follows:

  1. How to keep multiple copies of data consistent with each other?
  2. How to deal with failed replica nodes?
  3. Should we replicate synchronously or asynchronously?
    • How to deal with replication lag in case of asynchronous replication?
  4. How do we handle concurrent writes?
  5. What consistency model needs to be exposed to the end programmers?

We will explore the answer to these questions in this lesson.

Before we explain the different types of replication, let’s understand the Synchronous and Asynchronous approaches of replication.

Synchronous vs. asynchronous replication

There are two ways to disseminate changes to the replica nodes, i.e., synchronous and asynchronous. In synchronous replication, the primary node waits for acknowledgments from secondary nodes about updating the data. After receiving acknowledgment from all secondary nodes, the primary node reports success to the client. Whereas in asynchronous replication, the primary node does not wait for the acknowledgment from the secondary nodes and reports success to the client after just updating itself.

The advantage of synchronous replication is that all the secondary nodes will be completely up to date with the primary node. However, there is a disadvantage to this approach. If one of the secondary nodes does not acknowledge due to failure or fault in the network, the primary node would be unable to ...

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy