- 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.
Top comments (0)