ldm
ldm

Reputation: 267

How to add a warmup time for ecs tasks?

I am using ecs tasks to deploy my services. However, recently noticing that when I do an update on the service, the first task that starts up usually gets taken down immediately because it fails load balancer health checks. I think this is because it needs more time (a second or two more) to startup. How can I configure this?

Upvotes: 3

Views: 2523

Answers (1)

Jamie Starke
Jamie Starke

Reputation: 9234

When updating the ECS Service with a new Task Definition, I'd suggest also setting the healthCheckGracePeriodSeconds parameter. See Service Definition Parameters for more details.

If you're using the cli, you should be able to do this with aws ecs update-service --cluster <value> --service <value> --health-check-grace-period-seconds <value>.

If for example, your HealthCheck interval is 30 seconds, and 2 unhealthy checks will cause the service to be replaced, but you know your service takes, say 65 seconds to start up, you could set --health-check-grace-period-seconds 95, and this would tell ECS even if the service is considered unhealthy, let it keep going until 95 seconds would pass. I chose 95 in this case because the next healthcheck would be expected to come at 90 seconds, so if I did less than that, the load balancer may not notice the service is healthy before the unhealthy check takes effect.

Upvotes: 1

Related Questions