Scalability explained by a pigeon

Scalability explained by a pigeon

An illustrated explanation of software scalability

Hi reader :). Welcome to PigeonDev. I am your host, the PiseWigeon and in this post, I will be talking about Scalability. If you don't know what that is, then I will try my best to explain it in this article, and in case you know what that is, please do read the article, I might say something wrong and will be very happy to hear from more experienced people. So, without further a do, let's get into this.

Introduction

This, is Jacob. image_2022-09-25_203116073.png

Jacob is a web developer, and for the past months, he has been building a web app that will help him find his cat whenever it get lost. Now let's say, a friend of Jacob looses his cat and Jacob uses his app to help his friend find the cat. The friend is super impressed, he talks about the app to his colleagues and suddenly, the entire world knows about Jacob's app and would like to use it. Jacob then make his app accessible via an API which takes in the picture of the cat and returns its exact location as response

image_2022-09-25_205847033.png

All requests are sent to Jacob's computer, which is the app's host, it means that all the data generated by the app is stored on that computer. This wouldn't cause any problem if Jacob only had like 10 users, even if it was the case, whenever Jacob's computer would turn off or not have access to internet, his users won't be able to use his app. Jacob has to host his app on the Cloud.

What is the difference between Jacob's computer and that cloud you might ask?

Well the cloud is a set of computers that is provided by a company that has the money and infrastructure to make sure these computers are always on and connected to the internet. Developers can then "rent" these computers, deploy their app and pay a relatively reasonable amount of money for that service. Hosting his app on a cloud will not only make the response time a little bit faster because of the computation power and internet speed of the cloud computers, but also make the app available all the time, unless Jacob doesn't pay his subscription.

image.png

Now, the fact that Jacob deployed his app on a cloud and made it faster, brings him a million users, all of them are sending their requests to a single computer which is causing the server to lag and not work properly. Jacob needs a solution and has mainly two options:

  • Buy a more powerful computer in the cloud

image.png

  • Buy more computers in the cloud

image.png

The ability to handle more requests, by buying a bigger(more powerful) computer, or buying more computers, is called Scalability.

Scalability refers to the ability to increase or decrease resources as needed to meet changing demand.

By buying a bigger computer to make his app run faster, Jacob would be doing what is called Vertical Scaling. And by buying more computers so that not only one have to deal with the requests, he would be doing Horizontal Scaling.

Now let's look at some specific characteristics of both of these scaling methods.

Horizontal scaling:

  • Data inconsistency (The data is spread across all computers, thus is not in one place)
  • Limitless scaling (One can add as much computers as he can afford)
  • Requires Load Balancing (A load balancer is the system that will efficiently distribute the traffic across all the computers)
  • Resilient (If one machine crashes, the app won't go down because there will be many more computers still running it)
  • Uses Remote Procedure Calls (To share data between themselves computers will have to communicate via network calls)

Vertical scaling:

  • Hardware limitation (If you already have the most powerful computer in the world and so much users that even that computer is struggling, you can't do much, you have to wait for a more powerful hardware to be released and then buy it)
  • Have a single point of failure (Having that the app is running on a single computer, if it happens to crash on that computer, you will have to solve the issue and relaunch the app before anyone can access it)
  • Uses Inter Process Communication (All the data needed is available in the different processes on the same machine, it is faster than network calls)
  • Does not need load balancing
  • Has Data consistency (All the data is in one place)

As you can see, both of these methods have their pros and cons, you can't really tell if one is better than the other, the choice of the scaling method has to be based upon some specific requirements. There is an hybrid solution that consist in buying more computers and increase the power of these computers at the same time. For example, instead of buying 10 more computers, one would buy 5 and then double the computation power of each new machine.

image.png

That will do it for today. I will be making another post discussing every characteristics that I mentioned in this post, with more details and examples. I really hope you find this post interesting, if so, follow me for more. If you notice something wrong in this post, please let me know, I will be very happy to hear from you.

It's been a pleasure, I will see you in the next one.

I use excalidraw for the illustrations. You can find all the illustrations from this post here