To understand it better, let’s try to take a real world example first then we will go to the detail of these two types of scaling.
Imagine we have written some code inside our computer. It does the following things:
- Accepts the request from client
- Processes it and
- Sends response back to the client
Now, the client is really impressed with our code so they decided to use and ready to pay us for it.
Now, let’s consider a scenario.
This application is running inside our computer and we can’t give our computer to all the customers that they are wanting to use our code/application.
This is not possible and obviously we don’t want to do this.
So, the alternate solution would be to expose our application/code running in the internet as an API and give access to all or our customer so that they can request to our API, our code processes it and sends response back to the customer. This is fine.
What happens when there is a power cut or internet connection loss? Our computer is not accessible by the customers. Isn’t it?
We can’t afford to our service go down. Because, our customer are paying money to us for the code/application we have written.
To solve this problem, we will go for the cloud.
The cloud is a set of computers that somebody/company provides us and we have to pay when we use it.
We don’t have to worry about the power cut or internet connection, security issues and etc, when we are using the cloud.
Cloud providers like AWS will provide all the set of computers that we can use to run our services and they will be taking care of reliability.
There could be a scenario when we have many customers and using the application that we have build and this application is unable to handle all the request coming from the clients.
Now we have two options:
- Buy a bigger machine or
- Buy multiple machines
The ability to handle more request either by buying multiple machines or by buying a bigger machine is called a scalability.
Scalability
The ability to handle more request either by buying multiple machines or by buying a bigger machine is called a scalability.
So the conclusion is we can handle more request by spending more money. This is because, we have to spend more money whether to buy bigger machine or to buy multiple machines.
When we buy a bigger machine it will have more processing and memory power so that it can process the request faster. This is called Vertical Scaling.
When we are buying more machines the request can go to any machines so the distributed request can reduce the request load to a single computer and process fast. This is called Horizontal Scaling.
This is called the scalability of the system. Which means be able to handle more request.
Pros and Cons of Vertical and Horizontal scaling
Horizontal
Pros
- Resilient
- If one server crashes some other will come up to solve the problem
- Scales well as user increases
Cons
- Load balancing required
- More network calls
- Data inconsistency
Vertical
Pros
- Inner process communication makes faster to process
- Consistency
Cons
- Hardware limit
- Single point of failure
- Because we only have a single machine if it crashes then application will stop accepting the request.
Conclusion
In this post we learn the vertical and horizontal scaling with the simple use case.
Leave a Reply