Search code examples
amazon-web-servicesamazon-ecs

ECS task definition - container per task or multiple container within task?


I searched the web for some practical information about task definitions and containers deployment but could not find any real life example.

Are there any situations where I would need to disperse my containers over multiple tasks instead of running multiple containers in 1 task?

For example, if I have one backend service and one frontend service, should I place both of them within the same task so they will share same network and be on the same host or should I create 2 separate tasks for them?


Solution

  • You can think of a task as the smallest unit in which ECS will scale. All containers in a task will be scheduled on the same host and can share information among each other. You'd put multiple containers in a single task if you want to implement patterns like sidecar, ambassador or adapter.

    In your specific case, I'd separate the frontend and backend containers in their own tasks as they will probably benefit from being independently scalable.