How Can I Optimize ECS Rolling Deployments on EC2 to Avoid Over-Provisioning?

0
19
Asked By TechExplorer99 On

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

Answered By BlueGreenBuff On

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!

Answered By DevOpsNinja01 On

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!

Answered By ServerSlayer88 On

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!

Answered By CloudGuru42 On

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.

Answered By DeployDynamo On

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.