You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use ApplicationLoadBalancedFargateService (currently 2.59.0) to deploy our dockerized application, however ECS decides to initialize task and assign target which is not enabled for ALB, getting error:
Target is in an Availability Zone that is not enabled for the load balancer
Health check endpoint is never reached by ALB, causing ECS to discard task after some time - this repeats indefinitely when we set desiredCount > 2 (ECS tries to run task in every availability zone obviously).
We have following availability zones:
eu-west-1a both public and private subnet
eu-west-1b both public and private subnet
eu-west-1c contains only private subnet
ALB should use a and b obviously, but ECS uses c as well.
If a service uses a load balancer and starts a task located in an Availability Zone that the load balancer isn't configured to use, then the task never passes the health check and the task is stopped.
Fargate service setup looks like this - we don't configure ECS nor ALB directly, my understanding was this should be done automatically:
// configuration and variables omittedconstvpc=Vpc.fromLookup(this,id,{vpcId: 'vpc-00000000000000000'});constcluster=newCluster(this,"AcmeCluster",{vpc: vpc,clusterName: 'Acme-Cluster'});constservice=newApplicationLoadBalancedFargateService(this,serviceId,{cluster: cluster,cpu: cfg.taskManagement.cpu,// Default is 256desiredCount: cfg.taskManagement.desiredCount,// Default is 1memoryLimitMiB: cfg.taskManagement.ram,// Default is 512publicLoadBalancer: true,// Default is false,// ...taskImageOptions: {image: ContainerImage.fromRegistry(asset.imageUri),logDriver: newAwsLogDriver({streamPrefix: 'Acme-Api',logGroup: logGroup}),}});service.targetGroup.configureHealthCheck({path: "/",interval: Duration.seconds(30),healthyHttpCodes: "200",healthyThresholdCount: 2,unhealthyThresholdCount: 3,timeout: Duration.seconds(5),});// don't drop long running incoming calls too early (they happen during peak load)// default 60// https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#connection-idle-timeoutservice.loadBalancer.setAttribute("idle_timeout.timeout_seconds","120");// speed up target deregistraion, moving from `draining` to `unused` state faster// default 300// https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html#deregistration-delayservice.targetGroup.setAttribute("deregistration_delay.timeout_seconds","20");// custom route53 registraionletloadBalancerTarget=newLoadBalancerTarget(service.loadBalancer);letrecordTarget=RecordTarget.fromAlias(loadBalancerTarget);newARecord(this,'AcmeDns',{target: recordTarget,recordName: cfg.domainNamePrefix,zone: cfg.hostedZone});
... but ECS was still using wrong availability zone.
We have several other projects where we use Fargate, but this is the first time I'm seeing such behaviour. I compared this CDK with other projects but couldn't spot any difference. What could be causing this?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
We use
ApplicationLoadBalancedFargateService
(currently2.59.0
) to deploy our dockerized application, however ECS decides to initialize task and assign target which is not enabled for ALB, getting error:Health check endpoint is never reached by ALB, causing ECS to discard task after some time - this repeats indefinitely when we set
desiredCount
> 2 (ECS tries to run task in every availability zone obviously).We have following availability zones:
eu-west-1a
both public and private subneteu-west-1b
both public and private subneteu-west-1c
contains only private subnetALB should use
a
andb
obviously, but ECS usesc
as well.This issue is described here: https://aws.amazon.com/premiumsupport/knowledge-center/ecs-fargate-load-balancer-errors/
Fargate service setup looks like this - we don't configure ECS nor ALB directly, my understanding was this should be done automatically:
I found somewhat related tickets:
I tried to add:
... but ECS was still using wrong availability zone.
We have several other projects where we use Fargate, but this is the first time I'm seeing such behaviour. I compared this CDK with other projects but couldn't spot any difference. What could be causing this?
Beta Was this translation helpful? Give feedback.
All reactions