KyoMel / Yogyakarta, Indonesia

Term 014014 / 344

Replica Technique in System Design

Month
July 2025
Day
14
Source
2025/july-term.md

Definition:

Replica Technique is a design pattern used in distributed systems to enhance reliability, availability, and performance by creating multiple copies (replicas) of data or services across different nodes.

Key Benefits ⚑ High Availability - System remains operational even if some replicas fail πŸš€ Performance - Reduced latency through geographical distribution πŸ›‘οΈ Fault Tolerance - Data redundancy prevents single point of failure πŸ“ˆ Scalability - Load distribution across multiple replicas

Types of Replication:

  • Master-Slave Replication: One master node handles writes, while multiple slave nodes handle reads. Use case: Read-heavy applications like web servers.
  • Master-Master Replication: Multiple nodes can handle both reads and writes. Use case: High write availability systems where any node can accept writes.
  • Peer-to-Peer: All nodes are equal, and each can read/write data. Use case: disributed systems like blockchain.

Example:

E-commerce Database Replication(scenario: Amazon-like online store)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Master    β”‚    β”‚   Slave 1   β”‚    β”‚   Slave 2   β”‚
β”‚  Database   │───▢│  (US East)  β”‚    β”‚  (Europe)   β”‚
β”‚   (Main)    β”‚    β”‚             β”‚    β”‚             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                   β”‚                   β”‚
       β–Ό                   β–Ό                   β–Ό
   All Writes         Read Queries        Read Queries
   (Orders, Users)    (Product Info)     (Product Info)

Implementation Strategy

  • Master Database 🎯

Handles all write operations (new orders, user registration) Located in primary data center

  • Read Replicas πŸ“–

Handle read queries (product searches, user profiles) Distributed globally for reduced latency

  • Replication Process πŸ”„
-- Master receives write
INSERT INTO orders (user_id, product_id, amount)
VALUES (123, 456, 99.99);

-- Changes replicated to slaves asynchronously
-- Users in different regions read from nearest replica

Keep reading