When your app grows, you are sure to consider scaling. What kind of scale you will need depends on your app. You might have heard various buzzwords, such as vertical scaling, horizontal scaling, scale-up, scale-down, and many more. In this article, we will discuss what is scaling, the difference between vertical and horizontal scaling, and what might be good for your application. We will discuss this in the context of the AWS cloud platform as it is one of the largest cloud platforms in the world.
To discuss the difference between vertical and horizontal scaling, first, we need to learn about what is scalability. The hardware on the server runs on limited resources. Whenever there is more request on the server to handle, it’s called the limit of scalability. At that time, your server, more specifically, CPU, ram, storage, and network devices are at their limit. So you need to consider adding more resources to handle more requests. You can do this manually. But cloud infrastructure like AWS provides ways to auto-scale.
When increasing the resources of the AWS infrastructure, one can scale in two ways: Vertical scaling and Horizontal scaling.
For vertical scaling, the server equipment is upgraded. The upgrade is done on the same logical unit of computation. So, 1 core CPU can become 2 core CPU, giving more CPU power to the user. The same goes for the ram, storage, and other resources. One obstacle in the way of increasing vertically is, there is a limit to increasing hardware capacity. The power required for a device might be too much for the grid or device to handle.
When the resources are increased for vertical scaling, it’s called scale-up; if the resources are decreased, it’s called scale-down.
With horizontal scaling, the user can add more EC2 to the available resources. Thus giving more computation ability over multiple virtual devices. When scaling horizontally, the individual devices’ capacity remains the same. Databases can also be scaled in the horizontal direction. AWS provides load balancers to distribute incoming traffic between multiple instances.
For horizontal scaling, if the resources are increased, it’s called scale-out, if the resources are decreased, it’s called scale-in.
Horizontal Scaling vs Vertical Scaling
Both scalings have their benefits. It all depends on the system architecture, requirements, and preferences of the developer. The main difference between the two scaling types can be summarized by, the way they are increasing their hardware specification and if the sequential code execution and data processing is subdivided or not.
As discussed above, vertical scaling has its hardware density limitation. You can only increase your hardware specification to a certain degree. But vertical scaling is very enticing due to its implementation. As all the hardware resources are in the same logical unit, the code can execute sequentially in the same hardware space. This makes the system architecture of your application easy to maintain and upgrade. But the downside of vertical scaling is: there is a single point of failure. If any error occurs on your device, the whole service will get down.
In theory, horizontal scaling can provide infinite scaling opportunities. Multiple instances can be synced with a Load Balancer to divide the incoming traffic. But the clustering and management of the application over multiple instances can be a tedious task for the developers. The benefit of horizontal scaling is there isn’t any single point of failure. Even if a few instances get corrupted for some reason, the application can still run successfully. The downside of horizontal scaling is: complexity will increase with scaling; so it’s up to the development team to decide on the system architecture. As the same code will run on multiple devices, the programmers must consider how many resources they can use per instance. The same also goes for databases. The other big benefit of horizontal scaling is: while upgrading there is no downtime; each instance can be upgraded separately.
What to Use for Your Application
Both types of scaling have their pros and cons. It all depends on how you are trying to put effort into your administrative tasks. Horizontal scaling requires a lot of administrative management compared to vertical scaling.
When your application is serverless, it makes sense to use horizontal scaling. For horizontal scaling, you have to consider how your application is distributed. If there isn’t concurrent dependency on your database, and your application is microservice based, then horizontal scaling can be optimal.
If you are considering spending less on administrative tasks, and your application load is bearable by available computing devices, then you should not make your architecture complicated and go for the vertical scaling. The cost for vertical scaling is lower than horizontal scaling.
There can be applications that use both scaling types. For sections of your application that are not dependent on data, you can use horizontal scaling. This also increases complexity. It’s up to the system architect to decide.
We have discussed what scaling is, and the difference between vertical and horizontal spacing. We have also discussed what types of scaling you should consider when developing your application. In the end, it depends on how you are trying to create your system architecture and how you are intending to manage complexity and cost.