Auto Scalability Using Amazon Web Services

Auto Scalability is the key feature of cloud computing. The ability of AWS cloud to manage the capacity of your environment automatically is a huge advantage for availability of the application. It has also reduced a lot of burden from operation teams.

In this blog, I’II be focusing on deploying a MVC web application from Visual Studio to AWS cloud utilizing the auto scalability features of AWS.

AWS provides a deployment service called Elastic Beanstalk; which can create a scalable environment on AWS in just 5 minutes. Let us go through this in detail.

1. Download AWS toolkit for visual studio from http://aws.amazon.com/visualstudio/. The tool kit enables developers to develop, debug and deploy AWS solutions right from their favorite IDE, i.e. Visual Studio. Similar toolkits are available for Eclipse.

2. Create a new user profile in AWS using Identity and Access Management. These user credentials will be used to access AWS resources for Visual Studio. Refer to http://docs.aws.amazon.com/AWSToolkitVS/latest/UserGuide/tkv_setup.html. The user should be based on the principle of least privilege.

3. Create a new MVC application and deploy the same on AWS cloud by following the below steps.

a. Right click on the solution and choose “Publish to AWS”

AWS

b. Create a new deployment profile

AWS

c. Provide the application environment specific information

AWS

d. Set up the launch configuration setting for your environment. Here I am choosing a 2012 R2 server with IIS 8.5 with a very small EC2 instance type t2 micro. These instances should be further launched in a VPC.

I am not using RDS service for this deployment but we can configure the database right from this screen. The roles and permissions under which these services will be launch can be modified after the environment gets created.

AWS

e. As I configured the environment to run in a VPC, I need to setup the VPC options. I am using the default VPC for this blog.

I have already created 2 subnets as shown below. I am setting up the ELB to run in one subnet and EC2 instance to launch in the other subnet.

AWS AWS BS05

f. Configure IIS and .NET framework setting.

BS06

g. Review and deploy.

AWS

h. Refresh the node under AWS Elastic Beanstalk from left tree and check out the logs. The status of the environment should be launching.

AWS

Beanstalk will create and set up each service that is required for setting up a scalable environment. You will be amazed to see how much of the work of setting up for the environment is taken over by Beanstalk. If you look closely in the logs, the services it created and configured are the following services:

i. Auto Scaling

ii.    ELB

iii.    EC2

iv.    Cloud Watch

AWS

i. You can access logs that can be helpful to fix any setup issues. You can download the logs from S3 by clicking on logs.

BS10

j. Check the status of the environment and if it is “Environment is healthy” you are good to access the application by clicking on the URL

AWS

k. The environment can always be tweaked as per the requirement from the AWS console. Let me add 2 more alarms that will trigger the spawning of new server. The alarms will be based on CPU utilization. The first one will spawn up a new EC2 instance if CPU load remains higher than 60% for a minute. The other alarm will bring down an EC2 instance if CPU load remains lower than 10% for 1 minute.

AWS

l. Now let us increase the load on the application. The application that I have built has a button which can increase the load on CPU. After a couple of minutes the CPU utilization will increase over the threshold and Auto Scaling will spawn another EC2 instance in the environment.

BS13

m. The request to the server will now be shared between these 2 instances. ELB will redirect my request to these 2 different machines automatically. See below how the Server IP is different for the 2 different requests.

AWS AWS

n. Don’t put any further load on the server and you will see after a few minutes that the Auto Scale service will bring down one EC2 instance.

BS15.1

o. So this is how auto scaling works. You must have noticed that the CPU usage indicator that has been shown on the above screens is 0. That is a bug in the code. So I need to fix and redeploy the application on the AWS environment. To do that, just republish to the Environment as below.

AWS BS17

p. As before, check the status within the Elastic Beanstalk service. It should first be in “updating” state and then should change into “Environment is healthy” state.

q. The new code is deployed successfully on top of the existing environment. Follow the below steps to run the application and validate the setup again:

i.    Access the web application

ii.    Increase the load

iii.    See the CPU utilization – if it goes above 60%, it should spawn one more EC2 instance

iv.    Check the number of EC2 instances running. There should be 2 or more instances running now

v.    Access the web application again. ELB should send the requests to the other server now as load on the other server is not high

vi.    Wait for a couple of minutes more so that CPU can come below 10% for 1 minute

vii.    Check the EC2 instance; there should be only one instance running again

AWS AWS

I hope you have realized the power of Beanstalk and AWS auto scaling capability. I will appreciate your feedback in the comments section!

Manoj Bisht

Manoj Bisht

Senior Architect

Manoj Bisht is the Senior Architect at 3Pillar Global, working out of our office in Noida, India. He has expertise in building and working with high performance team delivering cutting edge enterprise products. He is also a keen researcher and dive deeps into trending technologies. His current areas of interest are data science, cloud services and micro service/ serverless design and architecture. He loves to spend his spare time playing games and also likes traveling to new places with family and friends.

2 Responses to “Auto Scalability Using Amazon Web Services”
  1. satish mangwane on

    i wanted to develop a scalable web application using mvc 4 over AWS , i need help for the same

    Reply
Leave a Reply

Related Posts

4 Reasons Everyone is Wrong About Blockchain: Your Guide to ... You know a technology has officially jumped the shark when iced tea companies decide they want in on the action. In case you missed that one, Long Isl...
3Pillar Recognized as a Leading Experience Designer by Forre... Fairfax-based product development company named to its second Forrester report in 2018 FAIRFAX, VA (June 18) - Today, 3Pillar Global, a global cust...
3 Cloud Optimization Projects That Will Pay for Themselves i... AWS introduced 1,430 new features and tools in 2017, including 497 in the 4th quarter alone. This means that it can be a challenge for even the mos...
The Connection Between Innovation & Story On this episode of The Innovation Engine, we'll be looking at the connection between story and innovation. Among the topics we'll cover are why story ...
Go Native (App) or Go Home, and Other Key Takeaways from App... I just returned from my first WWDC. I feel like I learned more in a week at Apple’s annual developer’s conference than I have in years of actually dev...