Scaling to New Heights: Exploring AWS Auto Scaling's Potential
Tags: aws, autoscaling, cloudinfrastructure
Published: 2023-07-05 09:57:49

In Bangladesh, one of the recurring situations that highlights the challenge of handling peak traffic occurs during the National Board Examinations Result Days. These eagerly awaited days witness a surge in student visits to the Education Board Bangladesh website. Unfortunately, the existing server infrastructure fails to cope with the overwhelming influx of requests, leading to downtime. Investing in additional, high-capacity infrastructure solely for a few days of the year proves impractical. However, with the introduction of AWS Auto Scaling, this issue can be effectively addressed.

Embracing scalability is of paramount importance, especially when deploying modern web applications. With the continuous evolution of Cloud technologies, crafting scalable solutions has become remarkably convenient and accessible. The elasticity of the Cloud serves as a robust foundation for designing practical and flexible solutions, precisely what the National Board needs to overcome their current challenge. By leveraging AWS Auto Scaling, they can dynamically adjust their server capacity during peak result days, effortlessly handling the surging traffic without incurring the costs of permanent, underutilized infrastructure. This ensures smooth and uninterrupted access for students eagerly awaiting their examination results.

Autoscaling is a game-changer for managing web applications, offering a range of benefits. Here are some key advantages:

Optimal performance: Automatically adjusts server capacity to handle fluctuating traffic, ensuring smooth operation during peak periods.

**_Cost-efficiency:_** Scales resources based on demand, preventing overprovisioning and reducing unnecessary expenses.

**_Enhanced reliability:_** Maintains consistent performance by dynamically adapting to changing workload patterns.

**_Improved scalability:_** Accommodates sudden spikes in traffic without downtime or performance degradation.

**_Flexibility and agility:_** Allows for quick response to changing business needs and ensures seamless user experience.

**_Increased availability:_** Minimizes the risk of service disruption by distributing traffic across multiple instances.

To auto scale a web application effectively, several relevant AWS services come into play. These services work together to provide a robust Auto Scaling infrastructure:
1. Route 53
2. Elastic Load Balancer (ELB)
3. Auto Scaling Group (ASG)
4. Cloud Watch
5. Amazon Machine Image (AMI)


## Launch Template vs Launch Configuration:

Both, Launch Configuration and Launch Templates can be used to Auto Scale the infrastructure in AWS. However since May 2023, AWS is highly encouraging users to use Launch Templates as this have some advantages over Launch Configurations

**_Launch Configuration (Legacy):_** Must be recreated every time because modification is not allowed.

**_Launch Template (Recommended By AWS):_**
1. Allows to edit and update.
2. Maintains versions.
3. Can use T2 unlimited burst feature.
4. Allow provisioning using both On-demand and Spot Instances.
5. Creation of parameter subsets. 


## Types of Auto Scaling in AWS:

**_Reactive Scaling:_**
Reactive scaling, also known as reactive autoscaling, involves dynamically adjusting the resources of an application based on real-time changes in demand. It responds to immediate workload fluctuations and automatically scales up or down the number of instances to meet the current demand. Reactive scaling is commonly used when the traffic patterns are unpredictable or exhibit sudden spikes.

_Advantages:_
1. Ensures real-time responsiveness to changing workload demands.
2. Adapts quickly to handle unexpected increases or decreases in traffic.
3. Helps maintain optimal performance during peak load periods.

**_Scheduled Scaling:_**
Scheduled scaling enables pre-defined scaling actions to occur at specific times or dates, irrespective of real-time demand. It allows organizations to plan for known periods of high or low traffic and adjust the capacity accordingly. Scheduled scaling is commonly used for applications that have predictable workload patterns, such as daily, weekly, or seasonal fluctuations.

_Advantages:_
1. Provides control and predictability over capacity changes.
2. Allows for efficient resource allocation during expected traffic variations.
3. Facilitates cost optimization by ensuring resources are available when needed.

**_Predictive Scaling:_**
Predictive scaling, also referred to as proactive autoscaling, utilizes historical data and predictive algorithms to forecast future resource requirements. By analyzing patterns and trends, it anticipates future demand and proactively adjusts the capacity of the application in advance. Predictive scaling is particularly useful for applications with predictable or cyclical traffic patterns.

_Advantages:_
1. Optimizes resource allocation based on anticipated demand.
2. Reduces the risk of under or over-provisioning resources.
3. Improves cost-efficiency by scaling proactively, avoiding last-minute capacity adjustments.


## Horizontal Scaling vs Vertical Scaling:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ncui8nc24hqcyr2h7q8u.png)

**_Horizontal Scaling_** refers to adding more instances to distribute the workload across multiple machines. It involves increasing the number of servers or instances to handle a higher volume of traffic or workload. This approach improves scalability, fault tolerance, and overall performance by allowing the workload to be divided and processed in parallel across multiple instances.

Pros:
1. Improved Scalability: Adding more instances allows for better distribution of workload, enabling the system to handle increased traffic or demand.
2. High Availability: By distributing workload across multiple instances, horizontal scaling enhances fault tolerance and reduces the risk of a single point of failure.
3. Cost-Efficiency: Scaling horizontally can be cost-effective as resources can be added or removed based on demand, optimizing resource utilization.
4. Flexibility: It provides flexibility to scale resources dynamically based on changing workload patterns.

Cons:
1. Complexity: Implementing and managing load balancing, distributed data storage, and communication between instances can add complexity to the system architecture.
2. State Management: Handling shared state or maintaining session data can be challenging in a horizontally scaled environment.
3. Communication Overhead: Communication between instances may introduce latency or require additional configuration for synchronizing data or coordinating tasks.

**_Vertical Scaling_** involves increasing the resources (CPU, RAM, storage, etc.) of an individual server or instance to handle increased demands. It focuses on upgrading the capacity of a single machine, making it more powerful and capable of handling larger workloads. Vertical scaling is suitable when applications require additional resources, such as more processing power or memory, to meet performance requirements.

Pros:
1. Increased Performance: Adding more resources to a single instance improves its processing power, allowing it to handle larger workloads and higher traffic.
2. Simplified Architecture: Vertical scaling can be simpler to implement and manage as it involves upgrading the existing infrastructure without introducing distributed components.
3. Compatibility: Applications that are not designed to be horizontally scalable can still benefit from vertical scaling by upgrading the existing infrastructure.

Cons:
1. Limited Ceiling: There is a maximum limit to the capacity that can be added to a single instance, restricting scalability options.
2. Downtime During Scaling: Vertical scaling often requires stopping or rebooting the instance, causing temporary downtime during the scaling process.
3. Cost Inefficiency: Upgrading the resources of a single instance may result in under utilization of resources during periods of lower demand, leading to increased costs.