I'm working with ECS rolling deployments on EC2 and I've noticed a big issue: during deployments, I need to keep both the current and new tasks running until the new one is healthy. This means I'd have to allocate enough resources for two identical tasks at once, which leads to unnecessary costs since I'm mostly not deploying. I'm wondering if there's a better approach, like launching a new instance for the new task while the previous one shuts down once the new task is confirmed healthy. Has anyone implemented a setup like this?
5 Answers
In our team, we stick to Blue/Green deployments in production instead of rolling updates. While it costs a bit more infrastructure-wise, especially with Fargate, the trade-off of flexibility is worth it. If you go for rolling updates, be prepared for temporary resource bumps during deployments. ECS has also made improvements to their rolling update process that may help!
Look into options like Fargate or the Managed EC2 instances which will launch based on your requests. You can also disable rolling deployments by setting the max tasks to 100%, which might help you avoid over-provisioning. Balancing availability and cost is key with bin-packing here!
You might want to set up application autoscaling to address resource allocation better. I think it works based on CPU usage and requests, so that could help balance your resources. It needs a bit of research on how it integrates with ECS, though!
The ECS rolling update is indeed the default deployment model where new containers roll in while the old ones are retired. If you're using EC2, consider implementing cluster autoscaling. Your cluster might scale up slightly during a deployment and then scale down afterward. The extra costs are usually minimal, just a few cents.
One method is to set the max healthy tasks to 100% and the minimum to below that, which will terminate the old task before starting the new one. Just remember, this can result in downtime. Alternatively, you could use Fargate to eliminate these issues completely. Also, new ECS managed instances function similarly to Karpenter, scaling based on requests, which is worth checking out!

Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures