AWS Blog

EC2 Container Service – Long-Running Applications, Load Balancing, and More

by Jeff Barr | on | in Amazon EC2, EC2 Container Service |

Amazon EC2 Container Service is a highly scalable container management service that supports Docker containers and allows you to easily run applications on a managed cluster of Amazon Elastic Compute Cloud (EC2) instances. We launched the preview at AWS re:Invent and have been receiving a lot of great feedback ever since.

We built Amazon ECS because many of you told us that you are using Docker to encapsulate your applications and services, and that you want to run one or (more typically) more of them across a cluster of EC2 instances without having to worry about managing it. You asked for a service that was reliable and scalable, and that allowed you to take advantage of the advanced EC2 features that you are already using.

You also told us that managing a cluster, including the state of the EC2 instances and containers, can be tricky, especially as the environment grows. You need to have access to accurate and timely state information so that you can make container placement decisions, such as what instances are available and have the requisite capacity. Tracking of state grows increasingly difficult (and yet ever-more important) as the number of instances and containers grows into the thousands or tens of thousands.

Amazon ECS was designed to meet all of these needs and more. You do not need to install, operate, and scale your own cluster management infrastructure. With simple API calls, you can launch and stop container-enabled applications and discover the state of your cluster. You can use Amazon EC2 with other AWS services  and you can take advantage of familiar features such as Elastic Load Balancing, EBS volumes, EC2 security groups, and IAM roles.

You also get several options for container scheduling, allowing you to run a wide variety of applications and to manage the placement and utilization of containers, applications, and services.

Now Generally Available
I am happy to be able to announce that Amazon ECS is now generally available! We have added some powerful new features including support for long-running applications, a shiny new Amazon ECS Console, and CloudTrail integration. We are also making Amazon ECS available in the Asia Pacific (Tokyo) region.

Let’s take a look at each of these new features.

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.

A Word From Gilt
Online retailer Gilt provides their customers with insider access to today’s top brands and experiences. Co-founder Phong Nguyen told us:

“We were early adopters of Docker. Using Docker has helped us move faster and allowed us to improve and simplify end-to-end continuous delivery of our micro-services architecture. As we Dockerize all our services, it is very important for us to have a platform that can help us speed up deployments, automate our services, and gain greater efficiencies. The new service scheduler and ELB integration make Amazon ECS an excellent platform for our services, and we are looking forward to partnering with AWS as our Docker platform.”

Amazon ECS Console
The new Amazon ECS Console simplifies the process of setting up and running a cluster. I’ll demonstrate it by creating a service that deploys a simple PHP application.  The application displays content (a message and the time of day) provided by a linked container.

I start by opening up the Console and opting to create a custom task definition (the set of containers that I want to run together on an EC2 instance). I choose Custom:

Then I create my task definition. I can build it visually, one container at a time:

Or I can paste in an existing JSON definition (this one came straight from the Docker Basics section of the documentation):

I clicked on Create a service and accepted all of the default values in the next step:

Now that the service is defined I can create a cluster (3 t2.micro instances in this case) to run it. I used the Select/Create Roles button to set up the requisite IAM roles in one-click fashion:

After reviewing my choices and confirming my intent, Amazon ECS launched the EC2 instances into my default cluster. I was able to watch the progress from within the Console:

Everything was up and running within a couple of minutes and I was able to do some exploration. I started by looking at my list of clusters (just one):

And then zooming in for a closer look  at the cluster:

From there I can check on the service:

And I can make changes as needed:

You can also exercise all of this control, and retrieve all of the same information, by using the ECS API or the Command-Line Interface (CLI).

CloudTrail Integration
Calls to the ECS APIs are now logged to AWS CloudTrail.

Another Region
Effective today, Amazon ECS is available in the Asia Pacific (Tokyo) region. It is also available in the US East (Northern Virginia), US West (Oregon), and EU (Ireland) regions.

Get Started Today
If you are new to the world of container-based computing and Amazon ECS, start by reading What is Amazon EC2 Container Service.