When I create a new revision of my tasks in aws ecs, ecs creates two new instances as requested.
However, it leaves the other two untouched:
AWS does know, however that this is not correct:
Why is it like that?
I have a minimum health of 100% (two tasks) and a max of 200%.
My understanding is that it starts two new tasks and then kills the inactive ones. But the inactive ones just stay there forever (until I manually kill them), doing unpredicable things on old code.
Note that it isn't the old tasks, but the old task-definition that is inactive. You have two running tasks that are using taskdef:34 and 2 older ones that are using an older, now inactive taskdef.
ECS/ALB does stop routing new requests to the old tasks immediately, but they will stay around as long as there are active connections to them. This is really a mechanism to enable zero-downtime graceful switchover. If your app keep long lived connections, or that is the nature of your transactions, your old tasks will stick around for longer.
You can, if you so desire, select the old tasks and terminate them manually and immediately; or even write up a script to terminate all tasks running on older taskdefs. Needless to say, this can be disruptive to active connections/transactions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With