I am running long running tasks via ECS. The container instances are spread over multiple availability zones. Is it possible to define in ECS that when having more then 1 instance of a task, each task should run on another availability zone (if possible)? This feature would be awesome for high availability and fault tolerance. Right now it would be possible that all of my 5 instances of a task run on the same machine, therefore when the machine dies, the tasks would all need to be placed somewhere else by the scheduler and it would result in downtime of the service.

Hope you can help me out.


Today was announced AZ aware scheduling so this is solved now

Amazon Blog Post

| improve this answer | |

i'm facing the same issue.

At the moment, i'm using my own AMI with docker & awscli. I inject the init script with ec2_Data. This script launch dockersn apply crontabs (for cloudwatch metrics and backups) and initialize alarms.

I don't want to use a private registry or dockerhub, i'm loading docker images from S3

s3curl --id clouddocker -- -s --retry 5 --retry-delay 30 URL.gz | gunzip|docker load

| improve this answer | |
  • So you run one container per instance? – lukaswelte Oct 7 '15 at 16:46
  • It depends. I'm using VPC. Public IP/gateway instances are hosting several dockers (HaProxy, mailrelay, varnish - one per disponibility zone). Instances for mongodb only (replicaset - one per disponibility zone) , and Instance from autoscaling groups for handwriting recognition (CPU needed), are hosting only one docker as well. – mruellan Oct 8 '15 at 6:51
  • But then you still have a static partitioned server cluster. I love the flexibility mesos and ECS give you by just running the container where it fits in that moment – lukaswelte Oct 8 '15 at 7:00
  • Yes, static server are deployed with one command line, because everything is scripted. I did that before ECS was available. – mruellan Oct 8 '15 at 10:19

With ecs-cli, you can define subnets.

>ecs-cli up --help
   up - Create the ECS Cluster (if it does not already exist) and the AWS resources required to set up the cluster.

   command up [command options] [arguments...]

   --keypair        Specify the name of an existing Amazon EC2 key pair to enable SSH access to the EC2 instances in your cluster.
   --capability-iam Acknowledge that this command may create IAM resources.
   --size       [Optional] Specify the number of instances to register to the cluster. The default is 1.
   --azs        [Optional] Specify a comma-separated list of 2 VPC availability zones in which to create subnets (these AZs must be in the 'available' status). This option is recommended if you do not specify a VPC ID with the --vpc option. WARNING: Leaving this option blank can result in failure to launch container instances if an unavailable AZ is chosen at random.
   --security-group     [Optional] Specify an existing security group to associate it with container instances. Defaults to creating a new one.
   --cidr       [Optional] Specify a CIDR/IP range for the security group to use for container instances in your cluster. Defaults to if --security-group is not specified
   --port       [Optional] Specify a port to open on a new security group that is created for your container instances if an existing security group is not specified with the --security-group option. Defaults to port 80.
   --subnets        [Optional] Specify a comma-separated list of existing VPC Subnet IDs in which to launch your container instances. This option is required if you specify a VPC with the --vpc option.
   --vpc        [Optional] Specify the ID of an existing VPC in which to launch your container instances. If you specify a VPC ID, you must specify a list of existing subnets in that VPC with the --subnets option. If you do not specify a VPC ID, a new VPC is created with two subnets.
   --instance-type  [Optional] Specify the EC2 instance type for your container instances.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.