Does AWS ECS support per container dynamic scalabi

2019-07-20 18:01发布

问题:

Amazon's EC2 Container Service allows you to run any amount of containers you want, it will choose an EC2 instance(s) to run the containers on automatically. Which are great features. However, we are really concerned about automatic scalability.

Scenario:

  1. I launch a container via AWS ECS Console.
  2. The HTTP requests are starting to come up.
  3. The HTTP load increases significantly with time.
  4. CPU (or RAM) usage of the container is getting closer to 100%.

Question 1: Will ECS run one more container automatically?

Question 2: Will ECS automatically shut one of the containers down when CPU (or RAM) load gets low?

回答1:

No, you don't get fully automated scaling with basic ECS. What you can do is create an alarm for when load gets high and have the alarm trigger an update to increase the cluster size.

Update Nov 29, 2017

AWS Fargate is a technology for Amazon ECS and EKS* that allows you to run containers without having to manage servers or clusters. With AWS Fargate, you no longer have to provision, configure, and scale clusters of virtual machines to run containers.

This allows to scale containers without worrying about underneath infrastructure working with ECS service level scaling configurations.



回答2:

You should ideally put scaling both at the ec2 and ecscontainer level.

In case you are using ASGs, ec2 scaling based on the cloudwatch alarms can be configured on the ASG.

For container scaling you will have to write a lambda function or have some sort of application which can be triggered on an cloudwatch alarm for the scaling to occur.


On May 18th 2016, ECS has released autoscaling capability. you wont need Lambda to build scaling capability at service level.

Please see the release and feature documentation below

https://aws.amazon.com/about-aws/whats-new/2016/05/amazon-ec2-container-service-supports-automatic-service-scaling/

http://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-auto-scaling.html



回答3:

So it doesn't say so explicitly and Nathaniel could certainly be correct but this blog from April 9th this year seems to imply at least that you can do what you are asking

Long-Running Applications Previously, Amazon ECS included two ways to schedule Docker containers on a cluster. You could run tasks once for processes such as batch jobs that perform work and then stop. You could also make calls to the Amazon ECS APIs to retrieve state information about the cluster and then use it to power a third-party or custom-written scheduler.

With today’s launch you can also use the new Amazon ECS Service scheduler to manage long-running applications and services. The Service scheduler helps you maintain application availability and allows you to scale your containers up or down to meet your application’s capacity requirements. Here’s what it does for you:

Load Balancing – The Service scheduler allows you to distribute traffic across your containers using Elastic Load Balancing. Amazon ECS will automatically register and deregister your containers from the associated load balancer. Health Management – The Service scheduler will also automatically recover containers that become unhealthy (fail ELB health checks) or stop running to make sure that you have the desired number of healthy containers available to run your application. Scale-Up and Scale-Down – You can scale your application up and down by changing the number of containers you want the service to run. Update Management – You can update your application by changing its definition or using a new image. The scheduler will automatically start new containers using the new definition and stop containers running the previous version. It will wait for the ELB connections to drain if ELB is used. You can also use these new facilities to implement a basic service discovery model. You can list the services that are running in a cluster and then use the ELB as the service endpoint.



回答4:

As of Dec 2017 Amazon announced the new service called Fargate. Quoting the link:

AWS Fargate makes it easy to scale your applications. You no longer have to worry about provisioning enough compute resources for your container applications. After you define your application requirements (e.g., CPU, memory, etc.), AWS Fargate manages all the scaling and infrastructure needed to run your containers in a highly-available manner. You no longer have to decide when to scale your clusters or pack them for optimal utilization.

I assume the bold text means that Fargate will scale up and down the resources for me. Not 100% sure though.