0
0
HLDsystem_design~3 mins

Why Database replication (master-slave) in HLD? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if your website never slowed down or crashed, no matter how many visitors came?

The Scenario

Imagine running a busy online store where all customer orders are saved in a single database. When many people shop at once, the database gets overwhelmed, slowing down the whole site and making customers wait.

The Problem

Using just one database means every read and write request waits in line. If the database crashes, the whole store stops. Fixing this manually is slow and risky, causing lost sales and unhappy customers.

The Solution

Database replication with master-slave setup copies data from one main database (master) to one or more copies (slaves). Reads can happen on slaves, spreading the load and keeping the system fast and reliable even if one database fails.

Before vs After
Before
all_reads_and_writes_to_master()
After
write_to_master(); read_from_slave();
What It Enables

This lets your system handle many users smoothly and stay online even if one database has problems.

Real Life Example

Popular social media platforms use master-slave replication to show posts quickly to millions while safely saving new posts without delay.

Key Takeaways

Single database struggles with heavy traffic and risks downtime.

Master-slave replication spreads read load and improves reliability.

It keeps applications fast and available for many users.