ECS - Elastic Container Service

  • ECS tasks can also be assigned with IAM ROLES just like IAM Role or EC2 instances

  • Task definitions

    • Container information for your application

      • Docker image to use with each container , Docker networking mode

      • CPU and memory to use with each task

      • The IAM role that your tasks should use

      • The launch type to use (EC2 or Fargate)

      • The logging configuration,

      • what to do in case of failures

      • The command the container should run when it is started

      • Any data volumes that should be used with the containers in the task


  • ECS Task placement

    • Task placement strategies

      • Algorithm for selecting instances for task placement or tasks for termination.

      • binpack

        • minimizes the number of instances in use

        • Place tasks based on the least available amount of CPU or memory

      • random

        • randomly place the tasks

        • requires the LEAST amount of configuration (EASIEST)

        • follow the constraints that you specified both implicitly or explicitly

        • it makes sure that tasks are scheduled on instances with enough resources to run them

      • spread

        • Place tasks evenly based on the specified value

          • Host (instanceId)

          • Availability Zone ( attributes:ecs.availabiltiy-zone)

    • Task placement constraints

      • Rule that is considered during task placement.

      • Ex: place tasks based on Availability Zone or instance type

      • distinctInstance

        • Place each task on a different container instance

      • memberOf

        • based on expression

      • Task groups: set of related tasks

    • Cluster query language

      • Expressions that enable you to group objects

      • you can group container instances by Availability Zone, Instance type, or custom metadata

    • Task placement constraints place the tasks, but Cluster query language is the one which provides you with expression to group the task

    • Task placement strategies and constraints are usually used together

    • Task placement strategies and constraints are NOT supported for tasks using the Fargate launch type.

    • Fargate tasks are spread across Availability Zones

    • https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement-strategies.html

  • ECS Deployment types

    • Rolling update

      • Amazon ECS service scheduler replaces the currently running tasks with new tasks

    • Blue/Green deployment with CodeDeploy

      • Controlled by CodeDeploy

      • enables you to verify a new deployment of a service before sending production traffic to it

      • Canary: Traffic is shifted in two increments.

      • Linear: Traffic is shifted in equal increments with an equal number of minutes between each increment

      • All-at-once: All traffic is shifted from the original task set to the updated task set all at once.

    • External Deployment

      • third-party deployment

  • ECR

    • Fully Managed Docker container registry provided by AWS

    • Alternative to Docker Hub