Idea of vertical and horizontal scaling


Sign up for FREE 1 month of Kindle and read all our books for free.

Get FREE domain for 1st year and build your brand new site

Scaling has become a very important concern and topic in information technology in the age of accelarating technology and data. Can our system handle increased load? How do we make our system, nodes or nodes handle more load or work? How do we manage our resources more efficiently?

The concept of scalability in technology mainly applies to computer systems, databases, computer networks, programs and applications. With web applications its extremely important to understand the number of users it can support and how to scale to allow for increased usage. There are two main solutions to handle scale for such systems, horizontal scaling and vertical scaling.

Screenshot-2021-02-24-at-6.56.51-PM

In image above, vertical scaling enlarges a system as represented by growing vertically, system remains one. Horizontal scaling entails adding additional units of same system e.g more databases or computers as represented by adding more along the horizontal axis.

Horizontal Scaling

Horizontal scaling (often referred to as scale out), adds more instances of the system to try and distribute the load equally. For example in client server systems if a single server is overloaded, more servers were traffic can be directed are created. Additionally tools like load balancers are involved to help distribute load equally among the system. For example in distributed computing, more nodes or computers are added.

Horizontal scaling can be likened to producing clones of existing system by duplicating them. In databases via sharding, clones of existing database are spread around multiple servers. Horizontal scaling is less disruptive as existing node can be up, whilst new nodes are added. It may turn out cheaper as even basic machines, nodes or servers working together can have significant efficiency gains. If you reach another load or system strain that requires scaling you can simply add more machins, giving potential for inifinite scaling.

Vertical Scaling

Vertical scaling adds resources or capacity to an existing system. This often includes making hardware improvements like adding more CPU, memory, or storage. For example in a database you may add more physical and virtual resources like adding more storage to handle capacity and load. Vertical scaling can be likened to beefing up the existing system to make it bigger, more powerful and more capable to handle extra requirements and load.

Vertical scaling is often referred to as up/down scaling. Vertical scaling is slower and may disrupt existing operations as the single node or system may be down during upgrade. Hardwware improvements can be expensive and has limitations no matter how good, implying you can only scale horizontally up to a certain limit.

Application

MongoDB is a database that allows you to horizontally scale out across multiple machines. Via sharding the database is split into several parts. Sharding distributes the data across various machines. Examples of other horizontally scaled database include Cassandra and Google Cloud Spanner. Cassandra uses virtual nodes containing data in certain ranges. Google Cloud Spanner is a clustered relational database management system which can easily scale horizontally.

Screenshot-2021-02-19-at-10.01.43-AM
Image Source docs.mongodb.com

Examples systems not suited to horizontal scaling

Traditional Relational Databases e.g SQL databases like MySQL are normally vertically scaled. Scaling horizontally in databases relies on partitioning data. Paritioning data makes queries and concepts of joins challenging, harms performance and breaks ACID requirements. Relational Databases are inelastic, once you distibute data its difficult or impossible to undistribute it. Other examples vetically scaled databases include Amazon RDS which switches to bigger machines to handle more capacity.

Choosing between vertical and horizontal scaling

The right scaling solution depends on existing systems, your requirements, budget, time constraints,application requirements, infrastracture and technical resources and capabilites. In many systems and databases horizontal scaling seems to be more popular these days due to buzz terms like ability to have elastic systems.

Questions

Question 1

What is an advantage of horizontal scaling and not vertical scaling?

Fault tolerance
Data consistency
When one unit of the entire system fails the others remain operational. With vertical scaling everything depends on a single system which can fail.