System design: Horizontal vs vertical scaling- 1 min
Imagine we have a REST API service, which provides services to customers who pay. The service surely resides in a server. The server could be in the cloud or a personal server.
What if, after a successful year of campaign customer base almost tripled. Now the server needs scaling as it is not initially made for that kind of load.
There’s two types of scaling
- Horizontal Scaling
- Vertical Scaling
If you are adding more and more servers to the system, that is called horizontal scaling. For a horizontally scaled system
- Even if a single server went down, the whole service doesn’t just fall.
- Network communication with other servers are slow.
- We have to set load balancer as there are more and more servers are included.
- Data consistency is a burning issue
- If customers increase, the scaling is easy to maintain.
In case you are increasing resources (like ram, storage) in the same server that is called Vertical scaling. In vertical scaling,
- This is a single-point failure.
- Interprocess communication is faster.
- There’s no need for LB.
- Consistent data
So which one should we use? This depends on the requirement. You need to consider what at stake if scale out or scale up the server.