Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(aws-ecs): (Add deregistration delay parameter to FargateService construct) #31529

Open
2 tasks
lorenzozamponi opened this issue Sep 23, 2024 · 2 comments
Open
2 tasks
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@lorenzozamponi
Copy link

Describe the feature

Currently, when deploying a service using ECS Fargate without a load balancer, there is a fixed deregistration delay of 5 minutes for replaced tasks (old tasks enter a draining state and remain there for 5 minutes), which is non-configurable unless a load balancer with target groups is used. I am proposing the addition of a deregistrationDelay parameter to the FargateService construct in AWS CDK, allowing developers to customize this delay when a load balancer is not used.

Use Case

When deploying a service to ECS Fargate that does not require a load balancer, the deployment process is unnecessarily slowed down by the default 5-minute deregistration delay. For example, when tasks are replaced during a deployment, the old tasks enter a draining state and remain there for 5 minutes, even though the service doesn't need this full delay. This results in a longer deployment time than necessary, impacting deployment pipelines and delaying new service availability. Allowing users to specify a custom deregistration delay would optimize this process.

Proposed Solution

Introduce a deregistrationDelay option to the FargateService construct to specify the amount of time, in seconds, to wait before changing the state of a deregistering target from draining to unused. The range is 0-3600 seconds. The default value is 300 seconds.

Other Information

deregistration_delay.timeout_seconds used in aws_elasticloadbalancingv2

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

v2.150.0

Environment details (OS name and version, etc.)

Mac OS Sequoia

@lorenzozamponi lorenzozamponi added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Sep 23, 2024
@github-actions github-actions bot added the @aws-cdk/aws-ecs Related to Amazon Elastic Container label Sep 23, 2024
@ashishdhingra ashishdhingra self-assigned this Sep 23, 2024
@ashishdhingra ashishdhingra added p2 investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Sep 23, 2024
@ashishdhingra
Copy link
Contributor

ashishdhingra commented Sep 23, 2024

@lorenzozamponi Good afternoon. Thanks for opening the issue. Referring some of the articles like How to Speed Up Amazon ECS Container Deployments, deregistration_delay.timeout_seconds is used for configuring load balancer connection draining. Please advise:

  • How exposing deregistration_delay property at FargateService level would would be used for scenario where ECS Fargate is used without a load balancer?
      • If possible, could you also demonstrate your use case with sample CDK code?
  • Where are you observing the 5 minute delay?

Thanks,
Ashish

@ashishdhingra ashishdhingra added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Sep 23, 2024
@lorenzozamponi
Copy link
Author

Hi Ashish,

Thank you for your reply. As explained in the article Optimize load balancer connection draining parameters for Amazon ECS, the ECS agent ensures that the load balancer target is in an unused state before proceeding from draining to removing the old task. This means that an amount of time can be set to reduce the draining time of a task. This wait time (in the case of using a load balancer) can be reduced by using the deregistration_delay.timeout_seconds parameter. For example, by setting it to 5 seconds, the time between the draining state and task removal would be much faster, significantly reducing the deployment time.

  • How would exposing the deregistration_delay property at the FargateService level be used for scenarios where ECS Fargate is used without a load balancer?
    It would help reduce deployment time by shortening the draining period of a task, which by default seems to be set at 300 seconds. The general idea is to add a property that allows setting the task's drain time.

  • Where are you observing the 5-minute delay?
    The 300-second delay can be observed during the deployment of a service: once the new task is up, the old task remains in the draining state for 300 seconds before being removed.

Thank you very much,
Lorenzo

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Sep 24, 2024
@ashishdhingra ashishdhingra added the effort/medium Medium work item – several days of effort label Oct 9, 2024
@ashishdhingra ashishdhingra removed their assignment Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

2 participants