DEV Community

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

Posted on

1

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

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

πŸ‘‹ Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay