In Computer Science, Scaling refers to the aspect of adopting a system or application to handle a larger volume of requests, data, users or transactions.
Let me explain it with an example.
Suppose you developed an application, that takes image of one type and convert it into image of different type. For example,
a. User can convert a .png to .jpeg using your application
b. User can convert a .jpeg. to .png etc.,
Your service has gained significant traction, with a growing user base. Consequently, the existing infrastructure is struggling to cope with the substantial increase in traffic. To tackle this issue, we have two potential solutions:
a. Invest in a more powerful server.
b. Procure more machines and distribute the workload by spreading traffic across them.
Invest in a more powerful server
We can buy more powerful hardware to handle the growing user base, this is called virtual scaling. Virtual scaling is a strategy used to enhance the performance and capacity of a server by making it more powerful.
In this approach, we expand the existing server hardware resources like RAM, CPU, storage etc.,
Advantages of Vertical Scaling:
a. By consolidating all your system components, including the database and other microservices, onto a single high-powered server, there is no need for external service calls to fulfill user requests. This results in significantly faster response times.
b. The management of a single, more robust server is straightforward, reducing the intricacy of your infrastructure.
c. A single, powerful server occupies less physical space.
d. Handling data backups on a single potent server is a straightforward task.
Disadvantages of Vertical Scaling
a. There is a single point of failure; if the server experiences any hardware issues, it can lead to complete service unavailability.
b. Vertical scaling has limitations regarding hardware resources. Once you reach the upper limit, further scaling becomes unfeasible.
c. During maintenance activities, server downtime may be necessary, causing interruptions in user services.
d. Vertical scaling often necessitates proprietary hardware and components, potentially resulting in vendor lock-in.
Procure more machines and distribute the workload by spreading traffic across them.
This is an example of Horizontal scaling. Horizontal scaling increase the performance of the system by adding more machines to the existing infrastructure. Load is equally distributed among all the computes using a load balancer.
Advantages
Load Balancing: By adding more servers, we can distribute the traffic across multiple machines.
No downtime: Even one of the machine went down, it will not impact user requests.
Cost efficient: Instead of investing in powerful and costly hardware, we can invest in cheap commodity hardware here.
Better throughput: We can achieve higher overall throughput when multiple servers working in parallel.
Note
In the real world, it is common to use a combination of both vertical and horizontal scaling to meet the demands of a system. This is because vertical scaling has its limits, and horizontal scaling can help to overcome those limits. Companies like Google, Amazon and Netflix uses a combination of vertical and horizontal scaling to handle huge traffic to their search engines, e-commerce requests, video streaming etc.,
System Design Questions
No comments:
Post a Comment