SkillSprout
Chapter 17 · Lesson 1
Beginner
4 min read

Redundancy vs Replication: Synchronous and Asynchronous

Overview

Every machine, disk and network link will fail eventually. If your system depends on just one of anything, one failure takes it down.

This lesson explains how keeping extra copies solves this, and the key choice of how quickly copies are updated.

Detailed Notes

What is redundancy and replication

  • Redundancy means having spare components so that if one fails, another can take over: two web servers, two power supplies, two network paths.
  • Replication is redundancy for data: keeping the same data on more than one machine, and keeping those copies up to date. Each copy is called a replica.

The problem it solves

A component that, if it fails, stops the whole system is a single point of failure. A single database server is a classic one: if its disk dies, you lose data and the app is down.

Replication gives two benefits:

  1. Reliability: if one machine dies, another has the data.
  2. Read capacity and speed: many replicas can answer read requests at once, and replicas placed near users answer faster.

How it works

One machine accepts changes first. Plain words for now: one copy is the main copy that receives writes, and it sends each change to the other copies. (Who is in charge and how they agree are big topics, covered later in the course.)

The big question is when the main copy tells the client "done":

Synchronous replication. The main copy waits until the replica confirms it has stored the change, and only then replies.

  • Good: the replica is never behind, so no data is lost if the main copy dies.
  • Bad: every write is slower, and if the replica is down or slow, writes stall.

Asynchronous replication. The main copy replies right after saving the change itself, and sends it to replicas in the background.

  • Good: fast writes, and a slow replica does not block anyone.
  • Bad: replication lag, a short delay during which replicas are behind. A user might write something, then read from a replica that does not have it yet. If the main copy dies at the wrong moment, the latest writes can be lost.

Many systems mix them: one replica is synchronous (for safety) and the others are asynchronous (for speed).

SynchronousAsynchronous
Write speedSlowerFaster
Replica up to dateYesSlightly behind
Data loss on failureNone for confirmed writesPossible for recent writes
If a replica is downWrites may blockWrites continue

A simple example

You write a note and a friend keeps a copy. Synchronous: you hand over the note, wait for them to copy it and say "got it", then walk away. Safe but slow. Asynchronous: you hand over the note and leave; they copy it later. Fast, but if you lose your original before they finish, the note is gone.

System design example

A shop's database has a main server and two read replicas. Product pages read from the replicas, so the main server only handles orders. Because replication is asynchronous, a customer who just changed their address might see the old one for a second. To avoid confusion, the app reads that user's own data from the main server for a few seconds after a write. For payments, the team uses a synchronous replica so no confirmed payment is ever lost.

Summary

  • Redundancy is spare components; replication is spare copies of data.
  • Both remove single points of failure.
  • Replicas also add read capacity and can be placed near users.
  • Synchronous replication is safe but slower; asynchronous is fast but has lag.
  • Replication lag means a replica can briefly return old data.

Architecture Diagram

Main copy with replicas
Architecture
Clients
Main copy

Replicas

Replica 1
Replica 2

Writes go to the main copy; changes flow to replicas.

  1. 1A client sends a write to the main copy.
  2. 2The main copy saves it and sends the change to replicas.
  3. 3Synchronous: it waits for confirmation before replying.
  4. 4Asynchronous: it replies first; replicas catch up shortly after.

Common Interview Questions

Finished this lesson?

0 of 91 lessons done · 0% of the course