Server Autoscaling on AWS

Today we discuss about the best scaling mechanism for the production server. There are two types of scaling which we can inherit either Horizontal Scaling or Vertical Scaling.

In Horizontal Scaling we can add more servers to our pool of resources and make them distribute the load accordingly but In Vertical Scaling we have to increase the computational or memory power of the single machine to handle the load more efficiently. Horizontal Scaling is more efficient and economic as compared to the Vertical Scaling because in Horizontal Scaling we can increase or decrease the pool of resources in real time without any downtime or affecting the services which is not possible in Vertical Scaling. So, we always prefer horizontal scaling for our production or live server environment.

Lets implement the auto scaling (Automatic Horizontal Scaling) on AWS.

To implement auto scaling on your application, you have to take care of few things which are as follows-:

  • Application and Database should be on separate servers so that we can clone our application server as per demand and it doesn’t affect our central database, for database server we can use RDS Service of AWS (Required).
  • All dynamic files (files created at the time of code execution for ex-: images, thumbnails, templates etc.) should be stored and managed through S3 or any other Central Storage Media so that all servers can access these files irrespective of their life cycle (Required).
  • We can setup GIT or SVN on the application server for Updating and Maintaining the code structure throughout the server pool (Recommended).
  • Load Balancer is required to balance the load between the pool of servers (Required).
  • Load Balancer, Database Server, Application Server and Auto scaling group should be in the same VPC (Required).
  • Create AMI image of your application server to setup launch configuration of autoscaling(Required).

First we have to create a load balancer as follows-:

  1. After logged into AWS Console go to EC2 Panel and select load balancer.
  2.  Click “Create Load Balancer” button.
  3. Type Load Balancer name, Select the same VPC and subnet in which your application and database servers are present and setup the listener configuration as per your choice either on port 80,443 or both.
  4. Select an existing Security Group or Create a new one in the same VPC and subnet.
  5. Configure health check on the load balancer either on TCP port basis or webpage basis, for more details refer to AWS Documents for Load Balancer.
  6. Add EC2 instance (Application Server) in the load balancer.
  7. Add Tags and Review all your settings in the next window, after reviewing all the settings launch the load balancer.

As we have already added one EC2 instance (Application Server) in our Load Balancer, now we have to enable the auto scaling by following steps.

  1. After logged into AWS Console go to EC2 Panel and select “Launch Configuration” in “Auto Scaling” pane.
  2. Click “Create Auto Scaling Group” and then click on “Create Launch Configuration”.
  3. In the next step choose your application server AMI which you have created for launch configuration.
  4. In next step choose the instance type and fill the launch configuration details like name, IAM role and other advanced details or you can make it simple by giving name only.
  5. In the next step all the storage volume and set the storage space for instances.
  6. Now create or select the security group but you have to take care that these security groups should be the member of same VPC group in which application and database server are present.
  7. After that review your configuration and launch the configuration in next step.
  8. Now in the “Configure Auto Scaling group details” pane type the group name for auto scaling group and set the initial size of the group by giving size in “Group size”, In “Network” drop down list and “Availability Zone” select your same VPC and Zones respectively.
  9. In Advanced Details select your load balancer which you have created before and enter the “Health Check Grace Period”.
  10. Now configure the scaling policies as per your requirement either on CPU consumption, Memory Consumption or based on traffic for more details please check here or you can select the keep this group at its initial size.
  11. After that skip the notification part and give the tags to your auto scaled instances.
  12. Review your configuration in the next step and create the auto scaling group.

After this go to your EC2 instance panel and check for launched instances which will be managed on the basis of your scaling policy and you don’t need any manual scaling for extra traffic.



Category(s) aws cloud
. . .


Add Your Comment

Be the first to comment.