Skip to content

ECS service without loadbalancer - how to add a time for 'warming'?

0

When ECS service services web traffic, we have ALB target group healthcheck - so it's easy to control when ECS service will start getting traffic. What about ECS service without ALB, which receiving tasks from SQS for example? How I prevent situation when it's starting to process tasks too early? How I can add X second wait - only in code, or I can use container healthcheck?

asked 2 years ago305 views

1 Answer
6

Hello,

I would say 2 options here to add a warming period before your ECS service starts processing tasks from SQS:

  • In your application code: You can add a delay at the start of your application before consuming messages from SQS. This gives your container some time to initialize properly.

  • Using ECS container health checks: In your task definition, you can configure a health check that ensures your container is marked as "healthy" only after it's ready. I think using container health checks is a cleaner approach compared to adding delays directly in the application code.

You could also combine both approaches if needed!

Hope this helps!

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

  • Thank you, Jordan! I like the 2nd way, using healthcheck. But, after reading many docs and forums, I'm still not sure that ECS healthcheck will prevent task from communicate with SQS, database and other services. It seems that the only effect of failed healthcheck - it's task termination, after a few failed checks. I'll try to test....

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.