In this information era, not just business enterprises, but each individual generates a big volume of data every day. There are billions of people and millions of businesses across the globe. So, all these databases need to be scaled for addressing this massive volume of data generation. All such databases need to be scaled up to ensure it is always functional and available. A database is not scalable when it gets drained or cannot simultaneously handle all incoming requests.
Database scaling can alter the size and capacity of a DBMS (database management system). In the process of scaling, we expand or compress the system to meet its objectives. Scaling can be done either by adding more resources to meet the current system’s expectations or by adding another system to the existing one. Sometimes, both these need to be done based on the situation.
Definition of scalability
“Scalability” is the capacity of a server, network, system, or process to accommodate the growing volume of data/work. Its potential is to scale up to provide more volume when needed in the future.
Types of scalability
As of late, two types of database scaling are in popular practice which are:
- Vertical Scaling, and
- Horizontal Scaling
Imagine you need a car. Your current vehicle can accommodate only 4 people, and you need to transport 8 people now. What you would probably do:
- You may buy a bigger car: an example of vertical scaling.
- You may buy one more car which can accommodate another 4 passengers: example of horizontal Scaling
As discussed above, when we add new systems to the existing to increase the capacity to meet the desired outcome, it is called vertical scaling. You may consider it as the rack of connected servers you can see in the data centers. So, when the existing system fails to meet the increasing needs, more resources can be added from time to time, vertical scaling, or scaling up. Vertical scaling is much easier to do and also requires only lesser time to fix.
When another server rack gets added to the existing database system to meet increasing expectations, it is called horizontal scaling. You may consider a single frame of resources and servers for the existing system. When this system fails to meet the increasing size and process requirements, we add entirely new servers with higher capacity. This is considered as horizontal scaling. Compared to vertical scaling, horizontal scaling is a bit tougher to accomplish and also comparatively costlier. You may need more time also to fix it in case of any failures.
Side-by-side comparison of vertical vs. horizontal scaling
|VERTICAL SCALING||HORIZONTAL SCALING|
|New resources get added to the system to meet the increasing expectation.||New server racks get added to the existing system to increase its capacity.|
|Helps to expand the size of the existing system vertically||Horizontally expands the system size.|
|Easy implementation and less time-consuming||A bit tougher and time-consuming implementation
|Cheaper as the need is to add new resources only when needed.||Costlier as adding new server racks consist of many new resources.|
Elasticity is the ability of a system to stretch and accommodate the increasing workload by provisioning and de-provisioning of database resources on demand. At any given point in time, a flexible system can match the incoming requests as closely as possible. A system can be called elastic when it can scale up or down to address the running applications’ resource needs.
Ideal cases of vertical scaling
Usually, vertical scaling is adopted when the given database cannot handle large data volumes. Say, for example, if the given database server having 10GB memory, which got exhausted with the data. So, to accommodate more data, you may buy another expensive server with 2TB memory. This is an example of vertical Scaling. Upgrading to a single expensive server. This will add more CPU power and disk storage space to your system.
The utility of vertical scaling is based on the situation. An example put forth by RemoteDBA.com is social media platforms like Instagram. Initially, it may have been addressing a minimal crowd. A single server would have been enough for that. However, when it grows to thousands and then millions of users accessing the application simultaneously, the server with limited capacity may not be able to store all the data. Data is also meant to be queried.
- If your application handles a limited range of users with minimal querying, vertical scaling is good to go.
- Relational databases use vertical scaling as an active mode of upgrading.
- Offers faster RAM and memory power.
- No code change needed to implement.
In fact, for larger applications like Instagram, where there is a load of queries, vertical scaling is not ideal. It cannot handle multiple queries at a time. The chances of downtime are also high.
Ideal cases for horizontal scaling
Horizontal scaling works by distributing the incoming data into various servers or called as shards. Each server acts as an independent DB. So, instead of buying another 2 TB server as in the above case, you are adding another 10 GB server to the system. The number of servers increases.
In the same example of Instagram, we discussed, in horizontal scaling, you get one system to store the user profile info, another to store the stories, another for image storage, etc. Now, the queries are classified and routed to the specific servers, which reduces the load on any one server at any given time, resulting in better performance.
If your application has more redundancy and involves very few joins, horizontal scaling is an apt mode of scaling out.
- New-age NoSQL DBs mostly adopt horizontal scaling.
- Cheaper compared to vertical scaling.
- Better performance with lesser load handling.
- Less downtime.
- More fault tolerance and resilience
However, horizontal scaling may make the joins as it features cross-server communications. So, it may not be suitable for banking transactions, etc.
Now, you know vertical vs. horizontal scaling fundamentals and the primary advantages and disadvantages of both. As we can see, different scaling modes suit different types of applications, which you need to make an informed decision by scrutinizing the current and future needs of your system to adopt one.