Configuring Fargate task duration - Deregistering

0

Hi everyone! I've been working with a Fargate app recently and I've managed to make everything work (LB, listeners, routing, CNAME with Route53, https and http protocols), but for one thing:

The app itself is just a website, bundled into a docker image and the ECS Task deploys it. It does not generally have any task running, it starts the task once a call to the website is received. If it receives a call while the task is not running, the user gets a 503 response from the website. As soon as that happens, the task spawns and takes about 5 to 7 seconds to actually get up and running, the website does respond after that and the target registers. After 15 seconds or so, it deregisters again (and again, anyone that comes to the website after that, receives that 503). So the loop begins again.

There's this other Fargate app, done by John Doe, same logics, that keeps the task alive for longer once it's up and running (so far I've tested it with pings every 3 minutes and keeps responding, still testing and from the logs I realise that I doesn't go down as soon as the response is given, it does reach an idle state whereas mine doesn't).

The issue is that the task I've defined in task definition takes about 5 to 7 seconds to spawn and the website shows a 503 response until it does. But once the task is up and running, the website responds correctly and shows the page I want it to show. The other app has the exact same configuration regarding idle timeout of the LB, target groups, inbound/outbound rules, scaling rules, and so on. I don't think the problem is in the Load Balancer, nor in its target groups because they are configured correctly and the target group do register.

The only difference I've noticed is the behaviour of the task itself, once up and running, won't deregister after 15-30 seconds while mine does.

I need to know how to make that "task lifecycle" longer, the time the actual task lives. I've read somewhere that tasks can actually run for as long as we want. So my question is: How do I do that? How do I set up the "idle" time of a task in a Fargate app before it goes down again?

If the task is failing health checks, how do I troubleshoot health checks of the task without going into the target group thing? Could it be an issue with ECS deciding somehow that the task is failing health checks and so it takes it down again? If so, is there a way of telling ECS to keep it alive?

Thank you in advance!

No Answers

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.

Guidelines for Answering Questions