Skip to main content

Horizontal vs. vertical scaling. What is the difference?

· 5 min read
Alexander Röse
Software Developer

With increasing demands on the performance and availability of applications and systems, the question arises as to how these requirements can be met. One option is to scale the existing infrastructure in order to improve performance and availability. A distinction is made between horizontal and vertical scaling. But what is the difference between the two approaches and which one should you choose?

Requirements for the programming code

In addition to the requirement for the scalability of the infrastructure, the programming code also plays an important role. A well-structured and modular code facilitates horizontal scaling, as the application can be divided into several instances. This makes it easier to fulfil performance and availability requirements. With vertical scaling, on the other hand, it is more difficult to divide the application into several instances, as the resources on one instance are limited. It is therefore important to clarify in advance what requirements are placed on the programming code and how it should be structured.

Example based on a mobile app

Suppose you have the idea of developing a mobile app. Then you should start by deciding in which programming language the app should be developed. If you have sufficient capacity for developers to develop the mobile app separately for Android and iOS, it is advisable to develop the app in the native programming languages Kotlin and Swift. This allows you to better adapt the app to the respective operating systems and improve performance and availability. If, on the other hand, you only have limited capacity and want to develop the app quickly, we recommend developing the app in a cross-platform programming language such as Flutter or React Native. This allows you to develop the app faster and benefit from the advantage of having only one code base instead of two separate code bases for Android and iOS. Before deciding on a programming language, consider the requirements of your project and which native functions you need.

Assuming you have decided in favour of Flutter, you now need to select the appropriate database for the app and decide in which programming language you want to develop the backend.

On-premise vs. cloud hosting

Another important aspect when scaling applications and systems is the choice between on-premise and cloud. On-premise means that the infrastructure is operated in your own data centre, while cloud means that the infrastructure is operated in an external data centre. Both approaches have their advantages and disadvantages that need to be taken into account. With on-premise, you have full control over the infrastructure, whereas with cloud, the infrastructure is flexible and scalable. Before deciding in favour of one of the two approaches, you should consider the performance and availability requirements as well as the costs and effort involved in operating the infrastructure.

Vertical scaling

To keep things simple here, we have opted for a basic server infrastructure in which an Nginx proxy forwards the incoming requests to the various services. In practice, however, the architecture becomes more complex, as additional components such as load balancers and Cloudflare can be used.

When the first users start using your app and the number of requests increases, it is important to use the monitoring tool to recognise when you need to increase the server capacity based on the server load.

Now you have reached the point where your app is getting bigger and the number of requests is increasing. The example clearly shows how the utilisation of the servers has increased and you need to increase the server capacity.

With vertical scaling, the performance and availability of a server is improved by adding resources such as CPU, RAM and hard disk space. This approach has the advantage that the application runs on a single server and resources can be added easily. However, there are also disadvantages, such as limited scalability and higher costs compared to horizontal scaling. Here, for example, we scaled from a 1-core, 8 GB RAM and 1 TB SSD to a 4-core, 32 GB RAM and 4 TB SSD server.

If your app continues to grow, you will eventually reach the point where you can no longer increase the server capacity vertically. Then it's time to think about horizontal scaling.

Horizontal scaling

You have just seen that vertical scaling has reached its limits. Now it's time to think about horizontal scaling. Horizontal scaling improves the performance and availability of an application by adding more server instances. The advantage of this approach is that the application runs on multiple servers and the load is distributed evenly. As a result, performance and availability requirements can be better met. However, there are also disadvantages, such as the complexity of the infrastructure and the higher costs compared to vertical scaling.

Conclusion

Overall, it is important to know the performance and availability requirements of an application or system in order to choose the right scaling strategy. Both approaches, horizontal and vertical scaling, have their advantages and disadvantages that need to be taken into account. It is therefore important to clarify in advance what the performance and availability requirements are and how these can best be met.

Ready for your next project?

Arrange a non-binding initial consultation with us now and we will show you how we can realise your project.

Start now