This is a basic walk-through tutorial of how to deploy a webapp using ECS. In this tutorial, we will deploy a simple scalable nodejs app on docker containers but with ECS. With this, we will have our app run in a sandboxed environment in the form of docker container and using ECS, we can demonstrate how we can scale it better.
In this demo, we will show you how to deploy a scalable,load-balanced and high available simple nodejs app. The demo will have multiple instances of nodejs app each running inside a container and load-balanced through haproxy. The basic architecture looks like following:
The app as a whole consists of four components that will be deployed:
The demo will first walk-through setting ECS cluster from Web UI of AWS and later how to use ECS CLI.
First step in deploying any web application to create an ECS cluster from aws console. This is a fairly simple step as show in picture below:
Now that a bare minimum cluster is created its time to use ECS CLI. ECS CLI is a command line tool that you can use with given credentials to manage you cluster and prepare to run tasks and services on it.
To install the ECS CLI , simply download the ECS CLI binary as shown here
Next step is to configure ECS CLI so that it stores our AWS credentials. Use your own AWS credentials with ECS CLI as:
ecs-cli configure --region us-west-2 --access-key
INFO[0000] Saved ECS CLI configuration for cluster (cs6320)
ECS CLI gives you full capability to create cluster from the CLI also.
Declaring tasks can be done from the Console or CLI. ECS CLI has a neat feature of supporting docker-compose , which are docker native way of declaring services. We avoided the hassle by reusing same compose based definitions as ECS CLI already supported them. The compose for our app looks like:
Now is the time to finally start our webapp from the compose file.
Once that’s successful, you will see the status using ecs cli.
Now we verify the status of containers by running “ps” command from ecs-cli as:
We can also verify that all services are up and cluster status from console.
Scaling a webapp to multiple instances is simply one command. Lets say we want to scale to 5 , we can then issue the command as:
ecs-cli compose --file docker-compose.yml --project-name cs6320_1 scale 5
CS6320 Project 2 ECS Tutorial.
Submitted By:Harkirat Singh, Harman Gill,Muhammad Imran Malik, Mauro Pappatera