A cloud computing feature that permits users to automatically scale cloud services such as virtual machines (VM) or server capabilities up or down based on definite situations is termed as Autoscaling. During a heavy spike in traffic, Autoscaling ensures that new instances are impeccably increased and also automatically reduced when the demand drops down. Such controlling helps to consistently maintain lower costs.
This Autoscaling feature can be implemented both manually and automatically as per the need. Many Cloud computing providers like Amazon Web Services offer this feature of Autoscaling. There are two main Autoscaling strategies in cloud computing namely horizontal and vertical Autoscaling.
Horizontal and Vertical Autoscaling in Cloud Computing
Vertical Autoscaling simply refers to adding more power to an existing instance. It resizes the server with no modifications to the base code. It is the ability to enhance the capacity of the existing hardware or software by including additional resources.
Let us consider an example. In a restaurant, the owner has an estimate of the accommodating capacity of a restaurant. If more patrons get in, more tables are added. However, when maximum capacity is reached, no more patrons can be accommodated. Capacity can be increased only based on the size of the establishment. Likewise in a cloud environment, extra hardware can be amended to the existing machine or RAM or hard drive only based on the size of the actual machine.
Advantages of Vertical Autoscaling
There are no modifications made to the existing design or software. Resources can be scaled just by adding more RAM, CPU or disk space. There are no changes made to the application but only to the underlying instances and its size.
Disadvantages of Vertical Autoscaling
There is a limit to the number of resources that can be added. It depends on the actual size of the machine. One more disadvantage is the need to bring the existing application down in order to add more resources. Very few servers support the addition of hardware resources on the fly. The same is applicable for cloud instances too. It is not possible to resize the instance while it is on execution. The power needs to be switched off. During the downtime, it is crucial to ensure that there is enough running capacity for the existing load. If that is not the case, the current applications might suffer due to the resize.
Also, the maintenance of the instance includes fixes, patches and improvements. This becomes an added overhead to the Operations team.
Horizontal autoscaling refers to the ability to scale wider as per the increasing traffic. It is the capability to amend several hardware or software entities such as servers so that they execute as a single logical unit. Such scaling cannot be implemented in short notice.
Let us consider an example. An express highway has a capacity to accommodate 2000 vehicles at a time. As commerce begins to expand, the count increased to about 8000 vehicles. To deal with this issue, the express highway scaled horizontally by constructing more express lanes and more likely an overpass was added. In this case, the construction of additional lanes takes extra time. Likewise, in the cloud environment when scaling is performed horizontally, additional machines are appended to the environment. This requires substantial planning and resource availability. It is also crucial to ensure that the base architecture has the capacity to handle the additional scaling.
Horizontal Autoscaling Architecture
Scaling horizontally is not an easy process from a developer’s perspective. Scaling horizontally means adding a new node (or removing a node) from a system or adding a new computer to a distributed application. A horizontally scalable architecture will improve the throughput by zero or by a very minimal increase in the overhead. For example, if a node completes 10 tasks in an hour, if we include 9 more nodes, 100 tasks get completed at the same hour.
The software needs to parallelize its tasks in order to scale horizontally. Tasks parallelization can be performed at different stages.
- Allocate separate tasks onto different computers. This process is called load balancing.
- Allocate separate tasks onto different CPUs of the same computer. This process is called multitasking.
- Allocate separate tasks onto different threads on the same CPU. This process is called multi-threading.
To be completely parallelizable, a task needs to be independent of other tasks that are getting executed in parallel with it. Likewise, to be completely distributable onto any computer, the task should be able to access any data that is required for execution regardless of which computer that executes the task.
Advantages of Horizontal Autoscaling
One of the key advantages of horizontal autoscaling is its ability to scale infinitely. If the underlying application has the ability to scale in a horizontal mode, an infinite number of instances can be added. This serves an infinite number of requests and also ensures rapid growth. In cloud computing, the developer builds a system that can accommodate additional hardware. Another benefit of horizontal autoscaling is that the extra hardware can be used to provide redundant data storage. Redundant data storage minimizes the chances of a partial system failure pulling down the entire system or compromise operations. One more advantage is that efficient systems can be created by simply networking low-cost generic hardware components and appending them to the system as per requirement.
Disadvantages of Horizontal Autoscaling
Designing an application to handle horizontal autoscaling is a herculean task. Several elements have to be accounted such as preserving state (cookies/persistence) and managing security (SSL). Serious planning and architectural designing are required to build an application that supports 100% horizontal autoscaling.
A database is normally used to store data (customer details). Based on the database, the architecture needs to be developed to make sure that not only does the application scales, but the underlying data layer also scales. This is not a simple process and the complexity is further enhanced if data is spread across different geographic locations.
When do we use Vertical Autoscaling and Horizontal Autoscaling?
Vertical autoscaling which refers to the inclusion of more resources (CPU/RAM/DISK) to the server as on-demand is mostly used in applications and products of middle-range as well as small and middle-sized organizations. An example is to purchase expensive hardware and apply it as a Virtual Machine hypervisor (VMware ESX). Other reasons to scale vertically include enhancing IOPS (Input/output Operations), optimizing CPU/RAM capacity and disk storage. MySQL-Amazon RDS is one of the software that makes use of vertical autoscaling.
Horizontal Autoscaling involves increasing the number of nodes in a cluster and minimizing the tasks of each node by dispensing the keyspace wider and providing additional end-points for client connections. Horizontal Autoscaling is mostly used for a high level of computing and for high-level applications and services. A few reasons for organizations to choose horizontal autoscaling are its ability to increase I/O concurrency, minimizing the load on existing nodes and enhancing the disk capacity. Software giants like Google (Gmail, YouTube), Yahoo, Facebook, eBay and Amazon largely use horizontal autoscaling.
Horizontal and Vertical Autoscaling in AWS
Vertical autoscaling in AWS is an easy process. In order to scale vertically, RDS or EC2 servers modify the instance size. One drawback is that this process requires a minimum downtime. Scaling up means choosing a larger instance size and scaling down would be selecting a smaller instance. Resizing an instance can either be performed by restarting an existing instance with a new size or by replacing an existing instance with a new resized instance.
Using the AWS Ops Automator a time-based or event-based trigger is defined which determines when the solution scales the instances. It also provides an option to specify if an existing instance’s size needs to modified or replace the instances with new resized ones. AWS Lambda is then invoked by the time or event-based trigger that scales the instances.
If the instance is restarted with a new size, the solution enhances or minimizes the size of the instance based on the changes in demand at a specific time period. The solution automatically modifies the instance size to the next defined size up or down. If the instance is replaced with a new resized instance, the solution creates new instances with the next defined instance size up or down. The solution is also connected with Elastic Load Balancing to automatically include the new instance with Load Balancers.
Horizontal Autoscaling in AWS is the process of changing the number of nodes or instances in a system without modifying the size of an instance. A basic Webapp in AWS has a couple of instances (servers) serving a webpage. An Elastic load balancer routes the traffic between the instances. The instances are available in the Autoscaling group. Here horizontal autoscaling is performed by having an EC2 Autoscaling scale based on the number of connections per instance for the integrated ELB. The Autoscaling scale is set to a minimum target and it is always maintained in a safe limit.
For example, if we target the “Application load-balancer request count per target” and instruct the auto-scaling group to retain this count as 200, the solution would automatically add or remove instances from the auto-scaling group based on the demand ensuring that the value is retained at 200 requests per instance in the Autoscaling group.
One key factor while performing horizontal autoscaling is to keep in mind to scale down. Scaling up a cluster is expensive which is affordable during peak traffic times. But it is important to scale down when an opportunity arises without loss of performance. The above example performs scale-up and scale-down as per requirement.
In short, the main difference between vertical and horizontal autoscaling in AWS is that in vertical autoscaling the capacity or size of the instance is increased as per demand whereas in horizontal autoscaling the number of instances (not the size) under the load balancer is increased as per requirement. Scaling vertically eventually hits the limits of the maximum capacity available whereas scaling horizontally is almost unlimited.
Horizontal and Vertical Autoscaling in Databases
Scaling Out or Horizontal Autoscaling is the process of including more instances or servers to distribute the databases on multiple machines to manage the increased demand. When the capacity of the system needs to be increased, DBA’s add more machines to cope with the requirement.
The data contained in the databases is then partitioned across several machines that make up the cluster. Here each server holds one part of the entire database. With horizontal Autoscaling, the scaled servers can also make use of data replication, where the main machine retains the primary copy of the whole database and several other copies in multiple machines that are used only in read-only load.
The maintenance and upgrades of horizontally scaled databases are easier. The faulty instances can quickly be powered off with minimum disruption to the rest of the system. Conversely, the number of instances enhances the complexity of the system. This eventually makes the monitoring and administration process more complex and also enhances the recovery time from disasters.
Scaling-up or Vertical Autoscaling includes adding more resources to a minimum number of server instances. The CPU resources, memory, storage and network bandwidth are increased thereby enhancing the performance of every single node. In this way, even the smallest server is scaled up to handle huge databases.
Managing and administration of vertically scaled are much easier than horizontally scaled databases. Vertically scaled databases are more stable, reliable and cost are also much lower for managing smaller data centres. The downsides are that the initial hardware costs are high and future upgrades are expensive and also limited. Vertical autoscaling increases the dependency on a particular database vendor and exiting the vendor later would result in complex and expensive server upgrades.
Horizontal Autoscaling and Vertical Autoscaling for Micro-Services
A microservice is a short, loosely coupled distributed service that allows taking a large application and break into easily manageable small components with certain defined responsibilities. Vertical Autoscalability in microservices as in the previously mentioned cases is scaling the capacity of the application by enhancing the hardware (CPU, memory, disk IOPS) capacity. The architecture of the application and the infrastructure does not change in vertical autoscaling. This is also called as Y-axis Scaling.
In microservices horizontal autoscaling method, instead of scaling by increasing the hardware capacity, the application is built in such a way that it scales out by adding more instances or by cloning more containers behind a load-balancer. This is also called as X-axis Scaling. If there are N cloned containers, then each container handles 1/N of the total load. The scalability pattern requires modifications in the application architecture. One key factor is that every single container that is cloned to scale horizontally executes a complete instance of the application, accesses all of the data and hence requires more memory.
ApacheBooster is a software plugin that improves server’s performance. If you are dealing with slow website or server, please contact us, and we will resolve your issue soon.