When using the Elastic Load Balancing (ELB) integration feature of AWS CodeDeploy, deployments take more time than I expected. What's causing this?

When adopting ELB for CodeDeploy, deployments might take longer, especially during BlockTraffic and AllowTraffic lifecycle event hooks.

The BlockTraffic and AllowTraffic lifecycle event hooks are added into the CodeDeploy deployment procedure when an ELB is added to the Deployment Group. These event hooks are reserved for the AWS CodeDeploy agent. They can't be used to run scripts, as they are dedicated to deregistering instances from the ELB during the deployment, and re-registering them after the deployment completes.

The BlockTraffic and AllowTraffic hooks operate differently than the other lifecycle hooks, because they’re dependent on the ELB service for operation. The duration of these hooks is directly affected by two ELB health check settings: the HealthCheck Interval and the Healthy Threshold.

The HealthCheck Interval is the time between ELB health checks, and the Healthy Threshold is the minimum number of checks needed to consider an instance healthy. CodeDeploy adds an additional HealthCheck Interval to make sure that there is enough time for the de-registration, or for the draining and re-registration of the instance to complete.

This duration of the expected stage time can be calculated using the following formula:

(Healthy Threshold x HealthCheck Interval) + 1 additional HealthCheck Interval = Expected Stage Time

For example, suppose that a service takes 10 seconds to start. The ELB is configured to do health checks at a HealthCheck Interval of every 10 seconds, with a Healthy Threshold of 5 successful checks. Using the formula, you can then calculate how long the BlockTraffic and AllowTraffic lifecycle hooks will take:

(5 x 10) + 10 = 60 seconds

Therefore, the Expected Stage Time for each of these hooks is about 1 minute.

To reduce the time taken by these stages, reduce either the HealthCheck Interval on which the ELB sends health checks, or the Healthy Threshold.

Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center.

Published: 2018-10-30