This content originally appeared on DEV Community and was authored by Tanisk Annpurna
- 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)
- 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 :
- SYNCHRONOUS
- 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
- More response time
- Slower writes
- Zero replication logs
- Very strong consistency.
- ASYNCHRONOUS
- 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
- Small response time
- Faster writes as it doesn't write on multiple db at a time, some replication logs
- Eventual consistency.
This content originally appeared on DEV Community and was authored by Tanisk Annpurna
Tanisk Annpurna | Sciencx (2024-06-21T18:39:43+00:00) DAY3 -> Scaling Databases (Replication). Retrieved from https://www.scien.cx/2024/06/21/day3-scaling-databases-replication/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.