Scale Horizontally vs. Vertically2 min read

Scalability is the process of designing and configuring a system so that it can be expanded and adjusted to meet the requirements when the complexity of a system becomes increases. In other words, scalability means there should be a reasonable way to deal with the system when it grows.

For example, we have a server that handles 1000 requests per day, but a few weeks later on a daily basis, we have roughly 10000 requests. With the current configuration, we run the server on our personal computer, let’s say we have 16GB of RAM, CPU Intel Core i5, and 500GB of SSD storage. Let presumes it works pretty fine with 1000 requests per day, but it starts lagging and our server seems cannot handle all 10000 requests per day together, there are 2 things we can do to cope with the new amount of traffic, either we still use this server and upgrade our existing resources, so we upgrade the CPU to Intel Core i7, increase the amount of RAM to 32GB and replace the physical storage with 1000GB SSD, we basically don’t add a new server and we only update existing resources our server has, this is called “vertical scaling“. On the contrary, if we keep the existing server as it is and adding more servers to handle the traffic, this is called “horizontally scaling“.

With vertical scaling, the benefit it brings to the table is it’s easy to implement and maintain, and also not much cost is added. However, there are some drawbacks with this approach, it’s not fault-tolerant, because when our server dies, there is no resource available to handle incoming requests, the downtime is high and there is a high disk of hardware failure, these properties lead to bad user experience.

With horizontal scaling, it addresses all the drawbacks of the vertical scaling approach, because there are multiple servers available, if a server dies, the process of serving client requests will not be stopped since there are servers available to handle the traffic, so horizontal scaling is fault-tolerant or resilient, and with the help of a load balancer, the traffic will be will-dispersed to multiple servers available which increases the throughput and decrease the latency hence boosting user experience, the built-in backup will be available in case of system failure. However, it comes with a price, of course, horizontal scaling is hard to implement and maintain, the cost is high, and usually, some kind of load balancers are required.