วันพุธที่ 18 กันยายน พ.ศ. 2567

Load balancing db servers

The master-slave (or primary-replica) database architecture is a common approach for handling database load and ensuring data redundancy. In this setup:

1. Master (Primary): The master server handles all write operations (insert, update, delete). It's the authoritative source of data.

2. Slave (Replica): Slave servers are read-only copies of the master. They replicate data from the master server, often in near real-time, and are typically used for read operations (queries).

While this setup does provide some level of load balancing (by offloading read queries to slave servers), it doesn’t fully balance the load for write operations, as all writes go through the master. This can become a bottleneck in write-heavy environments.

For true write-load balancing or higher scalability, other architectures like multi-master replication or distributed databases (e.g., Cassandra, CockroachDB) might be used, where multiple servers can handle both reads and writes. However, the master-slave approach remains widely used due to its simplicity and reliability, especially for applications with more read-heavy workloads.