Lecture 8
Lecture 8
2. Asynchronous Replication:
o Changes are made to a primary replica and then propagated to other replicas over time.
o Pros: Faster writes because the system does not wait for all replicas to confirm.
o Cons: Temporary inconsistency since other replicas might not have the latest data
immediately.
o Example: Social media posts may use asynchronous replication, where updates can
propagate over a few seconds without causing issues.
3. Types of Replication in Distributed Systems(cont.)
3. Multi-Master Replication:
• Allows updates on multiple replicas simultaneously, which are then synchronized across
replicas.
• Cons: Conflict resolution is challenging, as multiple replicas might have conflicting updates.
• Example: Collaboration tools like Google Docs use multi-master replication to allow multiple
users to edit documents simultaneously.
3. Types of Replication in Distributed Systems(cont.)
• A primary replica handles all writes, and other replicas (backups) receive updates from the
primary.
• Cons: The primary node can be a bottleneck and a single point of failure.
• Example: A website with a master database that replicates data to read-only replicas to
handle traffic more efficiently.
4. Consistency Models in Distributed Replication
Consistency refers to the state of data across replicas. Different models offer different levels of consistency:
1. Strong Consistency:
• Guarantees that all replicas reflect the latest write before any read operation.
• Use Case: Critical systems where accurate data is essential, like online banking.
2. Eventual Consistency:
• Guarantees that, in the absence of new updates, all replicas will eventually become consistent.
• Use Case: Social media platforms where a few seconds of inconsistency don’t cause issues.
3. Causal Consistency:
• Ensures that if one operation causally affects another, the system respects this order in replication.
• Use Case: Messaging applications where responses should follow messages in order.
4. Read-After-Write Consistency:
• Ensures that once a write completes, the client can read the updated data immediately.
• Use Case: Blog platforms, where users should see their posts immediately after publishing.
5. Challenges in Distributed Data Replication
1. Consistency vs. Availability (CAP Theorem):
o The CAP Theorem states that in any distributed data system, you can only choose two of
the following three guarantees:
o Implication: Choosing between these factors impacts the design of the distributed
system. For instance, systems that prioritize availability and partition tolerance may
sacrifice consistency (eventual consistency).
5. Challenges in Distributed Data Replication (cont.)
2. Conflict Resolution:
o Techniques to resolve conflicts include:
▪ Timestamping: Keeping the most recent update.
▪ Vector Clocks: Tracking the order of operations across nodes.
▪ Application Logic: Using domain-specific rules (like majority vote) to handle conflicts.
3. Data Latency:
o Replication adds network overhead, as data needs to be copied to multiple locations.
o Trade-offs must be considered between data accuracy and the speed of access.
4. Fault Detection and Failover:
o Detecting failed nodes and rerouting requests to healthy replicas requires careful coordination.
o Load balancers or distributed algorithms (like Paxos or Raft) help manage failover and maintain
system stability.
6. Examples and Use Cases
• Google Search Infrastructure: Google replicates search data across multiple data
centers globally, ensuring fast access and reliability.
• Netflix: Uses distributed data replication to store and stream media content across
the world, reducing latency and providing a seamless user experience.
• Amazon Web Services (AWS) S3: AWS S3 replicates data in multiple geographic
locations for redundancy and disaster recovery.
7. Trade-Offs and Real-World Considerations
• Performance vs. Consistency:
A highly available system may prioritize quick responses over having the latest data,
while a highly consistent system may experience delays.
• Cost:
Data replication requires additional storage, bandwidth, and hardware, which can
increase operational costs.
• Geographic Distribution and Legal Considerations:
Some regions have regulations requiring data to stay within specific geographic
boundaries, influencing where and how data is replicated.