On the importance and the different types of scaling

Juan Pablo Rodríguez (ornitie)
To Journal, To Dev
Published in
4 min readJan 19, 2021

Vertical vs. Horizontal, what? When? And how?

Containers can facilitate the process. Photo by Guillaume Bolduc on Unsplash

There comes a time in every online application’s life (every growing one, at least) when it needs to scale. Your old server just can’t handle the amount of requests it is getting.

Now, many online services like Amazon provide auto scaling, but if you’ve heard about AWS pricing and how high it can be, you know that you should use the tools it provides in the right way. That is, you need to scale and do it right.

Now, this article is gonna refer to scaling regarding software, that is, regarding the broad service perspective and the amount of resoures dedicated to it, another way of scaling are the specifics of the code itself and how it handles increasing amounts of data (normally denoted with the famous Big O notation).

But first, we should talk about what is scaling and why it is important.

Scaling

Scaling is the property that your system has to handle increasing loads, either because it is handling more operations or more complex ones. Think about an online store that has to handle much more concurrent orders or a blog that has to serve content to much more visitors at the same time. Scalable software is important because it has the capability to handle those situations without crashing.

Vertical Scaling

One of the ways you can approach scaling is doing it vertically, that is giving more power and resources to the instances you currently have. Think about one super server that handles all your operations, something really common in monolithic architectures. In those cases, you use vertical scaling to give that server more CPU and memory power so it can handle the increasing demand in a better way. This is the way that services like AWS handle scaling and is why it’s famous for increasing prices apparently out of nowhere.

Pros:

  • It’s faster to scale both up (increase the resources) and down (decrease the resources after the rush)
  • It’s easier to implement, as I said, most online services provide vertical scaling (sometimes even automatically)
  • Great for smaller and monolithic systems

Cons:

  • It increases the chances of Single Point of Failure issues, the less instances, the more critical they are
  • Can be more expensive since more resources on a single server are costly.
  • Can actually scale worse under higher stress
  • Normally is peaked at some point, can’t scale out forever

Horizontal Scaling

Horizontal scaling is an approach that is common in more distributed architectures like SOA or microservices architectures, although you can also apply it to monolithic systems. Think about the same case before, you have your super server (or the bottleneck service) and you need to scale it. Now, instead of giving more resources to it, you could just increase the instances of that service, so instead of one service that handles 100% of the requests, you’d have two services that should distribute the load equally.

Pros:

  • It handles persistent increase on requests much better
  • Can scale as much as it is needed
  • Scales better since many instances share the load instead of stressing just one instance
  • Reduces bottlenecks and Single Point of Failure issues and the impact when one instance crashes

Cons:

  • Can be harder to implement from both an infrastructure POV and a software development POV, since not all systems can scale and handle concurrency this way
  • Can be traumatic to scale down, since killing an instance can kill the transactions that it is currently handling

Vertical vs Horizontal

Now, which one should you apply? As it is with most software decitions, it always depends. You should take into consideration things like the overall load that your system will handle and the stress that it will be put trough.

Think about a small system that might experience a one time increase in requests, well then vertical scaling should be better since it scales faster and easier, both up and down.

But maybe you have a system that is designed to handle periodically increasing request or that those requests would persist over time, well then you should use horizontal because it not only is cheaper but it also is safer since you do not deppend on fewer instances that might collapse and crash the whole thing.

One important takeaway is that there is no silver bullet, so you should take everything said in this article with a pinch of salt, every situation is different and every software too. Hopefully though, you’ve learned a bit about scaling and how both ways of doing it can be appropiate for your situation.

--

--

Juan Pablo Rodríguez (ornitie)
To Journal, To Dev

Desarrollador de Software, con hambre de aprender, con gusto por escribir y con ansias de programar.