Vertical vs Horizontal Scaling

Vertical vs Horizontal Scaling

When we want to deal with scaling servers we basically talk about Horizontal (Scaling out) and Vertical (Scaling up). What exactly is Scaling in Software Engineering?

Scaling is the process of adjusting the number of processes available to serve requests to increase or decrease the system's capacity. Scaling out a system adds capacity, whereas scaling in a system decreases capacity. (It is the ability to serve if the load increases. It is like capacity or caliber in other contexts).

To scale refers to the ability of a software solution that was designed for a small capacity requirement to be easily expanded to handle a large capacity requirement.

Scalability means different things to different people. It doesn’t have a technical definition. My definition of good scalability is that individual requests in the software system don’t get significantly more expensive (i.e. take more time) as the volume of data or traffic increases.

horizontal-vs-vertical-scaling-diagram.png

Why is scaling important? By modifying your product based on data such as consumer wants and new technology, scaling maintains your product on the market. Scaling is a method of ensuring that a product is reliable, continues to serve its job, and generates profits through diligent monitoring and swift response to changes.

For example, say you launch the beta for Jumia and on normal days you get 1000 requests per second, your database is 15GB, and the requests take 0.3 milliseconds each.

On Jumia black Fridays your site has 20 billion users, 100,000 requests per second, and the database is 40TB. Now your requests take 0.24 seconds each.

To me, that would be pretty good scalability. It doesn’t have to be perfectly flat, but the rate of increase in users, request rate, or database size has not resulted in a proportional increase in request latency. During Jumia black Fridays, we may need to scale up our server as we get more users on the platform and more servers as the previous server being able to take 1000 requests per second may not be able to handle 100,000 requests per second may even crash the server.

The way to design a scalable system is not to pick the right technology stack. The way is to design an application architecture that uses the same amount of computational work to handle requests, no matter how many requests there are, and how much data you’ve collected.

Of course, this isn't just about online apps. Many software systems essentially implement some form of "request," "transaction," "unit of work," or whatever name you wish to give it, which they repeat at increasing scale. That is the most effective use of computers.

Vertical scaling:

Using bigger server(s). The technique of shifting extra resources to a single server to meet the expansion of your application is known as vertical scaling. Vertical scaling in the cloud refers to the addition of a new server or the replacement of an existing server with a more powerful server.

Horizontal scaling:

Adding more servers. Horizontal scaling simply adds more instances of machines without first implementing improvements to existing specifications. By scaling out, you share the processing power and load balancing across multiple machines.

In simple terms have you ever come across a message like this

"To improve service experience we will be performing an emergency maintenance activity on 22-22-22..."

Most times the company is scaling up their servers and usually using vertical scaling, from the definition of vertical scaling, we simply remove a server with a lower capacity and replace it with a bigger server. To eliminate such messages and down times companies like facebook and whatsapp use horizontal scaling by adding more servers when requests grow.

When to choose different Scaling per time:

Advantages of Horizontal Scaling:

Any time you realize you don't have much traffic you can remove the server and scale later in important occasions. And Kubernetes helps us auto scale when there is much load.

Disadvantages of Horizontal Scaling:

  1. Architectural design is highly complicated.
  2. High licensing fees.
  3. High utility costs such (cooling and electricity)
  4. Bigger footprint and impact on the data center.
  5. Extra networking equipment such as routers and switches are required.

Advantages of Vertical Scaling:

  1. Reduced software costs.
  2. Easy Implementation.
  3. Licensing fees is less.
  4. Consumes less power.
  5. Cooling costs are lesser than horizontal scaling.
  6. Cooling costs are lesser than horizontal scaling.
  7. Application compatibility is maintained.

Disadvantage of vertical Scaling:

If you have a single server and it crashes the whole system crashes but for horizontal scaling kubernetes spins up a new server.

In order to minimize cost and maximize profits we use a methodology called Cloud Elasticity to help us in scaling, Cloud elasticity helps users prevent over-provisioning or under-provisioning system resources. Over-provisioning refers to a scenario where you buy more capacity than you need. Under-provisioning refers to allocating fewer resources than you use.

Cloud Elasticity:

The ability of a cloud to grow or reduce capacity for CPU, memory, and storage resources in response to changing needs is known as cloud elasticity. Cloud Elasticity can be automated, eliminating the need for capacity planning ahead of time, or it can be a manual process in which the organization is notified when resources are running low and can then decide whether to add or reduce capacity as needed. The cloud provider's monitoring tools dynamically alter the resources allocated to a business without interfering with existing cloud-based processes.

Finally, applying software design, database design, and technology selection approaches can significantly improve a system's quality, scalability, and performance. As a result, as software designers/developers, we should all learn about these strategies in order to create better systems.

Thank you for reading.