Learning center

ALB still sends traffic to the old target group after a deploy

Read RequestCount per target group to learn which group served the requests, then read the listener rules to learn which rule sent them there. A request served by the old group comes from a higher-priority rule, a weight or stickiness setting on a forward action, or a second listener that still points at the old group.

The signature and its nearby causes#

The deployment reports success. Amazon ECS shows the new service revision running, or the blue/green deployment has reached its clean-up stage, yet some or all responses still come from the previous version. On an Application Load Balancer, three settings can produce this, and each one leaves a different record:

  • Rule priority or conditions. The listener evaluates rules from the lowest priority value to the highest and runs the actions of the first rule whose conditions match. If no rule matches, it runs the default rule. A rule with a lower priority value that still forwards to the old group wins over the rule the deployment updated. CreateRule · Rule fields
  • Weights and group stickiness. A forward action can split requests across target groups by weight, from 0 to 999. With target group stickiness enabled on that action, the load balancer keeps a client on the group it first chose for DurationSeconds, up to seven days, by setting an AWSALBTG cookie. Forward action fields · Target group stickiness · Action types for listener rules
  • Another listener. The load balancer has a second production port, or an ECS blue/green test listener rule, whose rule or default action still forwards to the old group, and some clients send their traffic there. ECS blue/green resources for ALB

A fourth cause sits outside the load balancer: a browser, service worker or CDN cache answering with the old response. If the old group serves no requests, read which cache answered instead. Other routing and health signatures are in the signature table.

Read which target group served the requests#

RequestCount counts requests for which a load balancer node chose a target, and it publishes a LoadBalancer plus TargetGroup dimension set. That makes it the record of which group received traffic, minute by minute. List the dimension values first, because the value is part of the ARN and must match exactly. Use a read-only profile and replace the uppercase placeholders. ALB CloudWatch metrics · GetMetricStatistics

aws cloudwatch list-metrics \
  --profile PROFILE --region REGION --namespace AWS/ApplicationELB \
  --metric-name RequestCount --dimensions Name=TargetGroup \
  --query 'Metrics[].Dimensions' --output json --no-cli-pager

aws cloudwatch get-metric-statistics \
  --profile PROFILE --region REGION --namespace AWS/ApplicationELB \
  --metric-name RequestCount \
  --dimensions Name=LoadBalancer,Value=LB_DIMENSION Name=TargetGroup,Value=OLD_TG_DIMENSION \
  --start-time START --end-time END --period 60 --statistics Sum \
  --query 'sort_by(Datapoints,&Timestamp)[].[Timestamp,Sum]' \
  --output json --no-cli-pager

Run the second command once for the old group and once for the new one, over a window that starts before the traffic shift. If the old group's count falls to zero at the shift and stays there, the load balancer is routing as configured. If it keeps a steady share, or decays slowly over hours, a rule or stickiness setting is still sending clients there.

Read which rule sent them there#

List every listener on the load balancer with its default action, then read each listener's rules in priority order. describe-listeners · describe-rules

aws elbv2 describe-listeners \
  --profile PROFILE --region REGION --load-balancer-arn LB_ARN \
  --query 'Listeners[].{listener:ListenerArn,port:Port,protocol:Protocol,default:DefaultActions[].{type:Type,single:TargetGroupArn,groups:ForwardConfig.TargetGroups}}' \
  --output json --no-cli-pager

aws elbv2 describe-rules \
  --profile PROFILE --region REGION --listener-arn LISTENER_ARN \
  --query 'Rules[].{priority:Priority,isDefault:IsDefault,conditions:Conditions[].{field:Field,values:Values,paths:PathPatternConfig.Values,hosts:HostHeaderConfig.Values,header:HttpHeaderConfig.HttpHeaderName,headerValues:HttpHeaderConfig.Values},forward:Actions[?Type==`"forward"`].{single:TargetGroupArn,groups:ForwardConfig.TargetGroups,stickiness:ForwardConfig.TargetGroupStickinessConfig}}' \
  --output json --no-cli-pager

Find every rule whose forward action names the old group's ARN, either as single or inside groups with a weight above 0. A matching rule with a lower priority value than the rule the deployment changed is the first suspect. Then check stickiness: if Enabled is true, clients that the old group served before the shift stay there until DurationSeconds has passed.

If access logs were enabled before the incident, each entry records matched_rule_priority and target_group_arn. The priority is 0 when the request fell through to the default action. Together they name the rule and the group for each request, so a sample of entries that reached the old group points to the rule directly. ALB access log fields

Check what ECS blue/green resolved#

For an ECS service that uses the BLUE_GREEN, LINEAR or CANARY strategy, the service's advancedConfiguration names the alternate target group, the production listener rule and the optional test listener rule. Each service revision's resolvedConfiguration records which target group it serves and which production rule directs traffic to it. Service revisions created before October 25, 2024 can't be described. AdvancedConfiguration · ServiceRevision · DescribeServiceRevisions

aws ecs describe-services \
  --profile PROFILE --region REGION --cluster CLUSTER --services SERVICE \
  --query 'services[0].{strategy:deploymentConfiguration.strategy,current:currentServiceRevisions[].{arn:arn,running:runningTaskCount},lbs:loadBalancers[].{tg:targetGroupArn,alternate:advancedConfiguration.alternateTargetGroupArn,prodRule:advancedConfiguration.productionListenerRule,testRule:advancedConfiguration.testListenerRule}}' \
  --output json --no-cli-pager

aws ecs describe-service-revisions \
  --profile PROFILE --region REGION --service-revision-arns REVISION_ARN \
  --query 'serviceRevisions[].{arn:serviceRevisionArn,definition:taskDefinition,resolved:resolvedConfiguration.loadBalancers}' \
  --output json --no-cli-pager

Compare prodRule with the rules from describe-rules. The deployment changes that one rule. Any other rule on the production listener, and any default action on another listener, keeps the old target group until someone changes it.

What each result means#

Old group's RequestCount after the shiftRule readingLikely causeNext check
Steady shareA lower priority value forwards to the old groupRule priority or conditionsThe access log's matched_rule_priority for requests to the old group
Steady shareThe production rule has weight above 0 on the old groupWeights left in placeWhether the deployment tool or a manual change set the weights
Falls slowly over the stickiness durationTargetGroupStickinessConfig.Enabled is trueGroup stickinessDurationSeconds against the time since the shift
Steady shareProduction rules point at the new group; another listener's action points at the old groupSecond or test listenerWhich clients or DNS records use that listener's port
ZeroRules point at the new groupNot the load balancerBrowser, service worker or CDN cache

An illustrative fixture: two causes, same symptom#

This fixture is fictional. The service checkout moves from checkout:41 to checkout:42 with an ECS blue/green deployment at 14:00 UTC. The target groups are checkout-blue and checkout-green. The production listener on port 443 has rule priority 20, /*, which ECS moves to checkout-green at 14:06.

In the first reading, checkout-blue keeps about 30 percent of requests after 14:06. describe-rules on port 443 shows priority 5 with path pattern /api/*, forwarding to checkout-blue. An engineer added it during an earlier incident. It matches before priority 20, so API calls never reach the new revision. Access log entries for checkout-blue show matched_rule_priority 5.

In the second reading, the port 443 rules are correct and checkout-blue still receives a few hundred requests a minute. All of them arrive on the port 8443 listener, which holds the test listener rule. A partner integration was configured against the test port during a trial, and the test rule still forwards to checkout-blue after the deployment finished. The fix is the integration's endpoint, and a change to port 443 would not have moved that traffic.

Change the rule and confirm the shift#

These commands change the load balancer. modify-rule replaces the rule's whole action list with the actions you pass. If the rule also has an authenticate-oidc or authenticate-cognito action, passing only forward removes the authentication, so copy every action from describe-rules and change only the forward target. The command below is for a rule whose only action is forward. Delete or re-point a stray rule only after you know what traffic it was meant to carry. ModifyRule · modify-rule

# Change: forward the stray rule to the new target group
aws elbv2 modify-rule \
  --profile PROFILE --region REGION --rule-arn RULE_ARN \
  --actions Type=forward,TargetGroupArn=NEW_TARGET_GROUP_ARN \
  --output json --no-cli-pager

Confirm with the same RequestCount reads. The old group's count should fall to zero after the change, or by the end of the stickiness duration if stickiness was on. If access logs are enabled, entries after the change should show the intended matched_rule_priority and the new target_group_arn.

Where the reading stops#

RequestCount only counts requests where a node chose a target, so requests rejected earlier never appear in either group. Load balancer metrics are reported only while requests flow, so a quiet minute has no data point instead of a zero. The ECS fields requestedProductionTrafficWeight and requestedTestTrafficWeight on a service deployment are snapshots and may lag an active shift. ALB CloudWatch metrics · ServiceRevisionSummary

A request served by the new group can still return old content if the new task definition runs the old image, so confirm the image on the new revision before you read rules. Behind a Network Load Balancer, the old version can also keep serving clients on long-lived connections after the deploy. If the new group does receive the traffic and the load balancer answers with timeouts, read 504 errors after a deploy.

Bring the rule into code review#

Listener rules changed by hand drift from the infrastructure code that the next deployment applies. Put the rule set, with priorities and forward targets, in the pull request that changes it. Proofline reviews GitHub pull requests; new organizations get one calendar month of hosted code review without a cloud connection. Start a free GitHub review · Eligibility and fair-use terms · Current product availability

Questions#

How do I see which target group an ALB request went to?

Read RequestCount with the LoadBalancer and TargetGroup dimensions for each group. For individual requests, the access log's target_group_arn field names the group and matched_rule_priority names the rule, if access logs were enabled.

Why does traffic still reach the blue target group after the weights changed?

Check TargetGroupStickinessConfig on the forward action. With group stickiness enabled, a client stays on the group it was first sent to for DurationSeconds, so the old group's share falls gradually. Also check for another rule with a lower priority value that forwards to the old group.

Does an ECS blue/green deployment update every listener rule?

It updates the production listener rule and uses the test listener rule named in the service's advancedConfiguration. Other rules and other listeners' default actions keep whatever target group they name, so read them with describe-rules and describe-listeners.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading