Scaling With Amazon ECS
Scaling With Amazon ECS
You can quickly and easily configure your AWS services and containers to auto-scale up or down, depending on the load and attention your projects are getting.
Join the DZone community and get the full member experience.Join For Free
In my last post regarding AWS, I explained how to launch Amazon ECS clusters, including Cloud Formation, VPC and subnet creation, ELB and ECS security group creation, auto scaling groups, launch configuration, elastic load balancer creation with the help of a sample app by creating a task definition, scheduling tasks, and configuring a cluster through the Amazon ECS First Run Wizard.
In this post, I will talk about auto-scaling, which means:
- Scaling in/out of an EC2 instance in a cluster.
- Scaling in/out containers (tasks) for a particular service.
Auto-scaling is obviously very helpful. Configuring EC2 instances in an auto-scaling group or deploying and managing different containers of the same microservice manually is pretty complicated. It can take a lot of time and effort to do that, but Amazon EC2 makes it easier, providing one-click auto-scaling features, which saves a lot of time.
Auto-Scale EC2 Instances in a Cluster
Open the Amazon console: Click on cluster tab, then select your cluster. In our case, it is named "default":
Click on the “ECS instances” tab: Find the option to “Scale ECS Instances” and click on that. Before scaling, you can see that we have only one ECS instance running in the cluster.
Scale ECS Instances the in cluster: Provide the desired number of instances. Here's let's set it to scale up to two from one. Once you've chosen your desired number, click on Scale.
In a few seconds, you will see two EC2 instances up and running, Amazon ECS will automatically configure it, so you don’t have to do anything.
Auto-Scale Containers/Tasks for a Service
Click on the “Tasks” tab: As of now, we have only one container running for our aptly named sample-webapp service.
Click on the “Services” tab: Select the service for which you want to scale out or scale in your tasks. I’m selecting sample-webapp for this demonstration. Then, click on update.
Scale tasks: Provide the desired number of tasks you want to run for this service and then click on Update Service.
In a while, you will see that two containers are running.
So you see, in just one click, we are scaling up and down our ECS instances and container instances. I hope I helped you save time and effort. In my next article, I will explain how to update task definitions in order to run the updated version. Keep in touch!
Published at DZone with permission of Prashant Goel , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.