DEV Community

Cover image for DAY3 -> Scaling Databases (Replication)
Tanisk Annpurna
Tanisk Annpurna

Posted on

DAY3 -> Scaling Databases (Replication)

  • As in my previous blogs, We talked about vertical scaling. In this We will talk about Horizontal Scaling.

HORIZONTAL SCALING

  • We know that for any db read & write ratio is 90:10;
  • The very basic scaling that we can do is have separate db just for reading and separate db for writing.
  • Through API we can send request to replica DB(Read operation) and Master DB(Write operation).

It would look something like shown below. (Replica DB can be multiple)

Master DB with Replicas

  • Data consistency becomes a big part as we don't want data to be different in replica db and in master db. So, its very important to replicate the data.

There are mainly 2 ways to replicate :

  1. SYNCHRONOUS
  2. This means that when there is any write/update operation then through code or DB, we also update replica DB at the same time thus resulting in
  3. More response time
  4. Slower writes
  5. Zero replication logs
  6. Very strong consistency.

Synchronous replication

  1. ASYNCHRONOUS
  2. This means that we keep logs of all the write operations on master db and at certain time we just run those logs on replica dbs. This results in
  3. Small response time
  4. Faster writes as it doesn't write on multiple db at a time, some replication logs
  5. Eventual consistency.

Asynchronous replication

Top comments (0)