Horizontal vs Vertical Scaling: What Is the Best for You?
Mad Devs
Posted on February 14, 2022
In today's world, at least part of any business operates online. So it has a site or application that provides information about a product or service. Even if they are not the main business product, they need to be protected from attack and failures, as well as work well with any load. And here we come to scalability. In this article, we’ll discuss what is scalability and how to understand when you need it? What is traditional horizontal and vertical scalability and which one is better for you? How does scalability work with cloud computing and what it types and features?
Of course, we will not go for complicated technical details, but expose a lot of important points. Explore new options to improve your services and enjoy the reading.
What Is Scalability?
Service scalability is the ability of a web service to increase its performance by increasing the performance of internal server resources or by increasing the number of servers.
For example, you have a web application or website, and your marketing department did an excellent job of attracting a large number of users. But some of the users cannot access the website because the machine it runs isn't able to handle that many user’s requests. As a result, users get a negative experience, and many new users become a problem for you, not a victory. So you realize that you need to increase the machine's performance on which your site works. The ability to improve that performance without any base changes to the website is scalability.
When Do You Need It?
The performance increases mainly by increasing the hardware performance on which the site or application runs—for example, using a more powerful processor, faster memory, or just using a few machines. However, this requires additional funds and is often quite large. But for some reason, a significant increase in performance may not happen. First, you need to look into how your website or application is developed. Does the code provide for smooth hardware replacement? Or maybe poorly written code is the cause of latency in processing requests, not the hardware? If your main product is not software, and the website or web application only serves as customer contact, then you may not have your staff of experienced developers. In this case, we recommend turning to professionals. For example, Mad Devs provides a vavariousvices, from auditing to software development and support. We can thoroughly analyze your web service and provide comprehensive recommendations on the future scaling of your web service. In addition, we can directly scale your web service smoothly, taking care of all the individual aspects of your business. Of course, if you have your staff of experienced developers, they should do some pre-scaling work to determine whether you need it now and are you ready for it in the future.
Test Your Security
Security first. There is a chance of an attack on your web service. If this is the case, you need to pay all your attention to improving the security of your service, not pay your money on increasing performance. You can do this by looking at the statistics. If there is no periodicity in the high load, it is either a bug in the code or an attack. Don't panic. Just give it to your developers, they should know how to detect and fix it. They can also analyze the top IP addresses, parse logs, and put limits on your web service. Even if there is a periodicity, you should not immediately update the hardware. Perhaps the problem is still hidden in the code, and increasing the performance of the hardware can let you not notice it for a while. But later, it will show itself again and probably become an even bigger problem than spending money carelessly. So give your developers the task to check the code, affecting performance.
Test Your Database
One of the most common causes is the incorrect operation of the database. At a low load, such things often go unnoticed, but at a high load, everything becomes obvious. It is necessary to pay special attention to the database because problems with it lead to other problems, such as an unnecessary load of the processor, memory overflow, and so on. The problem may be in the default settings of the database server. In this case, you just need to take the time once and optimize the settings manually or use utilities that do this automatically.
Or the database may be organized incorrectly so that requests take a long time to process or even produce errors. For example, there continues to wait for data after a request when there is no data. Or in some table cells, there is too much different data or data is not indexed, and many other things are possible.
Technologies You Use
It's pretty apparent here. Suppose you are using old programming languages and outdated technologies in development. For example, if you are using the old version of PHP, you will see significant performance improvements if you rewrite your web service with the newer version of PHP. Also, using some different technologies can speed up the web service. For example, you can implement NGINX, which will cache static data and serve it to the user much faster and leave dynamic data for Apache. But trust it only to experienced developers. They know many technologies for optimizing web services and how to use them in the best way.
Hardware You Use
All previous tests helped optimize the web service code or concluded that it was initially well designed and optimized. Tests should also give a conclusion of which hardware component is failing. It could be an under-performing processor, insufficient amount or speed of memory, etc. So good reasons for scaling may be:
- To increase the size of the database
- To improve the functionality of the web service
- To grow in number of users
What Is Horizontal Scaling?
Horizontal Scaling - increasing performance by adding the number of servers to share the load between the existing and new machines. The website code must ensure smooth synchronized operation of the servers. If your code does not have this option, you will have to rewrite some of it. But even if the code provides for such an option, each time you connect a new server, you have to add some code, make additional configuration changes, and test synchronization with the rest of the servers.
Horizontal Scaling Advantages
- Allows you to distribute the load among multiple servers. This can improve both performance and fault tolerance. Especially if the servers are located in different data centers.
- Allows you to increase data security in some emergencies. Of course, there are always protected backups, but if they are on the same hardware, they are only protected by software. Storing data and its backups on several servers is hardware protection, which takes data security to a whole new level.
- Allows you to optimize the architecture of web services. Sometimes, due to some architectural specifics of the web service, its components can interfere with each other in one place. It doesn't sound quite logical, but experienced developers know about it. Of course, you can always run the service on a more powerful machine, but sometimes it is better to place some of its components on different machines. Also, using separate servers for the web and data layers allows them to scale independently of each other.
- Horizontal scaling is not limited at all, unlike vertical scaling. You can increase the number of servers endlessly with the proper software. Ultimately, this is a necessary stage for any vast service.
Horizontal Scaling Disadvantages
- It's more challenging to support. Whenever a new server is added, you need to configure synchronized operations between them, more care about the logic of communication and resource allocation.
- It doesn’t improve performance as much as vertical scaling. Sure, enough machines will enhance performance, but the quality is always more important than the amount.
- Many servers can be more expensive to support over a long time. Each server is a separate machine, with its software that you have to pay for a license and, of course, paying for renting the machine itself. Also, the more machines that work together, the more complicated their interaction is, which means you will need to hire more skilled and expensive developers, and you will need more and more of them.
What Is Vertical Scaling?
Vertical Scaling - increasing performance by changing components in the exciting server with more power. For example, installing a more powerful processor, faster memory, or more memory. Most likely, you won't have to make any changes to your code. But you will have to do some minimal additional settings.
Vertical Scaling Advantages
- Allows you to make little or no changes to the web service code while increasing performance. Since your web service is still on the single machine, you don't have to worry about additional complications as with multiple machines working together.
- Allows you to increase performance several times quickly. The latest generation processor can be more powerful than a dozen processors from five years ago. But even if the number of processors can increase the power, the memory will not become faster from more of it.
- Allows you to use a specific set of technologies. More advanced components can be more performant, but they can also have architectural solutions that were not available in previous components. In doing this, you do not have to improve the other components, which do not necessarily have to be the most advanced for your tasks. For example, tensor cores in today’s graphics cards allow you to do more complex calculations more efficiently, such as those from artificial intelligence and machine learning.
Vertical Scaling Disadvantages
- It has limitations. Of course, you can't increase the performance of your computer indefinitely. The operating system limits the number of components you can use.
- In an emergency case, the complete service goes down. Since everything works on one machine, any changes require a system restart, and any failures make the service unavailable for a while. Fault tolerance is provided only by software, not hardware.
Horizontal and Vertical Scaling in Cloud Computing
The problem with all previous approaches is that we are dealing with the modification or connection of new hardware. And this is always a lot of extra money, more time to find, buy and install hardware in data centers, debug and test it, and so on. A great alternative is horizontal and vertical scaling in cloud computing, of which Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform are good examples. They allow you to instantly change the configuration and number of machines that make your web service perform.
Manual Scaling
Manual scaling is done manually by the developer. Yes, when it comes to cloud scaling, it is much easier than in the case of data centers. But it still involves more configurations. And since there is a human factor involved, an error is not excluded.
Scheduled Scaling
Schedule scaling does not have the disadvantages of manual scaling. Based on statistics, you can plan the increase of available resources depending on the attendance of web service at different times of the day or days of the month. However, you need additional analysis of load statistics.
Auto Scaling
Auto Scaling allows you to configure the web service to automatically increase or decrease the performance depending on different load types. By analyzing various scenarios and load levels depending on them, you can improve the processor's performance, give access to more memory, etc. This allows you to optimize the provisioning of resources relative to the amount of load and save as much money and time in the future as possible. But this requires careful analysis and configuration initially.
Summary
So scalability and technologies are what you have to care about a lot. We hope that our article has helped you understand its main aspects and understand if you need to scale and what kind of scalability to pay attention to. However, it is safe to say that scaling with cloud technology has vast advantages relative to the rapidly changing world we live in today.
Here at Mad Devs, we follow the market and industry trends very closely and help you understand and start using the latest technologies so that any business has the infrastructure it needs to be fully confident in its future. Take a look at the full list of our services, customers, and their experiences, and the right decision will not belong in coming.
Previously published at maddevs.io/blog.
Posted on February 14, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.