Monday, 30 November 2026

Understanding Data Replication: How Distributed Systems Achieve High Availability and Fault Tolerance

  

Modern applications cannot afford to depend on a single machine, database, or storage system. As applications grow, they need to serve users across different geographical locations, handle increasing traffic, and continue operating even when individual components fail.

 

One fundamental technique that makes this possible is replication.

 

Replication involves maintaining multiple copies of data, services, or computational processes across different machines. It helps distributed systems improve availability, fault tolerance, read performance, and disaster recovery.

 

However, maintaining multiple copies introduces an important challenge: ensuring that replicas remain consistent when updates happen concurrently, network communication is delayed, or individual nodes fail.

 

In this article, we will explore the fundamentals of replication, different replication architectures, how databases and storage systems implement replication, and the trade-offs involved in designing reliable distributed systems.

 

1. Introduction to Replication

 

1.1 What is Replication?

In distributed systems, replication refers to the process of maintaining multiple copies of the same data, services, or computational resources across different machines or locations.

 

Instead of relying on a single machine to store and serve all data, a system maintains replicas (copies) on multiple machines. These replicas work together to ensure that data remains accessible even when individual machines experience failures.

 

Consider an e-commerce application that stores customer information, product details, and order history in a database.

 

If the application uses only one database server, every read and write operation depends on that server. If the server becomes unavailable because of hardware failure, software issues, or network problems, the application may no longer be able to access its data.

 

Replication addresses this problem by maintaining copies of the database on multiple servers.

 

For example:

-       Database Server 1 acts as the primary database and handles write operations.

-       Database Server 2 maintains a copy of the data from Database Server 1.

-       Database Server 3 maintains another replica. 

When a customer places an order, the change is written to the primary database and subsequently propagated to the replica databases.

 

If the primary server fails, another replica can potentially take over its responsibilities, allowing the application to continue operating.

 

The important point is that replication is not simply about creating copies of data. It is about maintaining and coordinating those copies so that the system can continue providing reliable access to information.

 

In simple terms: Replication means keeping multiple copies of data or services across different machines so that the system does not depend entirely on a single component.

 

1.2 Why Do Distributed Systems Need Replication?

As applications grow, their infrastructure requirements change significantly.

 

A small application might initially operate with a single application server and a single database. This architecture can be sufficient when the number of users, transactions, and data volumes is relatively small.

 

However, consider an application that grows from a few thousand users to several million users.

 

It now needs to handle:

- Thousands of concurrent database requests.

- Increasing read and write workloads.

- Users accessing the application from different geographical locations.

- Hardware and software failures.

- Network interruptions.

- Continuous availability requirements.

 

A single machine may become a bottleneck or a single point of failure. Replication helps address these challenges by distributing copies of data across multiple machines.

 

Let's understand this with a practical example.

 

Scenario: An e-commerce application

Imagine an e-commerce platform serving customers across India, the United States, and Europe. The application maintains customer accounts, product catalogs, inventory information, and order details.

 

Initially, all data is stored in one database server located in a single data center.

 

As the application grows, several problems emerge:

-       Server failure: If the database server crashes, the entire application may lose access to its data.

-       Increasing read traffic: Millions of customers browsing products generate a large number of database read requests.

-       Geographical latency: Customers located far away from the database experience higher network latency.

-       Infrastructure failures: Power outages, network failures, or data center outages can interrupt application availability.

 

Instead of depending on one database server, the application can maintain replicas across multiple servers and geographical locations.

 

Now:

- One database handles primary write operations.

- Other database replicas serve read requests.

- Geographically distributed replicas serve users closer to their locations.

- Additional replicas provide backup infrastructure for handling failures.

 

This architecture improves the application's ability to handle traffic and recover from failures. Replication is therefore an important building block for designing scalable, highly available, and fault-tolerant distributed systems.

 

1.3 Replication Versus a Single-Node Architecture

To understand the importance of replication, let's compare a traditional single-node architecture with a replicated architecture.

 

Single-node architecture

In a single-node architecture:

- All application requests are handled by one database server.

- All data is stored in one location.

- Every read and write operation depends on that server.

- If the database server becomes unavailable, the application cannot access the database.

 

This architecture is relatively simple to build and operate. However, it introduces a single point of failure and limits the system's ability to distribute database workloads.

 

Replicated architecture

In a replicated architecture:

- Multiple database servers maintain copies of the same data.

- A primary server may handle writes.

- Replica servers can serve read requests.

- If the primary fails, an eligible replica can be promoted.

- Multiple locations can maintain copies of the data.

 


The following table summarizes the differences.

 

Characteristic

Single-node

Replicated

Data storage

One server

Multiple servers

Availability

Depends on one server

Can survive some failures

Read scalability

Limited by one server

Reads can be distributed

Fault tolerance

Limited

Improved

Geographic distribution

Limited

Supported

Operational complexity

Lower

Higher

Data consistency

Simpler

Requires coordination

 

Replication introduces additional infrastructure and operational complexity. However, for applications requiring high availability, scalability, and reliability, these benefits often justify the additional cost.

 

1.4 Key Benefits of Replication

Replication provides several important benefits to distributed systems.

 

1.4.1 High Availability

High availability refers to a system's ability to remain accessible and operational even when individual components fail.

 

Consider an application that depends on a single database server.

 

If that database server crashes, application requests that require database access may fail until the server is recovered. With replication, multiple database servers maintain copies of the data. If the primary database becomes unavailable, another eligible replica can be promoted to become the new primary.

 

For example:

-       Database Server A is the primary and handles all writes.

-       Database Server B continuously receives changes from Server A.

-       Server A experiences a hardware failure.

-       The database cluster detects that the primary is unavailable.

-       Server B is promoted to primary.

-       The application reconnects to Server B and resumes operations.

 

This process is known as failover. Failover can be automatic or manual, depending on the database architecture and infrastructure.

 

It is important to understand that replication alone does not guarantee high availability. The system also needs failure detection, failover mechanisms, connection management, and appropriate replica synchronization.

        

1.4.2 Fault Tolerance

Fault tolerance is the ability of a system to continue functioning despite failures in individual components.

 

Replication improves fault tolerance by eliminating complete dependence on a single copy of the data.

 

For example, imagine a database cluster with three nodes:

- Node A: Primary.

- Node B: Replica.

- Node C: Replica.

 

If Node B fails, Node A and Node C can continue operating.

 

If Node A fails, Node C may be promoted to primary, provided it has sufficiently up-to-date data and the cluster can safely establish a new leader.

 

The system can tolerate certain failures without losing access to all its data.

 

However, the number of failures a system can tolerate depends on its replication strategy, quorum configuration, synchronization method, and failure model.

 

Important distinction:

- High availability focuses on keeping the system accessible.

- Fault tolerance focuses on continuing operation despite component failures.

 

They are closely related, but they are not identical.   

                 

1.4.3 Improved Read Performance

Replication can improve read performance by distributing read requests across multiple database servers.

 

Consider an application where 90% of database operations are reads and only 10% are writes. If every request is sent to one database server, that server must handle the entire workload.

 

Instead, the application can use a primary-replica architecture.

 

For example:

- Write operations are directed to the primary database.

- Read operations are distributed across multiple replicas.

- Each replica handles a portion of the read workload.

 

Imagine an application receiving 10,000 database requests per second:

- 9,000 read requests.

- 1,000 write requests.

 

Instead of handling all 10,000 requests on one server, the system can distribute reads across multiple replicas. This reduces the read workload on the primary database and increases the overall read-serving capacity.

 

However, there is an important consideration: replicas may not immediately reflect the latest changes made on the primary database. This delay is called replication lag.

 

For example, a customer updates their profile on the primary database. If the application immediately reads from a replica that has not yet received the update, it may return the previous profile information.

 

Applications must account for this behavior when deciding where read requests should be routed.

                 

1.4.4 Geographic Distribution

Modern applications often serve users across multiple geographical regions.

 

If all database requests must travel to a database located in one region, users in distant locations may experience increased network latency.

 

Replication helps address this by maintaining database copies closer to users.

 

For example, an application may maintain:

- A primary database in India.

- A read replica in Europe.

- Another read replica in North America.

 

Users can read data from the replica closest to their geographical location. This reduces network round-trip time and improves application responsiveness.

 

Geographic replication is particularly useful for:

- Global e-commerce platforms

- Banking and financial applications

- Streaming services

- Social networking platforms

- Applications with globally distributed users

 

However, geographic distribution introduces additional challenges. Network latency between regions can affect replication speed. Synchronous replication across distant regions can significantly increase write latency, while asynchronous replication can introduce temporary differences between regional copies.

 

Another important consideration is data residency, certain regulations may require data to remain within specific geographical boundaries.

 

1.4.5 Disaster Recovery

Disaster recovery refers to the ability to restore systems and data following major infrastructure failures or unexpected disasters.

 

Examples include:

- Data center outages

- Natural disasters

- Storage system failures

- Large-scale infrastructure disruptions

- Accidental infrastructure damage

 

Replication can support disaster recovery by maintaining copies of data in geographically separate locations.

 

For example, consider an organization operating its primary database in one data center and maintaining a replica in another region.

 

If the primary data center becomes unavailable, the organization can recover operations using the secondary location.

 

Two important concepts are associated with disaster recovery:

 

Recovery Point Objective (RPO)

RPO defines how much data loss an organization can tolerate, measured in time.

 

For example, an RPO of five minutes means the organization aims to recover with no more than five minutes of data loss.

 

Recovery Time Objective (RTO)

RTO defines how long an organization can tolerate the system being unavailable.

 

For example, an RTO of 30 minutes means the organization aims to restore operations within 30 minutes of a failure.

 

The replication strategy directly influences these objectives.

- Synchronous replication can provide very low data loss under its configured failure assumptions.

- Asynchronous replication may lose recently committed changes if the primary site fails before those changes reach the replica.

 

Note: Replication is not a replacement for backups. If data is accidentally deleted or corrupted on the primary database, those changes may also propagate to replicas. Backups provide a way to recover historical data.        

1.5 Challenges of Maintaining Multiple Copies

Although replication provides several advantages, maintaining multiple copies of data introduces its own set of challenges.

 

The more replicas a system maintains, the more coordination is required to ensure that they behave correctly. Let's examine the major challenges.

 

1.5.1 Data Consistency

One of the biggest challenges is ensuring that multiple replicas maintain consistent copies of data. Consider a customer updating their account balance.

 

The update is first committed on the primary database. However, the change may take some time to reach the replicas.

 

During this interval:

- The primary database contains the updated balance

- Replica 1 may already contain the updated balance

- Replica 2 may still contain the previous balance

 

Different database servers may temporarily return different results for the same query. This is a consistency challenge.

 

Distributed databases use different consistency models and synchronization mechanisms to manage these differences.

 

1.5.2 Replication Lag

Replication lag refers to the delay between a change being committed on the primary database and that change becoming available on its replicas.

 

For example:

A user places an order.

The order is committed on the primary database.

The update is transmitted to the replicas.

One replica receives the update after 100 milliseconds.

Another replica receives it after 500 milliseconds.

 

During this period, a read request routed to a replica may return stale information.

 

Replication lag can be influenced by:

- Network latency

- Database workload

- Transaction volume

- Replica processing capacity

- Large transactions

- Infrastructure limitations

 

Applications need to consider replication lag when implementing read-after-write operations.

 

1.5.3 Conflict Resolution

Conflict resolution becomes particularly important in multi-leader replication architectures. Imagine two database nodes located in different regions.

 

A customer updates their shipping address through the application connected to Region A. At almost the same time, another update changes the same customer's address through Region B.

 

Both databases may accept their respective writes independently.

 

When the changes are synchronized, the system must determine which update should be retained or how the changes should be merged.

 

Possible strategies include:

- Last-write-wins.

- Version-based conflict detection.

- Application-specific conflict resolution.

- Merging concurrent updates.

 

The appropriate strategy depends on the application's business requirements.

 

1.5.4 Network Latency

Replication requires communication between database nodes.

 

When replicas are in different data centers or geographical regions, network communication introduces additional latency.

 

For synchronous replication, a write may need to wait until another replica acknowledges the change before the transaction is considered complete. This increases write latency.

 

Asynchronous replication avoids waiting for remote acknowledgements, improving write performance, but replicas may temporarily contain stale data.

 

Therefore, system architects must balance consistency requirements against network latency and application performance.

 

1.5.5 Infrastructure and Operational Complexity

Maintaining multiple database servers increases infrastructure and operational requirements.

 

Organizations need to manage:

- Additional compute and storage resources

- Replica monitoring and health checks

- Replication failures and recovery

- Automatic or manual failover

- Database synchronization

- Backup and recovery procedures

- Network connectivity between nodes

 

For example, a three-node database cluster is not simply three independent database servers. It requires mechanisms to coordinate membership, detect failures, manage replication, and prevent multiple nodes from incorrectly assuming they are the primary.

 

Replication improves system reliability, but it also makes distributed system design more complex.           

 

1.6 Summary

Replication is a fundamental technique used to build reliable distributed systems by maintaining multiple copies of data or computational resources across different machines.

 

It helps organizations achieve:

-       High availability: Applications can continue operating when individual nodes fail

-       Fault tolerance: Systems can withstand certain component failures

-       Improved read performance: Read requests can be distributed across multiple replicas

-       Geographic distribution: Data can be served closer to users

-       Disaster recovery: Organizations can recover operations using copies maintained in separate locations

 

However, replication also introduces challenges involving data consistency, replication lag, conflict resolution, network latency, and operational complexity.

 

The central design challenge is not simply creating multiple copies of data but ensuring that these copies remain sufficiently synchronized while meeting the application's performance and availability requirements.

 

In the next section, we will explore the fundamental replication concepts, including active and passive replication, primary-backup architectures, multi-primary replication, and how replication differs from load balancing and backup.        

        

Section 2: Understanding Replication Fundamentals

Before exploring database replication architectures and implementation strategies, it is important to understand the fundamental concepts behind replication.

 

Replication is not limited to databases. It is also used in distributed computing, storage systems, and fault-tolerant applications. Depending on what is being replicated and how the replicas coordinate with each other, replication can be implemented in different ways.

 

In this section, we will explore the different types of replication, how primary-backup and multi-primary architectures work, and how replication differs from load balancing and backup.     

 

2.1 Data Replication Versus Computation Replication

Replication in distributed systems can be broadly classified into two categories: data replication and computation replication.

 

Although both approaches involve maintaining multiple copies or executions of something, they solve different problems.

 

2.1.1 Data Replication

Data replication involves maintaining multiple copies of the same data across different storage devices or machines.

 

The objective is to ensure that data remains accessible even when individual storage components fail, while also improving read performance and supporting geographical distribution.

 

Consider an application that stores customer information in a database. Instead of maintaining customer records on a single database server, the system maintains copies across multiple servers.

 

For example:

-       Database Server A stores the primary copy of customer records.

-       Database Server B maintains a replica of the same records.

-       Database Server C maintains another replica.

 

When a customer updates their profile, the change is propagated to the other database servers. The replicas can subsequently serve read requests or take over if another server becomes unavailable, depending on the replication architecture.

 

Common use cases:

-       Database replication

-       Distributed caches

-       Distributed file systems

-       Object storage systems

-       Geographic data distribution

 

2.1.2 Computation Replication

Computation replication involves executing the same computational task multiple times to improve fault tolerance or ensure reliable execution.

 

Unlike data replication, where multiple copies of information are maintained, computation replication focuses on executing the same operation across multiple computing resources or at different points in time.

 

Computation replication can be classified into two approaches.

 

a. Spatial replication

Spatial replication involves executing the same computation simultaneously on multiple machines.

 

For example, imagine a critical financial transaction validation service. Instead of relying on a single server to perform the validation, the same input is processed by multiple independent servers.

 

Commercial jets like the Boeing 777 and rockets like SpaceX's Falcon 9 run three or four independent flight computers in parallel. Every computer reads the exact same sensor data (altitude, airspeed, tilt) and calculates wing-flap or thruster adjustments simultaneously. A hardware voter compares the outputs—if one computer crashes or suffers a bit-flip from radiation, the system instantly follows the majority result without losing a millisecond of control.

 

In spatial replication model, If one server fails while processing the request, another server may still complete the computation.

 

This approach is useful in systems where reliability is more important than the cost of additional computing resources.

 

b. Temporal replication

Temporal replication involves executing the same computation repeatedly on the same machine at different points in time.

 

For example, a system may periodically execute the same validation operation to verify that a critical result remains correct.

 

Another example is retrying an operation when a temporary failure occurs. However, retries alone do not necessarily provide fault tolerance. The operation must be safe to repeat, or the system must use mechanisms such as idempotency keys to avoid unintended duplicate effects.

 

Data replication protects access to information by maintaining multiple copies, whereas computation replication improves the reliability of processing by executing the same task multiple times.

 

2.2 Active Replication Versus Passive Replication

Another important classification of replication is based on how requests are processed and how replica states are maintained.

 

There are two fundamental approaches:

-       Active replication.

-       Passive replication.

 

2.2.1 Active Replication

In active replication, the same request is processed independently by all replicas. Each replica receives the request, executes the operation, and updates its local state.

 

Consider an application maintaining three replicas of a service.

 

When a client sends an update request:

-       The request is distributed to all three replicas

-       Each replica executes the same operation

-       Each replica updates its local state

-       The system ensures that replicas process requests in an equivalent order so that their states remain consistent

 

For example, consider a distributed inventory service. A request arrives to reduce the available inventory of a product by one unit. All replicas execute the same operation against their local state.

If the operation is deterministic and all replicas process the same requests in the same order, they should arrive at equivalent states.

 

Advantages:

- Multiple replicas actively participate in request processing.

- There is no single replica exclusively responsible for executing every request.

- The system can continue operating despite certain replica failures.

 

Challenges:

- All replicas must process operations consistently.

- Requests generally require ordering or coordination.

- Non-deterministic operations can cause replicas to reach different states.

- Computational resources are consumed by executing the same request multiple times.

 

For example, if a replicated service generates a random number independently on each node, different replicas may produce different results. Such operations require deterministic inputs or coordinated results.

 

Active replication is particularly useful in fault-tolerant distributed services where multiple replicas must independently maintain equivalent state.

 

2.2.2 Passive Replication

In passive replication, one replica processes client requests, while the remaining replicas maintain copies of its state. This is commonly implemented using a primary-backup architecture.

 

Consider a service running on three servers:

- Server A is the primary

- Server B is the backup

- Server C is another backup

 

When a client submits a request:

-       The request is sent to Server A.

-       Server A processes the request.

-       Server A updates its state.

-       The resulting state changes or execution updates are propagated to Server B and Server C.

-       The backup replicas apply those changes to maintain their state.

 

If Server A fails, an eligible backup can be promoted to become the new primary.

 

Advantages:

- Only the primary processes client writes.

- Backup replicas do not need to execute the original business operation independently.

- The architecture is relatively straightforward to implement.

- It provides a clear mechanism for failover.

 

Challenges:

- The primary can become a performance bottleneck.

- Backups may lag behind the primary.

- Failover requires detecting failures and promoting another replica.

- Depending on the replication mechanism, some committed operations may be lost during failures.

 

2.2.3 Active Versus Passive Replication

Characteristic

Active replication

Passive replication

Request processing

All replicas process requests

Primary processes requests

State updates

Each replica updates its state

Primary propagates updates.

Coordination

Requires consistent request ordering

Requires state/update synchronization

Resource usage

Higher due to duplicate execution

Generally lower

Failure handling

Other active replicas can continue

Backup needs to take over

Common model

State machine replication

Primary-backup replication

        

Important distinction: Active and passive replication describe how requests are processed. Primary-backup and multi-primary describe architectural arrangements of replicas. These concepts are related, but they are not interchangeable.

 

2.3 Primary-Backup (Primary-Replica) Architecture

Primary-backup replication is one of the most commonly used replication architectures in distributed systems and databases.

 

In this architecture, one node is designated as the primary, while one or more additional nodes act as replicas or backups.

 

The primary is responsible for processing write operations, and changes are propagated to the replicas.

 

How It Works?

Consider an application maintaining a primary database and two replicas.

 

Step 1: Write request

A client submits an update request to change a customer's email address. The request is routed to the primary database.

 

Step 2: Primary processes the request

The primary database executes the update and commits the transaction according to its durability and replication configuration.

 

Step 3: Changes are propagated

The primary sends the corresponding changes to its replicas. The replicas apply the updates to their local database copies.

 

Step 4: Read requests

Depending on the application's consistency requirements, read requests can be served by the primary or distributed across the replicas.

 

Step 5: Primary failure

If the primary becomes unavailable, the system detects the failure and may promote an eligible replica to become the new primary. This process is called failover.

 

Example: E-commerce Order Management

Imagine an e-commerce platform processing thousands of orders every minute.

 

The platform uses a primary-replica database architecture.

-       All order creation and modification operations are directed to the primary

-       Product catalog and order history queries can be distributed across read replicas

-       If the primary fails, an eligible replica can take over write operations

 

This architecture helps distribute read traffic while maintaining a single write authority.

 

Advantages

-       Simplified write coordination: Since there is only one primary, concurrent writes do not need to be coordinated across multiple leaders.

-       Read scalability: Read requests can be distributed across multiple replicas.

-       High availability: Replicas can take over when the primary fails.

-       Simpler conflict management: There is generally no need to resolve conflicting writes from independent leaders.

 

Limitations

-       Write bottleneck: The primary handles all writes, which can limit write scalability.

-       Replication lag: Replicas may not immediately contain the latest committed changes.

-       Failover complexity: The system must safely detect primary failures and promote another replica.

-       Split-brain risk: If multiple nodes incorrectly believe they are primary, conflicting writes may occur.

 

A common solution to split-brain problems involves leader election, quorum-based coordination, and fencing mechanisms.

 

When is it useful?

Primary-backup replication is suitable for applications that need strong write coordination and can benefit from distributing read workloads across multiple replicas.

 

Examples include e-commerce applications, content management systems, reporting platforms, and many traditional relational database deployments.

 

2.4 Multi-Primary (Multi-Master) Architecture

Unlike primary-backup replication, where one node is responsible for processing writes, multi-primary replication allows multiple nodes to accept write operations independently.

 

Each primary can process local writes and propagate changes to the other primary nodes.

 

This architecture is particularly useful in geographically distributed applications where sending every write to a single central database would introduce significant network latency.

 

How It Works?

Consider an application operating in three geographical regions:

-       India.

-       Europe.

-       North America.

 

Each region maintains its own primary database.

 

When a user in India updates their profile:

-       The update is processed by the Indian database.

-       The change is committed locally.

-       The updated data is propagated to the European and North American databases.

-       The other regions apply the change to their local copies.

 

Similarly, a user in Europe can update their data through the European database without sending the write request to India. This allows applications to process writes closer to their users.

 

The Conflict Problem

Multi-primary replication introduces an important challenge: conflicting updates.

 

Consider a customer record with the following shipping address:

 

Address = Bangalore

 

Now imagine two users or application processes updating this record simultaneously.

- Region A changes the address to Hyderabad.

- Region B changes the address to Chennai.

 

Both regions may successfully commit their updates locally. When the changes are propagated, the system must determine which value should be retained.

 

Possible conflict resolution approaches include:

- Last-write-wins.

- Version-based conflict detection.

- Application-specific conflict resolution.

- Merging concurrent updates.

 

The choice depends on the application's data model and business requirements.

 

Advantages

- Writes can be processed locally in multiple regions.

- Reduces dependency on a single write-serving location.

- Improves write availability during certain network disruptions.

- Supports geographically distributed applications.

 

Limitations

- Conflict detection and resolution become more complicated.

- Maintaining consistency across multiple primaries is challenging.

- Replication and coordination introduce additional operational overhead.

- Applications must handle concurrent updates carefully.

 

Primary-Backup Versus Multi-Primary

Characteristic

Primary-backup

Multi-primary

Write authority

One primary

Multiple primaries

Write processing

Centralized

Distributed

Read processing

Primary and replicas

Multiple nodes

Conflict resolution

Relatively simpler

More complex

Coordination complexity

Lower

Higher

Typical use case

Traditional database clusters

Multi-region applications

 

 

Key takeaway: Primary-backup replication simplifies write coordination by using one primary, while multi-primary replication distributes write responsibilities across multiple nodes at the cost of additional coordination and conflict-resolution complexity.

 

2.5 Replication Transparency

One of the important goals of distributed systems is to hide unnecessary implementation complexity from application developers and end users. This concept is known as replication transparency.

 

Replication transparency means that users and applications should be able to access a replicated resource in a way that is similar to accessing a single resource, without needing to understand how many replicas exist or where they are located.

 

For example, imagine an application connecting to a database using a standard database connection. The application executes:

 

SELECT *
FROM CUSTOMERS
WHERE CUSTOMER_ID = 101;

The application does not necessarily need to know whether the query is executed against:

 

- A primary database

- A read replica

- A database replica located in another geographical region

 

The infrastructure can decide which replica should serve the request. Similarly, if a database server fails, the application should ideally continue operating without requiring significant changes to its business logic.

 

How Replication Transparency Works?

Consider an application using a database cluster with one primary and two replicas.

 

-       The application connects to the database through a logical endpoint.

-       The database infrastructure routes write requests to the primary.

-       Read requests may be routed to appropriate replicas.

-       If a replica becomes unavailable, the infrastructure can route requests to another healthy replica.

-       If the primary fails, the infrastructure may promote a replica and redirect new connections.

 

From the application's perspective, it continues interacting with the database through the same logical interface.

 

Is Replication Completely Transparent?

Not always.

 

Replication transparency has practical limitations.

 

For example:

-       A read from a replica may return stale data because of replication lag.

-       A failover may interrupt existing database connections.

-       A write may need to be retried after a primary failure.

-       Applications may need read-after-write consistency guarantees.

-       Applications may need to understand whether a request is routed to a primary or replica.

 

Therefore, replication infrastructure can hide much of the complexity, but applications may still need to account for consistency and failure-related behavior.

 

Key takeaway: Replication transparency aims to make multiple replicas appear like a single logical resource, reducing the complexity exposed to applications and users.

 

2.6 Replication Versus Load Balancing

Replication and load balancing are two important techniques used to improve the scalability and reliability of distributed systems.

 

Although they are often used together, they solve different problems. Replication creates multiple copies of data or resources, whereas load balancing distributes incoming requests across available resources.

 

Let's understand this with an example.

 

Imagine an application receiving one million requests per day. The application has three database servers, each maintaining a copy of the same customer data. Replication ensures that these servers have the necessary copies of the data. Load balancing determines how incoming requests are distributed across those servers.

 

How Replication Works?

Replication focuses on maintaining multiple copies.

 

For example:

- Database A stores the primary copy.

- Database B maintains a replica.

- Database C maintains another replica.

 

Changes made to the primary database are propagated to the replicas. The objective is to improve availability, provide redundancy, and make additional copies available for serving reads.

 

How Load Balancing Works?

Load balancing focuses on distributing incoming requests across multiple servers.

 

For example, imagine three application servers:

- Application Server A

- Application Server B

- Application Server C

 

A load balancer distributes incoming requests across these servers based on configured algorithms.

 

Common load-balancing strategies include:

- Round robin

- Weighted round robin

- Least connections

- IP hash

- Least response time

 

The objective is to prevent individual servers from becoming overloaded while utilizing available infrastructure efficiently.

 

Can Replication and Load Balancing Work Together?

Yes. In fact, they are frequently used together. Consider a database cluster with one primary and three read replicas. Replication ensures that the replicas receive database updates. A database-aware load balancer distributes eligible read requests across the available replicas.

 

For example:

Request

Destination

Create customer

Primary

Update customer

Primary

Get customer details

Replica 1

Get product catalog

Replica 2

Get order history

Replica 3

                 

This architecture combines replication and load balancing to improve read scalability. However, a generic load balancer cannot automatically determine whether a database request is safe to execute on a replica. Database-aware routing or application-level read/write splitting is required.

 

Replication Versus Load Balancing

Characteristic

Replication

Load balancing

Primary purpose

Maintain multiple copies

Distribute requests

What it manages

Data or resource copies

Incoming workload

Main benefit

Availability and redundancy

Scalability and utilization

 

Data synchronization

Required for data replicas

Not inherently required

Failure handling

Provides alternative copies

Routes traffic away from unhealthy servers

Example

Primary-replica database

Nginx or HAProxy

                 

Key takeaway: Replication provides multiple copies of resources, while load balancing distributes requests across available resources. Replication can exist without load balancing, and load balancing can exist without data replication.

 

2.7 Replication Versus Backup

Replication and backup are two important techniques used to protect data and improve system reliability. Although both involve maintaining additional copies of data, their objectives and operating mechanisms are different.

 

Replication focuses on maintaining up-to-date copies of data for availability and operational continuity, whereas backup focuses on preserving data so that it can be recovered after accidental deletion, corruption, or other failures.

 

Let's understand this with an example. Imagine an e-commerce application maintaining customer orders in a primary database.

 

The organization maintains:

-       One primary database.

-       Two database replicas.

-       Daily database backups stored in a separate backup system.

 

Replication keeps the database replicas synchronized with the primary database, while backups preserve recoverable versions of the data.

 

How Replication Works?

Suppose a customer places an order.

-       The order is inserted into the primary database.

-       The database propagates the change to its replicas.

-       The replicas apply the update.

-       All synchronized replicas eventually contain the new order.

 

Now imagine an application accidentally deletes the order.

 

The deletion may also be propagated to all replicas. This means replication alone cannot protect against accidental deletion or logical data corruption.

 

How Backup Works?

A backup system periodically captures and preserves database information.

 

For example:

- A full backup is taken every Sunday.

- Differential or incremental backups are taken during the week.

- Transaction logs are backed up periodically.

 

Now suppose an application accidentally deletes customer orders on Wednesday. The organization can restore the database from the previous backup and, where supported, replay transaction logs to recover the data to a point before the deletion.

 

This is known as point-in-time recovery.

 

Key Differences

Characteristic

Replication

Backup

Primary objective

Availability and operational continuity

Data protection and recovery

Data updates

Frequently synchronized

Captured periodically or continuously

Historical data

Usually not preserved

Historical versions are preserved

Accidental deletion

May propagate to replicas

Can recover from an earlier backup

Hardware failure

Another replica may take over

Restore from backup if needed

Recovery approach

Failover to another replica

Restore or recover data

Typical implementation

Primary-replica database

Full, differential, incremental backups

 

Can Replication and Backup Be Used Together?

Absolutely. Production systems should generally use both. Consider a financial application that requires high availability and strong data protection.

 

Its architecture may include:

-       A primary database handling transactions.

-       Synchronous or asynchronous replicas for availability.

-       Periodic full and incremental backups.

-       Transaction log backups for point-in-time recovery.

-       Backups stored in a geographically separate location.

 

Each component addresses a different failure scenario.

- If the primary database server fails, a replica can take over.

- If a database record is accidentally deleted, a backup can help recover it.

- If the entire data center becomes unavailable, geographically separate replicas or backups can support disaster recovery.

 

Key takeaway: Replication is not a replacement for backup. Replication helps systems continue operating, while backups help organizations recover historical data and protect against logical errors and data loss.

 

In summary, Replication is a fundamental concept in distributed systems, and understanding its different forms helps us design reliable and scalable architectures.

 

The most important distinction is that replication is not a single implementation technique. It is a broader concept with different architectures and execution models.

 

Choosing the right approach depends on application requirements, including availability, consistency, read and write workloads, geographical distribution, and operational complexity.

 

Section 3: Database Replication Architectures

Database replication is the process of maintaining copies of the same database across multiple database servers. These servers coordinate with each other to propagate data changes and make information available to applications.

 

Different database replication architectures use different approaches to handle read and write operations, synchronize data, and recover from failures.

 

The three fundamental database replication architectures are:

-       Single-leader replication: One database node handles all writes, and other nodes maintain replicas.

-       Multi-leader replication: Multiple database nodes can independently accept writes and propagate changes to one another.

-       Leaderless replication: Any database node can accept read and write requests without depending on a single designated leader.

 

Each architecture offers different trade-offs in terms of consistency, availability, performance, and operational complexity.

 

Let's explore each architecture in detail.

                 

3.1 Single-Leader Replication

Single-leader replication, also known as primary-replica or leader-follower replication, is one of the most widely used database replication architectures.

 

In this architecture, one database node is designated as the leader (primary), while the remaining nodes act as followers (replicas).

 

The leader is responsible for processing all write operations. Whenever data changes on the leader, those changes are propagated to the follower nodes.

 

Followers maintain copies of the leader's data and can typically serve read requests.

 

3.1.1 How Single-Leader Replication Works?

Consider an e-commerce application maintaining customer information, product catalogs, and order details.

 

The application uses three database servers:

- Database A: Primary (leader)

- Database B: Replica (follower)

- Database C: Replica (follower)

 

The primary handles all database modifications, while the replicas receive changes from the primary.

 

Write operation

Suppose a customer places an order.

 

The following steps occur:

-       The application sends an INSERT request to the primary database.

-       The primary executes the transaction and commits the order.

-       The primary records the changes in its transaction log.

-       The changes are transmitted to the replicas.

-       The replicas apply the changes to their local databases.

 

Read operation

Now suppose the customer opens their order history. The application can send the read request to one of the replicas instead of the primary.

 

The application may route this query to Database B or Database C. This distributes read traffic across multiple database servers and reduces the read workload on the primary.

 

However, there is an important consideration: the replicas may not have received the latest changes yet.

 

This is known as replication lag.

 

For example:

-       The primary commits order 1001 at 10:00:00.

-       Replica B receives the update at 10:00:00.100.

-       Replica C receives the update at 10:00:00.500.

 

If the application queries Replica C at 10:00:00.200, the newly created order may not yet be visible. This is why applications need to consider consistency requirements when routing reads to replicas.            

 

3.1.2 How Replication Is Implemented

Single-leader replication can be implemented using different techniques. The most common approaches include:

 

a. Statement-based replication

The primary records SQL statements executed against the database and sends those statements to the replicas.

For example: 

 

UPDATE employees
SET salary = salary * 1.10
WHERE department = 'Engineering';

  

The same SQL statement is executed on the replicas. One limitation is that certain SQL operations may produce different results when executed independently.

 

 

For example, operations involving NOW(), random values, or other non-deterministic functions can produce different results across database servers.

 

Consider this query:

UPDATE employees

SET bonus = 1000
WHERE employee_id = (
    SELECT employee_id
    FROM employees
    ORDER BY NEWID()
    OFFSET 0 ROWS FETCH NEXT 1 ROW ONLY
);

NEWID() generates a different value each time it is evaluated. As a result, the primary and replica might select different employees.

 

This can cause data inconsistency.

 

Other examples of potentially problematic statements include:

- Queries using NOW() or current timestamps.

- Queries using random-number generators.

- Queries relying on unspecified row ordering.

- Queries whose results depend on session variables or environment-specific behavior.

 

Database systems can handle some of these cases using special logging rules or by recording additional information, but statement-based replication still has determinism concerns.

 

b. Write-ahead log (WAL) shipping

The primary records database modifications in its write-ahead log (WAL). These log records are transmitted to replicas, which replay the changes to maintain their database state.

 

A Write-Ahead Log (WAL) records database changes at a low level before those changes are permanently applied to the database's data files.

 

The fundamental principle is, before modifying the actual database data pages on disk, the database first writes the corresponding change information to the WAL.

 

This ensures that the database can recover committed transactions after a crash.

 

The advantage is that replicas receive the actual database changes rather than independently interpreting the original SQL statements.

 

c. Logical replication

Instead of transmitting low-level storage changes, the database captures logical changes such as inserted, updated, or deleted rows. These changes are transmitted to the replicas and applied to their corresponding tables.

 

Logical replication can provide greater flexibility when replicating selected tables or integrating different database systems.

 

Consider the same query:

 

UPDATE employees
SET salary = salary * 1.10
WHERE department = 'Engineering';

Suppose the primary has these records:

Employee ID

Department

Salary

101

Engineering

100,000

102

Engineering

120,000

103

Sales

90,000

 

After executing the query, the primary produces these logical changes:

 

UPDATE employees
SET salary = 110000
WHERE employee_id = 101;

UPDATE employees
SET salary = 132000
WHERE employee_id = 102;

The replication mechanism transmits the row-level changes, and the replica applies them.

 

The important distinction is that the replica does not need to independently evaluate the original expression salary * 1.10 or determine which employees matched the original query. It applies the changes captured from the primary.

 

3.1.3 Synchronous Versus Asynchronous Replication

Single-leader replication can operate using synchronous or asynchronous replication.

 

Synchronous replication

In synchronous replication, the primary waits for the required replica acknowledgement before confirming a write operation to the client.

 

A simplified flow:

-       Client sends a write request.

-       Primary executes the transaction.

-       Primary sends the change to the replica.

-       Replica acknowledges the required replication stage.

-       Primary confirms the transaction to the client.

 

This helps ensure that acknowledged writes are available on the required replicas, depending on the acknowledgement policy. The trade-off is increased write latency because the primary must wait for communication with replicas.

 

Asynchronous replication

In asynchronous replication, the primary confirms the write operation without waiting for replicas to acknowledge the change.

 

The changes are propagated in the background.

 

A simplified flow:

-       Client sends a write request.

-       Primary executes and commits the transaction.

-       Primary acknowledges success to the client.

-       Changes are transmitted to replicas asynchronously.

-       Replicas apply the changes when they receive them.

 

This improves write performance but introduces the possibility of losing recently committed changes if the primary fails before those changes reach the replicas.

 

3.1.4 Failover in Single-Leader Replication

One of the important benefits of single-leader replication is the ability to recover from primary database failures.

 

Consider a database cluster with one primary and two replicas.

 

Initially:

- Database A is the primary.

- Database B is a replica.

- Database C is a replica.

 

Now imagine Database A crashes because of a hardware failure. The database cluster must detect the failure and promote an eligible replica.

 

The failover process generally involves:

 

-       Detecting that the primary is unavailable.

-       Identifying an eligible replica.

-       Electing or selecting a new primary.

-       Updating cluster metadata and routing.

-       Redirecting new write requests to the new primary.

 

For example, Database B may be promoted as the new primary, while Database C continues to act as a replica. An important challenge is preventing split-brain scenarios, where the old primary and the newly promoted primary both accept writes.

 

Distributed coordination, leader election, and fencing mechanisms help prevent this situation.

 

3.1.5 Advantages and Disadvantages

Advantages

-       Simple write coordination because only one leader accepts writes.

-       Read scalability through multiple replicas.

-       Straightforward conflict management for writes.

-       Supports failover when the primary becomes unavailable.

-       Widely supported by relational and distributed databases.

 

Disadvantages

-       The primary can become a write bottleneck.

-       Asynchronous replicas may return stale data.

-       Synchronous replication increases write latency.

-       Failover requires coordination and can interrupt operations.

-       A network partition can affect write availability, depending on the configuration.

 

3.1.6 Real-World Use Cases

Single-leader replication is suitable for applications where writes need a clear ordering and read workloads can be distributed.

 

Examples include:

-       E-commerce platforms.

-       Content management systems.

-       Reporting and analytics applications.

-       Customer management systems.

-       Applications using PostgreSQL or MySQL primary-replica deployments.

 

For example, a reporting platform can direct data modifications to its primary database while routing dashboard queries to multiple read replicas. This helps protect the primary from heavy read traffic.

 

3.2 Multi-Leader Replication

Multi-leader replication, also known as multi-primary or multi-master replication, allows multiple database nodes to independently accept write operations.

 

Unlike single-leader replication, where all writes are directed to one primary, multiple database nodes can act as leaders.

 

Each leader processes local writes and propagates changes to the other leaders.

 

This architecture is particularly useful for geographically distributed applications where users need to perform writes locally without sending every request to a centralized database.

 

3.2.1 How Multi-Leader Replication Works

Consider an application operating across three geographical regions:

-       India.

-       Europe.

-       North America.

 

Each region maintains its own database server, and all three databases can accept write operations.

For example:

-       Indian users connect to the India database.

-       European users connect to the Europe database.

-       North American users connect to the North America database.

 

When a user updates their profile in India:

-       The application sends the update to the India database.

-       The India database commits the change locally.

-       The change is propagated to the Europe and North America databases.

-       The other secondary databases in each region apply the update.

 

Similarly, a user in Europe can update their profile through the Europe database. This reduces the need to send every write operation to a central database.

 

3.2.2 Write Operations in Multi-Leader Replication

Let's understand this using a practical example. Imagine a customer database containing:

 

Customer ID

Name

City

101

Ravi

Bangalore

 

Now the customer updates their city. The update is submitted to the India database.

 

UPDATE CUSTOMERS
SET CITY = 'Hyderabad'
WHERE CUSTOMER_ID = 101;

The India database commits the update and propagates the change to the other regional databases.

 

Eventually, all databases contain:

 

Customer ID

Name

City

101

Ravi

Hyderabad

 

This is an example of asynchronous multi-leader replication.

 

3.2.3 Read Operations in Multi-Leader Replication

Read requests can generally be served by any available leader.

 

For example:

-       A user in India reads from the India database.

-       A user in Europe reads from the Europe database.

-       A user in North America reads from the North America database.

 

This allows reads to be served locally. However, because changes propagate asynchronously, different leaders may temporarily return different values.

 

Applications must account for replication lag and the possibility of conflicting updates.

 

3.2.4 The Conflict Resolution Problem

One of the biggest challenges in multi-leader replication is handling concurrent updates. Consider a customer record:

 

Customer ID: 101

City: Bangalore

 

Now imagine the customer updates their city through two different regions.

 

India database updates the city to Hyderabad.

Europe database updates the city to Chennai.

 

Both databases independently commit their updates. When the changes are propagated, each database must determine which value should be retained. This is known as a replication conflict.

 

Several strategies can be used to resolve such conflicts.

 

a. Last-write-wins (LWW)

The system compares timestamps associated with updates and retains the update with the latest timestamp.

 

For example:

Region

City

Timestamp

India

Hyderabad

10:00:01

Europe

Chennai

10:00:03

 

The system retains Chennai because its timestamp is latest. However, relying on timestamps can introduce problems when clocks across different machines are not synchronized.

 

b. Application-level conflict resolution

The application defines business rules to decide how conflicting updates should be handled.

 

For example, a banking application may reject conflicting account modifications instead of automatically selecting the latest update.

 

c. Version-based conflict detection

The system tracks versions between updates to identify concurrent modifications. It can then reject conflicting changes or ask the application to merge them.

 

d. Merging concurrent updates

When changes affect different fields, the system may be able to merge them.

 

For example:

-       India updates the customer's phone number.

-       Europe updates the customer's email address.

 

Since the changes affect different fields, the system may combine both updates without losing information.

 

3.2.5 Advantages and Disadvantages

Advantages

- Multiple regions can independently accept writes.

- Reduces dependence on a single write-serving location.

- Improves local write responsiveness.

- Supports geographically distributed applications.

- Can continue accepting writes in certain network partition scenarios.

 

Disadvantages

- Concurrent updates can create conflicts.

- Conflict resolution introduces additional complexity.

- Asynchronous replication can result in temporary inconsistencies.

- Distributed coordination is more difficult.

- Debugging and operational management can become complicated.

 

3.2.6 Real-World Use Cases

Multi-leader replication is useful when applications need to accept writes from multiple locations.

 

Examples include:

- Global collaboration applications

- Multi-region content management systems

- Applications supporting offline data entry and synchronization

- Distributed enterprise applications

- Geographically distributed operational databases

 

For example, a global collaboration platform may allow users in different countries to update shared documents through their nearest regional database. The changes are subsequently synchronized across regions.

 

However, the application must define how concurrent document modifications are reconciled.

 

3.3 Leaderless Replication

Leaderless replication is a database replication architecture in which there is no permanently designated primary or leader responsible for processing all write operations. Instead, clients can send read and write requests to multiple database nodes.

 

The database distributes data across nodes and uses mechanisms such as quorum-based acknowledgements, versioning, and conflict resolution to maintain availability and consistency.

 

This architecture is commonly associated with Dynamo-style distributed databases.

 

Examples of databases and systems using leaderless or Dynamo-inspired replication approaches include Amazon DynamoDB's underlying design principles, Apache Cassandra, and Riak.

 

3.3.1 How Leaderless Replication Works

Consider a distributed database cluster containing three nodes:

- Database Node A

- Database Node B

- Database Node C

 

All three nodes can participate in processing read and write requests. There is no single primary database responsible for coordinating every write.

 

Instead, the client or database coordinator communicates with multiple replicas to complete an operation. Let's understand this through read and write operations.

 

3.3.2 Write Operations in Leaderless Replication

Imagine an application storing customer information across three database replicas. A client wants to update a customer's city.

 

UPDATE CUSTOMERS
SET CITY = 'Hyderabad'
WHERE CUSTOMER_ID = 101;

   

The write operation is sent to a coordinator, which may be one of the database nodes.

 

The following steps occur:

-       The coordinator receives the write request.

-       It identifies the replicas responsible for storing the requested data.

-       It forwards the write to those replicas.

-       Each replica attempts to apply the update.

-       The coordinator waits for the required number of acknowledgements.

-       Once the acknowledgement requirement is satisfied, the operation is considered successful.

 

An important concept here is write quorum.

A quorum represents the minimum number of replicas that must acknowledge an operation before it is considered successful.

 

For example, suppose the database maintains three replicas:

- Total replicas (N) = 3.

- Write quorum (W) = 2.

 

The write operation is considered successful when at least two replicas acknowledge it. The remaining replica can receive the update later through mechanisms such as hinted handoff or subsequent synchronization.

3.3.3 Read Operations in Leaderless Replication

Read operations also involve communicating with multiple replicas.

 

Suppose a customer requests their account information. The coordinator sends the read request to multiple replicas and collects their responses. The coordinator can compare the returned values or versions to determine the appropriate result.

 

This introduces another important concept: read quorum.

Read quorum represents the minimum number of replicas that must respond to a read operation.

 

For example:

- Total replicas (N) = 3.

- Read quorum (R) = 2.

 

The coordinator waits for at least two replicas to respond.

 

Consider the following replica states:

 

Replica

Customer city

Version

Node A

Hyderabad

2

Node B

Hyderabad

2

Node C

Bangalore

1

 

The coordinator receives responses from Node A and Node B. Both replicas contain the latest version, so the coordinator returns Hyderabad. If one replica returns an older value, the system can identify the stale copy and potentially repair it.

 

3.3.4 Understanding Quorum Reads and Writes

Quorum-based replication is an important technique used in leaderless databases.

 

Three parameters are commonly used:

- N: Total number of replicas storing a piece of data.

- W: Number of replicas that must acknowledge a write.

- R: Number of replicas that must respond to a read.

 

A commonly used quorum condition is: (R + W > N).

 

This condition ensures that read and write quorums overlap, assuming they operate over the same replica set and the relevant writes have been successfully acknowledged.

 

For example: N = 3, W = 2, R = 2,

Therefore: R + W = 2 + 2 = 4

Since 4 > 3, the read and write quorums must share at least one replica. This improves the likelihood that a read will observe a recently acknowledged write.

 

However, quorum overlap alone does not guarantee strong consistency in every leaderless database. The actual consistency guarantees depend on the database's versioning, conflict resolution, read repair, write acknowledgement, and concurrency semantics.

 

3.3.5 What Happens When a Replica Is Unavailable?

One of the important advantages of leaderless replication is its ability to continue serving operations when some replicas are unavailable.

 

Consider a three-node cluster where Node C becomes temporarily unavailable. A client submits a write request.

 

The coordinator sends the update to all three replicas:

-       Node A acknowledges the write.

-       Node B acknowledges the write.

-       Node C does not respond.

 

If the configured write quorum is two, the operation can still succeed.

 

But what happens to Node C when it becomes available again?

The database must identify and synchronize any missing changes. Two important mechanisms help achieve this.

 

a. Read repair

Read repair is a mechanism in which the database identifies inconsistent replica values during a read operation and repairs outdated replicas.

 

For example:

Replica

Customer city

Version

Node A

Hyderabad

2

Node B

Hyderabad

2

Node C

Bangalore

1

 

When the coordinator reads the data, it may identify that Node C contains an older version. The system can return the latest value and send the updated value to Node C. This helps replicas gradually converge.

 

b. Hinted handoff

Hinted handoff helps synchronize replicas that were temporarily unavailable when a write occurred.

 

Suppose Node C is unavailable during a write. The coordinator or another node temporarily stores the update intended for Node C. When Node C becomes available again, the stored update is forwarded to it.

 

This helps the recovered node catch up without requiring a complete database rebuild.

 

Another related mechanism is anti-entropy repair, which compares replica data periodically and synchronizes missing or outdated information.

 

3.3.6 Advantages and Disadvantages

Advantages

- No permanently designated primary is required.

- Multiple nodes can accept requests.

- Can continue serving operations during certain node failures.

- Quorum-based operations provide configurable consistency and availability trade-offs.

- Suitable for geographically distributed and highly available systems.

 

Disadvantages

- Read and write operations may involve multiple replicas.

- Quorum coordination introduces additional network communication.

- Concurrent writes can create conflicts.

- Maintaining replica consistency is more complicated.

- Read repair and background synchronization introduce operational overhead.

- Strong consistency is not automatically guaranteed by using quorums.

 

3.3.7 Real-World Use Cases

Leaderless replication is particularly useful for applications that require high availability and distributed access to data.

 

Examples include:

- Large-scale distributed key-value stores.

- Shopping cart storage.

- User session management.

- Distributed caching and metadata services.

- Applications handling geographically distributed workloads.

- Systems requiring continued operation during individual node failures.

 

For example, an online shopping platform may store shopping cart information in a distributed database. If one database node becomes unavailable, the remaining nodes can continue processing requests when the configured quorum requirements are satisfied.

 

This helps the application remain available without depending on a single primary node.

 

3.4 Comparing Read and Write Operations Across Architectures

Now that we understand all three replication architectures, let's compare how they handle read and write operations.

 

Consider a database cluster with three nodes: A, B, and C.

 

a. Write operation comparison

 

Single-leader replication

-       Client sends the write to Node A.

-       Node A processes and commits the write.

-       Changes are propagated to Nodes B and C.

-       Only Node A accepts normal write operations.

 

Multi-leader replication

-       Client sends the write to a nearby leader.

-       That leader commits the write locally.

-       Changes are propagated to other leaders.

-       Concurrent updates may require conflict resolution.

 

Leaderless replication

-       Client sends the write to a coordinator.

-       The coordinator forwards it to the responsible replicas.

-       The operation succeeds after the configured write quorum is satisfied.

-       No permanent primary is required.

 

b. Read operation comparison

-       Single-leader: Reads can be served by the primary or follower replicas.

-       Multi-leader: Reads can be served by any available leader, subject to replication consistency.

-       Leaderless: Reads involve multiple replicas, with responses coordinated using the configured read consistency mechanism.

 

The key difference is how the architecture coordinates writes and determines which replica responses can be used to serve reads.

 

3.6 How to Choose the Right Replication Architecture?

There is no universally best replication architecture. The right choice depends on application requirements, particularly read/write workloads, consistency guarantees, geographical distribution, and failure-handling requirements.

 

Let's consider when each architecture makes sense.

 

Choose Single-Leader Replication When:

-       Your application requires a clear authority for write operations.

-       Write conflicts should be minimized.

-       Your application has significantly more reads than writes.

-       You want a relatively straightforward replication architecture.

-       You can tolerate some replication lag for read operations.

 

Example: An e-commerce platform where orders are written to a primary database while product catalogs and order history are served through read replicas.

 

Choose Multi-Leader Replication When:

-       Your application operates across multiple geographical regions.

-       Users need to perform writes against their local databases.

-       You want to reduce dependency on a central write-serving location.

-       Your application can handle concurrent updates and conflict resolution.

-       Local write availability is important.

 

Example: A global collaboration platform where users in different regions can update shared information and synchronize changes across locations.

 

Choose Leaderless Replication When:

-       Your application requires high availability.

-       You want to avoid depending on a single primary.

-       Your database workload can be distributed across multiple replicas.

-       You can work with quorum-based consistency mechanisms.

-       Your application can tolerate or resolve concurrent updates.

 

Example: A distributed shopping cart or session store that needs to remain accessible despite individual database node failures.

 

In summary, Database replication architectures determine how multiple database nodes coordinate to process reads and writes while maintaining copies of data.

 

The three fundamental architectures offer different approaches:

-       Single-leader replication: One primary handles writes, and replicas receive updates. It provides straightforward write coordination and supports read scaling.

-       Multi-leader replication: Multiple leaders accept writes independently and synchronize changes. It supports geographically distributed writes but introduces conflict-resolution complexity.

-       Leaderless replication: Multiple replicas participate in reads and writes using quorum-based mechanisms. It avoids dependence on a permanent primary but requires careful consistency management.

 

The key architectural decision is understanding where write operations should be processed, how replicas should synchronize, and what consistency guarantees the application requires.

 

In the next section, we will explore Synchronous and Asynchronous Replication, understanding how database changes propagate between replicas, how acknowledgements work, and how replication choices affect performance, consistency, and data loss.

 

Section 4: Synchronous and Asynchronous Replication

In the previous section, we explored different database replication architectures: single-leader, multi-leader, and leaderless replication.

 

Regardless of the architecture, an important question remains, When an application writes data to a database, when should the database acknowledge the write as successful?

 

Should the primary wait until the replica has received the change? Should it wait until the replica has actually persisted the change? Or should it acknowledge the write immediately and replicate the change in the background?

 

The answer depends on the replication strategy.

 

Database replication generally follows three approaches:

-       Synchronous replication

-       Asynchronous replication

-       Semi-synchronous replication

 

Each approach makes a different trade-off between data durability, consistency, availability, and performance.

 

4.1 What Is Synchronous Replication?

In synchronous replication, the primary database waits for one or more replicas to acknowledge the replicated change before considering the write operation successfully completed.

 

In other words, the primary coordinates with its replicas as part of the write operation.

 

Consider an application running with one primary database and two replicas. Suppose an application executes the following query:

 

INSERT INTO orders (order_id, customer_id, amount)

VALUES (1001, 501, 2500);

 

The write operation follows these steps:

-       The application sends the INSERT statement to the primary database.

-       The primary executes the transaction and generates the corresponding database changes.

-       The primary sends the changes to its replicas.

-       The replicas receive and process the changes.

-       The replicas send acknowledgements to the primary according to the configured synchronous replication policy.

-       The primary acknowledges the transaction to the application once the required acknowledgements have been received.

 

      

The important point is that the primary does not acknowledge the transaction until the configured synchronous acknowledgement condition is satisfied.

 

Different levels of synchronous acknowledgement

An important distinction is that receiving a replication message does not necessarily mean that the replica has durably stored or applied the change.

 

Depending on the database and its configuration, synchronous acknowledgement can represent different stages:

-       Received: The replica has received the change.

-       Written: The replica has written the change to its local operating-system buffer or log.

-       Flushed: The replica has persisted the log to durable storage.

-       Applied: The replica has replayed the change and made it visible to database queries.

 

For example, PostgreSQL supports different synchronous commit modes, including remote_write, on, and remote_apply, which provide different acknowledgement guarantees.

 

This distinction matters because a replica that has received a change but has not durably flushed it may still lose that change if it crashes.

 

Example: Synchronous replication with two replicas

Assume the primary has two replicas:

- Primary: Database A

- Replica 1: Database B

- Replica 2: Database C

 

The application submits a transaction to Database A.

 

If the configured policy requires acknowledgements from both replicas, the primary waits for both before acknowledging the transaction.

 

If Database B acknowledges after 10 ms and Database C acknowledges after 40 ms, the replication acknowledgement portion of the write takes at least 40 ms, excluding other processing and network overhead.

 

If Database C becomes unavailable, the write may block or fail, depending on the database configuration and timeout policy.

 

Advantages

-       Reduces the risk of losing acknowledged transactions during primary failure, provided the required replicas have durably persisted the changes.

-       Keeps replicas closely synchronized with the primary.

-       Can support stronger read-after-write guarantees when reads are directed to replicas that have applied the changes.

-       Useful for systems where data loss is unacceptable.

 

Disadvantages

-       Increases write latency because the primary must wait for replica acknowledgements.

-       Network delays directly affect transaction response times.

-       Replica failures can block writes if the required acknowledgement condition cannot be satisfied.

-       Geographic distribution can make synchronous replication expensive because of long network round trips.

 

Real-world use cases

Synchronous replication is useful for:

-       Financial transaction systems.

-       Banking and payment processing.

-       Critical business databases where losing acknowledged transactions is unacceptable.

 

However, synchronous replication alone does not guarantee every form of application-level consistency. Transaction isolation, concurrency control, and read routing still matter.

 

4.2. What Is Asynchronous Replication?

In asynchronous replication, the primary database acknowledges the write operation without waiting for replicas to confirm that they have received or applied the change.

 

The primary sends the changes to replicas in the background. This approach prioritizes write performance and allows replicas to temporarily lag behind the primary.

 

Consider the same order insertion:

INSERT INTO orders (order_id, customer_id, amount)

VALUES (1001, 501, 2500);

 

The write operation follows these steps:

-       The application sends the INSERT statement to the primary.

-       The primary executes the transaction and records the changes.

-       The primary acknowledges the transaction to the application once its local commit requirements are satisfied.

-       The primary sends the changes to replicas asynchronously.

-       Replicas receive and apply the changes independently.

 

Notice that the application does not wait for the replicas.

 

Example: Replication lag

Suppose an e-commerce application has the following setup:

-       Primary database in India.

-       Replica in Europe.

-       Replica in North America.

 

A customer places an order in India. The primary successfully inserts the order and immediately acknowledges the transaction.

 

However, due to network latency, the replica in Europe receives the change after 100 ms, while the North American replica receives it after 250 ms. During this period, a read request routed to either replica might not find the newly created order. This delay is called replication lag.

 

During this interval, the primary and replicas temporarily contain different data.

 

Advantages

-       Lower write latency because the primary does not wait for replica acknowledgements.

-       Replication can continue later even when replicas are temporarily unavailable.

-       Supports geographically distributed read workloads.

-       Reduces the impact of network latency on application write operations.

-       Scales well for read-heavy applications.

 

Disadvantages

-       A primary failure can cause the loss of transactions that were committed locally but not replicated.

-       Replicas may return stale data.

-       Applications must account for replication lag.

-       Failover requires careful selection of the most up-to-date replica.

 

Real-world use cases

Asynchronous replication is commonly used for:

-       Geographic distribution of application data.

-       Disaster recovery replicas.

-       Applications that can tolerate a small amount of replication delay.

 

For many web applications, asynchronous replication offers a good balance between performance and availability.

 

4.3. What Is Semi-Synchronous Replication?

Semi-synchronous replication is a compromise between synchronous and asynchronous replication.

 

The primary waits for acknowledgement from at least one replica before acknowledging a transaction to the application. However, the acknowledgement may only confirm that the replica has received or persisted the change, not necessarily applied it.

 

The exact guarantee depends on the database implementation.

 

Consider a primary database with two replicas.

 

When an application inserts an order:

-       The primary executes the transaction.

-       The primary sends the changes to both replicas.

-       At least one replica acknowledges the required replication stage.

-       The primary acknowledges the transaction to the application.

-       Other replicas can continue receiving and applying changes in the background.

 

Advantages

-       Provides a stronger durability guarantee than purely asynchronous replication when the acknowledgement represents durable persistence.

-       Avoids waiting for every replica.

-       Offers a balance between write latency and data protection.

-       Can reduce the amount of data potentially lost during primary failure.

 

Disadvantages

-       Write latency is higher than purely asynchronous replication.

-       If the required replica acknowledgements cannot be obtained, writes may be delayed or the system may fall back to asynchronous operation, depending on configuration.

-       Acknowledgement does not necessarily mean that the replica has applied the changes.

-       It does not eliminate data-loss risk under every failure scenario.

 

Real-world example: MySQL

MySQL supports semi-synchronous replication through its semi-sync source and replica plugins. The source can wait for a replica to acknowledge receipt of the transaction's events before returning success to the client.

 

Importantly, this acknowledgement does not necessarily mean the replica has applied the transaction to its tables.

 

If the configured timeout expires, MySQL can fall back to asynchronous replication. Therefore, the actual durability guarantee depends on the configuration and operational behavior.

 

4.4 How Replication Latency Affects Performance

Replication latency is the time taken for a change made on the primary database to reach a particular stage on a replica.

 

It is particularly important in distributed systems because databases may be deployed across different machines, availability zones, or geographical regions.

 

Consider an application operating in India, Europe, and North America. If the primary database is located in India, the network round-trip time to a replica in North America can be significantly higher than the round-trip time to a replica in the same region.

 

4.4.1 Factors affecting replication latency

a. Network latency

The physical distance between databases affects the time required to transmit changes and receive acknowledgements.

 

For example:

- Primary and replica in the same availability zone: relatively low latency.

- Primary and replica in different regions: higher latency.

- Primary and replica across continents: potentially much higher latency.

 

b. Transaction volume

When the primary generates changes faster than replicas can receive or apply them, replication lag increases. For example, a bulk update affecting millions of rows can generate a large amount of replication traffic.

 

c. Replica processing capacity

A replica may receive changes quickly but take longer to apply them because of:

- Limited CPU resources.

- Slow disk I/O.

- Lock contention.

- Long-running transactions.

- Insufficient replication worker capacity.

 

d. Network bandwidth

Large volumes of replicated data can saturate network connections, delaying replication.

 

The actual latency depends on network conditions, replica acknowledgement policy, database implementation, and transaction workload.

 

What happens when replication lag increases?

Suppose a user updates their profile:

 

UPDATE customers

SET city = 'Bengaluru'

WHERE customer_id = 501;

 

The primary commits the change. Immediately afterward, the application reads the customer profile from a replica. If the replica has not yet received the update, it returns the previous city. This is an example of a stale read.

 

Applications can address these using strategies such as:

-       Route read-after-write requests to the primary,

-       Monitor replication lag and route reads away from significantly lagging replicas.

 

4.5 Data Loss Scenarios During Failures

One of the most important differences between synchronous and asynchronous replication becomes visible when the primary database fails.

 

Let's understand two scenarios.

Scenario A: Primary failure with asynchronous replication

Assume the primary database has one replica.

 

An application inserts three orders:

         Order 1001 → Committed on primary

         Order 1002 → Committed on primary

         Order 1003 → Committed on primary

 

However, the replica has received only the first two orders. Now the primary crashes.

 

The replica contains:

Order ID

Primary

Replica

1001

Committed

Replicated

1002

Committed

Replicated

1003

Committed

Not Replicated

 

If the replica is promoted to become the new primary, order 1003 may be lost. This happens because the application received a successful response from the old primary, but the transaction had not reached the replica.

 

The potential amount of data lost is described by the Recovery Point Objective (RPO). RPO represents the maximum acceptable amount of data loss measured in time.

 

For example:

- RPO = 0 seconds: no acknowledged transactions should be lost.

- RPO = 5 seconds: losing up to five seconds of data may be acceptable.

 

Asynchronous replication can have a non-zero RPO.

 

Scenario B: Primary failure with synchronous replication

Now assume the primary uses synchronous replication and requires the replica to durably flush the changes before acknowledging a transaction.

 

-       The application inserts order 1003.

-       The primary sends the change to the replica.

-       The replica durably persists the change and acknowledges it.

 

Only then does the primary acknowledge success to the application. If the primary crashes immediately afterward, the replica already has the acknowledged transaction and can be promoted without losing it.

 

This provides a stronger protection against data loss. However, there is an important caveat: synchronous replication does not automatically guarantee zero data loss under every possible failure.

 

For example:

-       If acknowledgement only confirms receipt rather than durable persistence, the replica might lose the change after a crash.

-       If multiple replicas exist, the promoted replica must be one that contains the acknowledged transaction.

-       Network partitions and split-brain scenarios require appropriate quorum, fencing, and failover coordination.

-       Acknowledgement policy and commit configuration determine the actual guarantee.

 

The important lesson: Zero data loss depends on durable acknowledgements and correct failover coordination, not merely on enabling synchronous replication.

 

4.6. Consistency Versus Performance Trade-offs

Synchronous and asynchronous replication make different trade-offs.

 

Dimension

Synchronous

Asynchronous

Write latency

Higher

Lower

Replica lag

Usually limited by acknowledgement policy

Can be higher

Data loss risk during primary failure

Lower with durable acknowledgements

Higher

Network dependency

Stronger

Weaker

Write availability during replica failure

May be affected

Usually less affected

 

Geographic distribution

More expensive for writes

Easier to scale

 

Operational complexity

Higher

Moderate

 

Replication consistency is not the same as transaction consistency For example, a database can use synchronous replication and still allow anomalies caused by weak transaction isolation or incorrect application logic.

 

Similarly, asynchronous replication can be used in an application that provides read-your-writes consistency by routing a user's subsequent reads to the primary.

 

4.7. When Should You Choose Each Approach?

There is no universally correct replication strategy. The choice depends on the consequences of losing data, the acceptable write latency, and the application's availability requirements.

 

Choose synchronous replication when:

-       Losing acknowledged transactions is unacceptable.

-       The application handles financial or critical business transactions.

-       Strong protection against primary failure is required.

-       Replicas are located close enough to maintain acceptable write latency.

-       The infrastructure can support the required acknowledgement and failover guarantees.

 

Example: A banking application transferring money between accounts. If a transfer is acknowledged successfully, the application needs strong assurance that the committed transaction survives a primary failure.

 

Choose asynchronous replication when:

-       Low write latency is important.

-       The application can tolerate a small amount of potential data loss.

-       Read traffic needs to be distributed across multiple regions.

-       Replicas are geographically distant.

-       Reporting and analytics workloads do not require immediately consistent data.

 

Example: An e-commerce product catalog. Product updates can be replicated asynchronously to regional databases. A short replication delay is generally acceptable for many product browsing operations.

 

Choose semi-synchronous replication when:

-       You want stronger protection than asynchronous replication.

-       Waiting for every replica would introduce unnecessary latency.

-       The application can tolerate waiting for at least one replica.

-       The database implementation provides an acknowledgement guarantee that meets your durability requirements.

 

Example: An order management application where losing recent orders is undesirable, but waiting for every geographically distributed replica is too expensive.

 

The key takeaway is that replication is not just about maintaining multiple copies of data. It is also about deciding when a write is considered safe to acknowledge and how much risk the application is willing to accept in exchange for performance and availability.

 

Section 5: Replication and Consistency Models

In the previous section, we explored synchronous, asynchronous, and semi-synchronous replication. We saw how these approaches determine when a primary database acknowledges a write and how quickly changes reach replicas.

 

However, an important question remains, When an application reads data from a distributed database, what guarantees does it have that the data is correct and up to date?

 

Imagine an e-commerce application operating across India, Europe, and North America. A customer updates their delivery address in India. The primary database successfully commits the change, but the replicas in Europe and North America have not received it yet.

 

If the customer immediately opens their profile from another region, should the application return the new address or the previous one?

The answer depends on the consistency model implemented by the distributed system.

 

A consistency model defines the guarantees a system provides about the visibility and ordering of updates when data is replicated across multiple nodes.

 

Consistency is one of the most important concepts in distributed systems because maintaining multiple copies of data introduces the possibility that different nodes temporarily or permanently return different values.

 

Let's explore the major consistency models and understand how they relate to replication.

 

5.1. What Does Consistency Mean in Distributed Systems?

In a traditional single-database application, there is usually one authoritative database handling reads and writes. Once a transaction commits, subsequent reads through that database generally observe the committed value, subject to transaction isolation and caching behavior.

 

In a distributed database, multiple nodes may maintain copies of the same data. When an application updates a record on one node, the change must propagate to other nodes. During propagation, different replicas might contain different versions of the same record.

 

Consider a customer account:


This situation is not necessarily a failure. It can be an expected consequence of asynchronous replication. The important question is what the system guarantees to applications during this period.

 

For example:

-       Can a read return an older value after a successful write?

-       Can two users read different values for the same record?

-       Can a user see their own updates immediately?

-       Can a user observe data moving backwards to an older version?

-       Does the system guarantee that all completed writes are visible in a particular order?

 

Different consistency models answer these questions differently.

 

5.2. Strong Consistency

Strong consistency ensures that a distributed system behaves like a single copy of data, executing all operations in one global order that respects real-time sequence. Commonly modeled as linearizability, this guarantee means that once a write completes successfully, every subsequent read will see that updated value or a newer one.

 

Consider an account balance initially set to ₹5,000.

The application updates it to ₹7,000.

UPDATE accounts
SET balance = 7000
WHERE account_id = 101;

Once the update returns successfully, any subsequent read must return ₹7,000 or a later valid value. It must not return ₹5,000.

 

How is strong consistency achieved?

Distributed databases commonly use coordination protocols to ensure that updates are ordered and committed according to the required consistency guarantees.

 

Some mechanisms include:

-       Synchronous replication with appropriate durability guarantees.

-       Consensus protocols such as Raft and Paxos.

-       Quorum-based reads and writes with appropriate consistency protocols.

-       Leader-based coordination and controlled failover.

 

For example, a distributed database using Raft can replicate log entries across a group of nodes. An entry is committed when the required majority has replicated it, subject to Raft's leader and commitment rules.

 

The system can then expose committed state according to its consistency guarantees.

 

Advantages

- Applications can rely on a consistent view of completed operations.

- Reduces stale-read problems.

- Simplifies application logic for operations that require globally coordinated state.

- Useful for financial transactions, inventory reservations, and account management.

 

Disadvantages

- Requires coordination between nodes.

- Network delays can increase read and write latency.

- Operations may become unavailable during certain network partitions.

- Geographic distribution can make coordination expensive.

 

Important: Strong consistency is not the same as synchronous replication. Synchronous replication is one replication strategy; linearizability is a consistency guarantee. A system needs appropriate ordering, coordination, and read guarantees to provide linearizable behavior.

 

5.3. Eventual Consistency

Eventual consistency is a consistency model in which replicas may temporarily contain different values, but if no new updates occur and the system continues operating, all replicas will eventually converge to the same value.

 

Unlike strong consistency, eventual consistency does not require every replica to have the latest update before the application receives a successful response.

 

Consider the same account balance example.

 

Initially, all three regional databases contain ₹5,000. A customer deposits ₹2,000 in India.

 

The primary database commits the update and acknowledges it immediately. Replication happens in the background.

 


 

How is eventual consistency achieved?

The system allows updates to propagate asynchronously between replicas. Depending on the database architecture, it may use mechanisms such as:

 

-       Background replication.

-       Anti-entropy synchronization.

-       Read repair.

-       Hinted handoff.

-       Version vectors or timestamps to track updates.

 

These mechanisms help replicas exchange missing changes and converge.

 

Advantages

-       Low write latency because applications do not need to wait for every replica.

-       Supports geographically distributed applications.

-       Can continue accepting writes during certain network failures.

-       Improves availability and scalability for appropriate workloads.

 

Disadvantages

-       Applications may read stale data.

-       Different users may temporarily see different values.

-       Concurrent updates can create conflicts.

-       Application developers need to account for temporary inconsistency.

 

Real-world use cases

Eventual consistency is suitable for:

-       Social media likes and comments.

-       Product reviews and ratings.

-       View counters and analytics.

-       User activity feeds.

-       Distributed caches.

-       Search indexes and recommendation systems.

 

For example, if a user likes a social media post, it may be acceptable for the updated like count to appear in another region a few milliseconds later.

 

However, eventual consistency does not automatically mean that all updates will be applied correctly. The system still needs mechanisms to handle concurrent changes, retries, failures, and conflicts.

 

5.4. Read-After-Write Consistency

Read-after-write consistency is a guarantee that when a client successfully updates a piece of data, subsequent reads by that same client will reflect its own completed update.

 

This is also commonly called read-your-writes consistency.

 

Consider a user updating their profile:

 

UPDATE customers
SET city = 'Bengaluru'
WHERE customer_id = 501;

The update is committed successfully on the primary database. Immediately afterward, the same user requests their profile:

SELECT city
FROM customers
WHERE customer_id = 501;

The user expects to see: Bengaluru. But imagine that the SELECT request is routed to a replica that has not yet received the update.

 

The replica returns: Hyderabad

 

This violates the user's read-after-write expectation.

 

How can we provide read-after-write consistency?

There are several approaches.

 

a. Read from the primary after a write

After an update, route subsequent reads from that client to the primary database. This is a simple approach, but it increases read traffic on the primary.

 

b. Use session stickiness

Keep a user's requests associated with a particular database node or session. This can help when the node processes both the write and subsequent reads, although it must be designed carefully around failover and replica changes.

 

c. Wait for replica synchronization

The application can track the replication position associated with its write and wait until the selected replica has applied changes up to that position before reading.

 

For example, PostgreSQL exposes WAL LSNs that can be used to reason about replication progress.

 

d. Return updated data directly

For some application operations, the server can return the updated representation in the write response rather than immediately performing another read against a potentially lagging replica.

 

Where is it useful?

Read-after-write consistency is particularly useful for:

 

- User profile updates.

- Shopping cart modifications.

- Account settings.

- Order creation and confirmation.

- Content publishing.

 

The important point is that the entire distributed database does not necessarily need strong consistency to provide read-after-write consistency to individual users.

 

5.5 Monotonic Reads

Monotonic reads guarantee that once a client has observed a particular version of data, subsequent reads by that client will not return an older version.

 

In simple terms, A user should not see data moving backwards.

 

Consider a user checking their order status. The order moves through these states:

 

Order Placed → Payment Confirmed → Shipped → Delivered

 

Suppose the user reads the order status from a replica that has already received the Shipped update.

 

The user sees: Shipped

 

The next request is routed to another replica that is lagging behind. It returns: "Payment Confirmed".

 

The user has now observed the order status moving backwards. This violates monotonic reads.

 

How can we provide monotonic reads?

a. Session affinity

Route all reads from a particular user session to the same replica. This reduces the chance of observing an older version from a different replica.

 

However, it does not automatically guarantee monotonic reads if that replica itself can serve data from different snapshots or move backwards after failover.

 

b. Track the version observed by the client

The application can remember the last version or replication position observed by a client. Subsequent reads must be served from a replica that has reached at least that version.

 

c. Use version-aware reads

Some distributed databases support consistency tokens or session guarantees that allow clients to request data at or beyond a previously observed version.

 

Where is it useful?

Monotonic reads are useful for:

-       Order tracking.

-       Social media feeds.

-       Messaging applications.

-       User activity timelines.

-       Dashboards showing evolving business metrics.

 

A user should not see an older state after already observing a newer one.

 

5.6. Replication Lag and Stale Reads

Replication lag is the delay between a change being committed on the source database and that change becoming available at a replica.

 

It is one of the most common causes of inconsistent reads in asynchronously replicated databases.

 

For example, the primary database has this customer record:

Customer ID

City

501

Bengaluru

 

However, a replica still contains city as Hyderabad for the customer 501.

Customer ID

City

501

Hyderabad

 

An application reading from the replica receives an older value. This is called a stale read.

What causes replication lag?

Several factors can contribute to replication lag:

-       Network delays: Replication messages take longer to travel between regions.

-       High write throughput: The primary generates changes faster than replicas can process them.

-       Slow replica storage: Disk I/O limits the rate at which changes can be persisted.

-       Long-running transactions: Certain database operations can delay replay or visibility of changes.

-       Resource contention: CPU, memory, locks, and other workloads compete with replication processes.

-       Network interruptions: Replicas may temporarily stop receiving changes.

 

Measuring replication lag

Different databases expose different replication metrics.

 

For example, PostgreSQL provides functions to inspect WAL positions and replication progress. On a primary, you can inspect connected replication clients:

 

SELECT
    application_name,
    state,
    sent_lsn,
    write_lsn,
    flush_lsn,
    replay_lsn,
    write_lag,
    flush_lag,
    replay_lag
FROM pg_stat_replication;

These fields help identify how far the replica has progressed through the WAL stream.

 

A few distinctions matter:

-       sent_lsn: WAL position sent to the replica.

-       write_lsn: WAL position written by the replica.

-       flush_lsn: WAL position flushed to durable storage.

-       replay_lsn: WAL position replayed by the replica.

 

The differences between these positions help identify whether lag is primarily in transmission, persistence, or replay.

 

How should applications handle replication lag?

A practical approach is to classify reads based on their consistency requirements.

 

Application operation

Suggested read strategy

Read immediately after updating profile

Primary or consistency-aware replica

Display order confirmation

Primary or wait for replica progress

Product catalog browsing

Replica, if small staleness is acceptable

Business reporting

Analytics replica

Financial balance display

Strongly consistent read path

Historical analytics

Eventual consistency may be acceptable

        

Not every read needs the latest data. The important thing is to make the consistency requirement explicit.

 

5.7. CAP Theorem and Its Relationship with Replication

The CAP theorem is one of the fundamental concepts in distributed systems.

 

It describes the trade-offs a distributed data system faces when a network partition occurs.

 

CAP stands for:

-       C — Consistency

-       A — Availability

-       P — Partition Tolerance

 


To understand CAP, imagine a database distributed across India and Europe. Both regions maintain copies of the same customer account data.

 

A network failure occurs, preventing the two regions from communicating with each other.

 

Both regions are still running, but they cannot exchange updates.

 

Now the system faces a difficult decision:

-       Should both regions continue accepting requests, even if they might return conflicting or outdated data?

-       Or should one region reject or delay some requests until communication is restored, preserving stronger consistency guarantees?

 

This is the trade-off described by CAP.

 

Consistency (C)

In the CAP theorem, consistency means a guarantee equivalent to linearizability. Every successful read should return the latest completed write, or a newer value, according to a single globally consistent ordering of operations.

 

For example:

-       A customer updates their balance to ₹7,000 in India.

-       The update completes successfully.

-       A client reads the balance from Europe.

 

If the system promises CAP consistency, the European client cannot successfully receive the old balance of ₹5,000 after that completed update.

 

Availability (A)

Availability means every request received by a non-failing node must receive a successful response, even during a network partition.

 

This does not mean every response must contain the latest data.

 

For example, Europe might continue serving requests using its local replica even though it cannot communicate with India.

 

The response may contain stale data or reflect only locally available updates.

 

Partition Tolerance (P)

A network partition occurs when some nodes cannot communicate with other nodes because of network failures.

 

For example:

-       India cannot communicate with Europe.

-       Europe cannot communicate with North America.

-       Some network paths are unavailable while the database servers themselves remain operational.

 

A distributed system must account for these failures because network communication cannot be assumed to be perfectly reliable.

 

What does CAP actually tell us?

The CAP theorem states that when a network partition occurs, a distributed system cannot guarantee both linearizable consistency and availability for all requests in the partitioned system.

 

In a distributed system, partition tolerance is generally a necessary design assumption. During a partition, the system must decide whether to preserve consistency or availability for affected operations.

 

CP systems: Consistency and Partition Tolerance

A CP system prioritizes consistency during a network partition. It may reject or block operations that cannot be completed safely.

 

Consider two regions:

- India

- Europe

 

A network partition prevents communication between them. If the database cannot coordinate a write safely, it may reject writes in one region rather than allow conflicting updates.

 

Examples of systems designed around consensus-based consistency include:

- etcd

- ZooKeeper

- CockroachDB

 

These systems use coordination mechanisms to maintain their consistency guarantees. During a partition, nodes that cannot obtain the required quorum may be unable to accept writes.

 

AP systems: Availability and Partition Tolerance

An AP-oriented system prioritizes serving requests during a network partition, accepting that replicas may temporarily diverge.

 

Consider the same India-Europe example. If both regions cannot communicate, both may continue accepting local writes.

 

Once connectivity is restored, the system needs to reconcile the updates and bring replicas toward a consistent state.

 

Examples of systems with availability-oriented, eventually consistent design options include:

- Apache Cassandra

- Amazon DynamoDB when configured with eventually consistent reads

 

CP versus AP comparison

Aspect

CP

AP

Priority during partition

Consistency

Availability

Requests during partition

Some may be rejected or blocked

More requests can be served

Stale reads

Avoided where linearizable reads are promised

May be permitted

Concurrent writes

Restricted or coordinated

May be accepted independently

Conflict handling

Often prevents conflicting commits

May require reconciliation

 

Important: CAP is about behavior during a network partition. It is not a complete description of a database's consistency, latency, or availability under normal operating conditions.

 

A system may offer strong consistency for some operations and weaker consistency for others.

 

5.8. PACELC Theorem

The CAP theorem explains the trade-off between consistency and availability during a network partition.

 

However, distributed systems also face important trade-offs when there is no network partition. This is where the PACELC theorem becomes useful.

 

PACELC extends CAP by considering what happens both during and outside network partitions.

 

PACELC stands for:

-       P — Partition

-       A — Availability

-       C — Consistency

-       E — Else

-       L — Latency

-       C — Consistency

 

Its basic principle is:

If there is a Partition, a system must trade off Availability and Consistency. Else, when the system is operating normally, it must trade off Latency and Consistency.

 

   

Understanding PACELC with an example

Consider a distributed database with replicas in India and Europe.

 

Scenario 1: No network partition

Both regions can communicate normally. A write happens in India.

 

The database has two choices:

-       Wait for coordination with Europe before acknowledging the write, providing stronger consistency but increasing latency.

-       Acknowledge the write locally and replicate it asynchronously, reducing latency but potentially allowing stale reads in Europe.

 

This is the Latency versus Consistency trade-off.

 

Scenario 2: Network partition

India and Europe cannot communicate.

 

The database again has two choices:

-       Reject or block operations that cannot be safely coordinated, prioritizing consistency.

-       Continue accepting local requests, prioritizing availability but allowing replicas to diverge.

 

This is the Availability versus Consistency trade-off.

 

PACELC in practice

PACELC helps engineers understand that consistency has a performance cost even when the network is healthy.

 

For example, a geographically distributed database that requires coordination across continents may have higher write latency even without any failure.

 

A database that permits local writes and asynchronous propagation can reduce latency, but applications may observe stale data.

 

This is particularly relevant when designing multi-region systems.

 

CAP helps us reason about network partitions. PACELC helps us reason about both network partitions and normal-operation latency.

 

5.9. Conflict Prevention Versus Conflict Resolution

When multiple replicas can accept writes independently, another important problem emerges: What happens when two replicas update the same record at approximately the same time?

 

This is particularly relevant to multi-leader and leaderless replication architectures. Consider an application operating in India and Europe.

 

A customer's address is initially:

City = Hyderabad

 

The customer updates their address in India:

City = Bengaluru

 

At almost the same time, another application instance updates the address in Europe:

City = Chennai

 

Because the regions cannot immediately exchange changes, both updates may be accepted. When connectivity is restored, the system discovers two competing updates for the same record.

 

It must decide which value should become the final value.

 

There are two broad approaches to handling this problem:

-       Conflict prevention

-       Conflict resolution

 

5.9.1 Conflict Prevention

Conflict prevention attempts to avoid conflicting updates before they happen. Instead of allowing multiple replicas to modify the same data independently, the system coordinates access or controls which node can modify a particular record.

 

Common approaches include:

 

a. Single-leader architecture

All writes for a particular dataset or record are directed to one leader.

 

For example, only the India database is responsible for updating customer account records. Other regions can serve reads, but writes must be routed to the leader.

 

Since only one node accepts writes for that record, competing independent updates are avoided.

 

b. Distributed locking

A system can acquire a distributed lock before modifying a shared resource.

 

For example:

Client A requests lock for Customer 501

             |

             v

       Lock acquired

             |

             v

       Update address

             |

             v

       Release lock

 

Another client must wait until the lock is released.

 

Distributed locks require careful handling of failures, lease expiration, and fencing tokens to prevent an expired lock holder from performing an outdated write.

 

c. Optimistic concurrency control

The application can use version numbers to detect whether another client has modified the record.

 

Consider this table:

Customer ID

City

Version

501

Hyderabad

1

 

An application reads the record with version 1. It then updates the address using a conditional update:

 

UPDATE customers

 

SET
    city = 'Bengaluru',
    version = version + 1
WHERE customer_id = 501
  AND version = 1;

If another transaction has already updated the record, the version will no longer be 1. The update affects zero rows, indicating that the application must reload the latest record and retry or handle the conflict.

 

d. Data ownership and partitioning

Another approach is to assign ownership of records to specific regions or nodes.

 

For example:

-       Indian customer records are owned by the India region.

-       European customer records are owned by the Europe region.

-       North American customer records are owned by the North America region.

 

Only the owning region accepts writes for its records. This reduces cross-region write conflicts and can improve performance.

 

5.9.2 Conflict Resolution

Conflict resolution is used when conflicting updates have already occurred. Instead of preventing concurrent writes, the system accepts them and determines how to reconcile the changes.

 

Some common conflict resolution strategies include:

 

a. Last-Write-Wins (LWW)

The system chooses the update with the latest timestamp.

 

For example:

Region

City

Timestamp

India

Bengaluru

10:05:10

Europe

Chennai

10:05:12

        

The system selects Chennai because its timestamp is later.

India:  Bengaluru (10:05:10)
Europe: Chennai    (10:05:12)
                  |
                  v
             LWW selects
                Chennai

This is simple and commonly used in distributed databases. However, LWW has an important limitation: physical clocks across machines may not be perfectly synchronized.

 

Clock skew can cause the system to select an update that was not actually the latest in real-world time. LWW can also discard a valid concurrent update.

 

b. Version-based conflict resolution

The system tracks versions between updates.

 

For example:

 

Version 1: City = Hyderabad
       |
       +-------------------+
       |                   |
       v                   v
Version 2A             Version 2B
Bengaluru              Chennai
   

Both updates originated from the same previous version, so neither is necessarily newer than the other.

 

A version vector or another causal metadata mechanism can help detect that these updates are concurrent. Causality describes the relationship between events: whether one event happened before another and whether the second event was influenced by the first. In distributed databases, causality helps determine whether two updates happened sequentially or independently (concurrently).

 

What is a causal relationship?

Consider a customer whose city is initially Hyderabad. An application updates the city to Bengaluru. Later, the customer changes it again to Chennai.

Version 1: Hyderabad
       |
       | Update 1
       v
Version 2: Bengaluru
       |
       | Update 2
       v
Version 3: Chennai

Here, the second update happened after the first update and was based on the latest version.

 

Therefore:

-       Update 1 caused Version 2

-       Update 2 was performed after observing Version 2

-       Version 3 is causally dependent on Version 2

 

We can represent this relationship as: V1 -> V2 -> V3. The arrow means happened before or causally precedes. This is called a causal relationship.

 

Another example: Independent updates

Now consider two geographical regions, India and Europe. Both regions initially have:

 

Version 1: Hyderabad

 

Due to network latency, both regions independently read Version 1.

-       India updates the city to Bengaluru.

-       Europe updates the city to Chennai.

 

Neither region knows about the other's update.

 

Neither update is causally dependent on the other. We cannot say that Bengaluru is newer than Chennai or vice versa based on causality. These are called concurrent updates.

 

c. Application-level conflict resolution

The application defines business rules to determine how conflicting updates should be handled.

 

For example, consider a shopping cart. One user adds two products in India, while another session adds three products in Europe. Instead of choosing one entire cart version, the application may merge the individual cart items.

 

The final cart contains both sets of changes, provided the business rules allow it. This approach is often more appropriate than choosing the latest timestamp.

 

d. Merge-based conflict resolution

Some data structures support merging concurrent updates without losing valid changes.

 

For example, a grow-only counter can combine increments from different replicas.

 

If India increments a counter by 3 and Europe increments it by 5, the merged value can reflect both increments.

 

Conflict-free Replicated Data Types (CRDTs) are designed to support such merging under defined operations and assumptions.

 

They are useful for distributed counters, sets, collaborative editing, and similar use cases.

 

Which approach should you choose?

Consider a banking application. Two regions should not independently update the same account balance without coordination because conflicting updates could lead to incorrect financial results. Conflict prevention through controlled writes and transactional coordination is generally more appropriate.

 

Now consider a collaborative document editor. Two users may edit different parts of a document simultaneously. Preventing all concurrent edits would unnecessarily restrict collaboration.

 

A merge-based strategy can combine compatible changes, while detecting conflicts that require user intervention.

 

The right approach depends on the business meaning of the data, not just the database architecture.

 

5.10. Comparing the Consistency Models

Let's bring the major consistency guarantees together.

Consistency model   

Guarantee    

Example

Strong consistency (linearizability)

Reads observe the latest completed write or a newer write     

Bank account balance

Eventual consistency

Replicas eventually converge if updates stop and replication succeeds

Social media likes

 

Read-after-write    

A client sees its own completed updates  

Updating a user profile

 

Monotonic reads     

A client never observes an older version after observing a newer one

Order tracking

 

 

These models are not all mutually exclusive. For example, a distributed database can use eventual replication between regions while providing read-after-write consistency for individual user sessions.

 

Similarly, an application can provide monotonic reads by routing requests to replicas that have reached the client's previously observed version.

 

The consistency guarantee should be selected based on the application's requirements.

 

In summary, Replication introduces multiple copies of data, but maintaining those copies is only part of the problem. A distributed system must also define when updates become visible, what happens when replicas disagree, and what guarantees applications can expect when reading data.

 

We explored several important concepts:

-       Strong consistency: Ensures reads observe the latest completed writes according to a globally consistent ordering.

-       Eventual consistency: Allows temporary differences between replicas but expects them to converge.

-       Read-after-write consistency: Ensures clients can observe their own completed updates.

-       Monotonic reads: Prevents clients from observing older versions after newer ones.

-       Replication lag: Explains why replicas can return stale data.

-       CAP theorem: Explains consistency and availability trade-offs during network partitions.

-       PACELC theorem: Extends the discussion to latency and consistency trade-offs during normal operation.

-       Conflict prevention and resolution: Explain how distributed systems handle concurrent updates.

 

The most important takeaway is that consistency is not a single switch that can simply be turned on or off. It is a set of guarantees that influence how applications behave when data is replicated across multiple nodes.

 

Section 6: Storage and File System Replication

Database replication focuses on keeping database records synchronized across multiple database instances. However, databases are only one part of a larger storage infrastructure.

 

Applications also depend on files, directories, disks, volumes, and file systems to store documents, images, videos, backups, configuration files, application binaries, and other data.

 

Storage replication ensures that data stored on one storage device or system is copied to another device or system. This helps protect against hardware failures, data corruption, accidental deletion, and site-level disasters.

 

For example, consider an application that stores user-uploaded documents on a storage server. If the server's disk fails, the application may lose access to those documents. By maintaining a replicated copy on another storage device, the system can continue operating even when the original storage fails.

 

Storage replication can happen at different levels:

-       Disk level: Replicating entire disks.

-       Block level: Replicating changes to individual storage blocks.

-       File level: Replicating files and directories.

-       File system level: Replicating file system changes and metadata.

-       Snapshot level: Maintaining point-in-time copies of storage.

 

Let's explore these approaches.

 

6.1 Disk Mirroring

Disk mirroring is one of the simplest forms of storage replication. It maintains an identical copy of data on two or more physical disks. Whenever an application writes data to one disk, the same data is written to another disk.

 

This is commonly implemented using RAID 1 (Redundant Array of Independent Disks).

 

How It Works?

Consider a server with two physical disks:

-       Disk 1: Primary disk.

-       Disk 2: Mirror disk.

 

When an application writes a file to Disk 1, the storage controller writes the same data to Disk 2.

 


   

What happens when a disk fails?

Suppose Disk 1 fails unexpectedly.

-       The RAID controller detects the failure.

-       The system continues serving reads and writes using Disk 2.

-       The failed disk is replaced.

-       The RAID controller copies the data from Disk 2 to the replacement disk.

-       Both disks return to a mirrored state.

 

This process is known as rebuilding the mirror.

 

Advantages

-       Simple to implement and operate.

-       Provides protection against a single disk failure.

-       Reads can potentially be distributed across both disks.

-       Usually provides good read and write performance.

 

Limitations

-       Requires twice the storage capacity for two-way mirroring.

-       Does not protect against accidental deletion or logical corruption.

-       Does not protect against server-level or data-center failures.

-       Both disks may be affected by the same power, controller, or environmental failure.

 

 

Important: Disk mirroring is primarily a hardware-level availability mechanism. It is not a complete backup strategy. If an application accidentally deletes a file, that deletion may be reflected on both disks.

 

6.2 Block-Level Replication

Block-level replication copies changes at the storage block level rather than replicating complete files.

 

A storage device is divided into fixed-size blocks. Whenever an application modifies data, the storage system identifies the affected blocks and transfers those changes to another storage device.

 

For example, consider a storage volume containing a large 10 GB file. If an application modifies only a small portion of that file, block-level replication transfers only the affected blocks instead of transferring the entire 10 GB file.

 

How It Works?

Consider two storage volumes:

-       Primary volume: Handles application reads and writes.

-       Secondary volume: Maintains a replica of the primary volume.

 

When an application modifies a block on the primary volume, the replication mechanism captures that modification and transfers it to the secondary volume.

 


The replication system maintains information about which blocks have changed and ensures that those changes are applied to the replica.

 

Types of Block-Level Replication

 

There are two common approaches:

 

a. Synchronous block replication 

A write is acknowledged only after the required copies have been written successfully according to the replication protocol.

  

This helps maintain strong write consistency between the storage copies, but increases write latency because the operation may need to wait for remote storage.

 

b. Asynchronous block replication

The primary storage acknowledges a write without waiting for the secondary storage to complete the replication.

  

Changes are transferred in the background. This reduces write latency but introduces a replication lag. If the primary storage fails before the pending changes reach the replica, some recently acknowledged writes may be lost.

 

Advantages

-       Transfers only modified blocks.

-       Suitable for large storage volumes.

-       Can replicate data independently of the file format.

-       Useful for disaster recovery and storage virtualization.

 

Limitations

-       Requires block tracking and replication coordination.

-       Replication across geographically distant locations can introduce latency and bandwidth costs.

 

6.3 File-Level Replication

File-level replication copies files and directories from one storage system to another.

 

Unlike block-level replication, which operates on storage blocks, file-level replication understands file system objects such as:

 

- File names.

- Directory structures.

- File contents.

- File permissions.

- Ownership.

- Timestamps.

- Other file metadata.

 

For example, consider an application storing customer documents in the following directory:

/customer-data
    /customer-101
        profile.pdf
        identity.png
    /customer-102
        profile.pdf
        invoice.pdf

   

A file-level replication system copies these files and their directory structures to another storage server.

 

When invoice.pdf is updated, the replication system detects the change and transfers the updated file or the changed portions, depending on the implementation.

 

File replication can be implemented in different ways:

-       Scheduled synchronization: Periodically scans directories and copies changed files.

-       Event-driven synchronization: Watches file system events and replicates changes.

-       Continuous synchronization: Continuously monitors changes and transfers them to the destination.

 

Advantages

-       Understands files and directory structures.

-       Can selectively replicate specific files and directories.

-       Allows replication between different storage systems.

-       Useful for sharing files across application servers.

 

Limitations

-       File scanning and metadata comparison can be expensive for large directories.

-       Large file changes may require significant network bandwidth.

 

6.4 File System Journal Replication

Modern file systems use journaling to protect against inconsistencies caused by unexpected shutdowns or system crashes.

 

A file system journal records metadata operations, or in some implementations both metadata and data, before those operations are committed to their final locations on disk.

 

For example, when creating a file, the file system may need to:

-       Allocate storage blocks.

-       Update directory entries.

-       Update inode metadata.

-       Record the transaction in the journal.

-       Commit the changes.

 

If the system crashes during this process, the journal helps the file system recover to a consistent state.

 

What Is Journal Replication?

File system journal replication refers to replicating journal information or journal-derived changes to another storage system.

 

Instead of repeatedly scanning all files and directories, a replication mechanism can use the journal to identify which file system operations have occurred.

 

For example:

-       A file is created.

-       A directory is modified.

-       File metadata is updated.

-       A file is deleted.

 

These changes can be identified from journal records or file system change notifications and propagated to another storage system.

 

Important distinction

A file system journal is primarily designed for local file system crash recovery. It is not automatically a replication protocol.

 

A replication implementation must interpret the journal correctly, preserve ordering, handle incomplete operations, and ensure that the destination reaches a consistent state.

 

For example, Linux file systems such as ext4 use journaling for local consistency. Tools and systems that monitor file system changes can use mechanisms such as inotify or file system specific change journals to detect changes, but these are not equivalent to replicating the journal itself.

 

Advantages

-       Can avoid repeatedly scanning large directory structures.

-       Helps identify changes efficiently.

-       Can preserve the ordering of file system operations when designed appropriately.

-       Useful for incremental synchronization.

 

Limitations

-       Journal formats and semantics are file-system-specific.

-       Journal records may be overwritten or discarded after a period.

-       Replication must recover correctly if the replication process stops.

-       A journal alone does not guarantee that a remote replica is consistent or recoverable.

 

6.5 Batch Replication and Synchronization

Not all storage replication systems need to replicate every change immediately. Some systems use batch replication, where changes are collected over a period of time and transferred together.

 

For example, consider an application that generates thousands of reports throughout the day. Instead of transferring every report immediately, the system can synchronize the files every 30 minutes or once every night.

 

How It Works?

-       Applications create or modify files on the primary storage.

-       A synchronization process identifies the changed files.

-       The system creates a list of files to replicate.

-       Changed files are transferred to the destination.

-       The destination is updated.

-       The replication process records its progress.

 

6.6 Point-in-Time Replication

Point-in-time replication maintains copies of storage data corresponding to specific moments in time.

 

Rather than simply maintaining the latest version of the data, the storage system allows users to access or restore an earlier state.

 

This is particularly useful when data is accidentally deleted, corrupted, or modified by an application bug.

 

For example, consider a document storage system:

Time 

Operation  

Document version

09:00 AM

Initial upload

Version 1

10:00 AM

Document updated 

Version 2

 

11:00 AM

Document updated 

Version 3

 

12:00 PM

Accidental deletion 

Deleted

 

If the storage system maintains point-in-time snapshots, an administrator can restore the document to its 11:00 AM state.

 

How It Works?

Point-in-time recovery is commonly implemented using snapshots, copy-on-write, redirect-on-write, and change tracking.

 

A snapshot represents the state of a storage volume at a particular moment.

 

Instead of immediately copying every block when a snapshot is created, many systems initially preserve the existing block references and copy or redirect blocks when subsequent writes occur.

 

Summary

Replication is a fundamental building block of distributed systems. It enables systems to maintain multiple copies of data across nodes, improving availability, durability, fault tolerance, and disaster recovery. From database replication to distributed storage, replication helps applications continue operating even when individual servers, disks, or entire data centers fail.

 

However, there is no universally best replication strategy. Single-leader, multi-leader, and leaderless architectures; synchronous and asynchronous replication; and physical, logical, and storage-level replication each address different requirements and introduce their own trade-offs.

 

Choosing the right replication architecture depends on application requirements, including consistency guarantees, acceptable replication lag, data volume, geographic distribution, recovery objectives, and expected workload. A strategy that works well for a financial transaction system may not be suitable for a globally distributed content delivery platform.

 

Ultimately, designing a reliable replication strategy requires balancing consistency, availability, performance, durability, and operational complexity. The goal is not simply to maintain multiple copies of data, but to ensure that those copies remain useful, recoverable, and consistent with the application's requirements, even in the presence of failures.

 

                                                                                System Design Questions

No comments:

Post a Comment