Mastering AWS Scaling: A Deep Dive into Auto Scaling for Seamless Performance Enhancement

Yukesh KYukesh K
5 min read

What is Scaling?

Scaling in AWS is a core concept that enables businesses to flexibly adjust their infrastructure as needed. Leveraging AWS's scalable architecture, organizations can dynamically allocate resources for optimal performance and cost efficiency. Whether managing surges in traffic, scaling to accommodate growth, or optimizing resource use during quiet periods, AWS scaling ensures agility and responsiveness. With a suite of scalable services, AWS empowers organizations to easily meet evolving demands and maintain competitive edge.

Scaling Up / Vertical Scaling

Vertical scaling in AWS, also referred to as scaling up or down, entails adjusting the resources allocated to a single instance to accommodate fluctuations in workload or demand. This involves modifying the instance size, such as increasing or decreasing CPU, memory, or storage capacity. Vertical scaling enables you to enhance the performance or capacity of individual instances without altering the underlying architecture or adding additional instances. Despite providing immediate capacity adjustments, vertical scaling has limitations regarding how much an instance can be scaled vertically, and it may not always be the most cost-effective approach for managing significant increases in workload. Additionally, if an instance fails, it poses a single point of failure, which can disrupt the system.

Scaling Out / Horizontal Scaling

Horizontal scaling in AWS, also referred to as scaling out or in, entails modifying the number of instances or resources within a group to manage fluctuations in workload or demand. This approach allows for workload distribution across multiple instances, enhancing fault tolerance, availability, and performance. It provides the flexibility to meet increasing demands without depending on a single, large instance and can offer cost advantages over vertical scaling in certain scenarios. Horizontal scaling ensures that your application or service remains responsive and available, even during peak traffic or demand periods.

What is Autoscaling and its types?

Auto Scaling in AWS automatically modifies the number of instances or resources within a group based on predefined conditions or metrics. This functionality allows your infrastructure to dynamically adjust to changes in workload or demand without requiring manual intervention. Auto Scaling ensures that you maintain optimal performance and availability by providing the appropriate amount of resources when needed, while also optimizing costs by scaling down during periods of reduced demand. When used alongside horizontal scaling, Auto Scaling distributes the workload across multiple instances, enhancing fault tolerance and resilience. Overall, Auto Scaling is an essential feature for building scalable and reliable applications on AWS.

The visual display highlights two Availability Zones designated for the Auto Scaling group. Utilizing CloudWatch logs, we can dynamically adjust the instance count to accommodate fluctuations in traffic, scaling up during peaks and scaling down during lulls. Furthermore, the Auto Scaling group automatically replaces any failed instances, ensuring fault tolerance.

Here are the different types of autoscaling:

  1. Manual - Adjusts ASG size manually.

  2. Dynamic - Scales automatically based on demand.

  3. Predictive - Utilizes machine learning for prediction.

  4. Scheduled - Scales according to a predetermined scheduled time.

Hands-On : Creating an Autoscaling Group

  1. Here's the User Data code that can be copied and used in the launch template for all instances,
#!/bin/bash

# Update package repository and install Apache
yum update -y
yum install -y httpd

# Start and enable Apache service
systemctl start httpd
systemctl enable httpd

# Retrieve the Availability Zone of the EC2 instance
EC2AZ=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)

# Create HTML content with the Availability Zone information
echo "<center><h1>This Amazon EC2 instance is located in Availability Zone: $EC2AZ </h1></center>" > /var/www/html/index.html
  1. Choose the launch template and provide a name for it.

  1. Choose the Linux operating system from the available AMIs and select the t2.micro instance type, which is eligible for the free tier.

  2. Choose the instance type as t2.micro and do not provide the key-value pair.

  3. Choose the security group that has access to the web server.

  4. In the advanced section, scroll down to input the user data and proceed to create the launch template.

Now that we have created a launch template for launching instances with the Auto Scaling group, let's proceed to create the Auto Scaling group that utilizes this launch template.

  1. Click on the Auto Scaling group and create one with the already created launch template.

  2. Choose the default VPC and select the availability zones us-east-1a and us-east-1b.

  3. No load balancer is opted at this time.

  4. Choose the desired capacity, indicating the number of instances you want to be running at all times. The minimum and maximum desired capacities denote the minimum and maximum number of instances to be running within the ASG.

  5. Review the changes made to your summary and proceed to create the auto-scaling group (ASG). Under the activity tab of the created ASG, we can monitor ongoing activities and status updates.

  6. Now, instances are being created based on the input desired capacity.

  7. To test the auto-scaling group (ASG), we will forcibly terminate one instance. The expected behavior is that a new instance should be created automatically, as we have already configured the required capacity.

  8. Now, activity logs containing traces of new instance additions during a failover are visible.

    This is how auto-scaling groups function in response to network failures or increased demand, ensuring the system remains available for use.

0
Subscribe to my newsletter

Read articles from Yukesh K directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Yukesh K
Yukesh K