I am new using Amazon ECS and I would like to know how to set up services in order to scale up / down one container easily.
Here is my project architecture:
- website: container with the website, only serving html pages and javascript/css/images. Listens on 80.
- api: container with the API developed in NodeJS serving json. Listens on 443.
- rabbitmq: container with rabbitmq. The api container is linked to it.
- worker: A container that waits for orders from rabbitmq (it is also linked to it) and process them, and then sends answers back to rabbitmq.
For now, I just created one task definition with all of my containers, and in my cluster I only have one service. I also have a load balancer on the API (so I can access it from the website via a DNS name).
It works fine, but I want to be able to launch more workers , without launching everything else, and I don't seem to be able to do that right now (correct me if I'm wrong). So I have a few questions:
- Do I need to create separate task definitions?
- Do I need to create separate services?
- If I create a task definition for each container (thus front with website, back with api, broker with rabbitmq and worker with worker), am I still able to link containers together, even though they are not in the same task definition?
Here is my current task definition:
{
"taskDefinitionArn": "arn:aws:ecs:ap-southeast-2:347930943102:task-definition/Flipendo:4",
"revision": 4,
"containerDefinitions": [
{
"volumesFrom": [],
"portMappings": [],
"command": [],
"environment": [
],
"essential": true,
"entryPoint": [],
"links": [
"rabbitmq"
],
"mountPoints": [],
"memory": 2048,
"name": "worker",
"cpu": 4096,
"image": "flipendo/worker"
},
{
"volumesFrom": [],
"portMappings": [],
"command": [],
"environment": [],
"essential": true,
"entryPoint": [],
"links": [],
"mountPoints": [],
"memory": 2048,
"name": "rabbitmq",
"cpu": 2048,
"image": "rabbitmq"
},
{
"volumesFrom": [],
"portMappings": [
{
"hostPort": 443,
"containerPort": 3000
}
],
"command": [],
"environment": [
],
"essential": true,
"entryPoint": [],
"links": [
"rabbitmq"
],
"mountPoints": [],
"memory": 2048,
"name": "api",
"cpu": 2048,
"image": "flipendo/api"
},
{
"volumesFrom": [],
"portMappings": [
{
"hostPort": 80,
"containerPort": 3000
}
],
"command": [],
"environment": [
{
"name": "API_PORT",
"value": "443"
},
{
"name": "API_ADDR",
"value": "load balancer dns server"
}
],
"essential": true,
"entryPoint": [],
"links": [
"api"
],
"mountPoints": [],
"memory": 1024,
"name": "website",
"cpu": 1024,
"image": "flipendo/website"
}
],
"volumes": [],
"family": "Flipendo"
}
Thank you very much.