Sub topic 11
Rolling out in stages with a rollback path
Earlier chapters covered right-sizing, Arm64 compatibility checks, multi-architecture images and benchmarking. This chapter covers how to put Graviton and smaller instances into production without a risky cutover. The rollout is a series of small, reversible traffic shifts. Each shift is gated by metrics you chose in advance.
This chapter assumes you can do the following:
- Use Application Load Balancers (ALB), target groups and Auto Scaling groups (ASG).
- Read CloudWatch alarms.
- Run the AWS CLI.
- Build and push a multi-architecture image, as in the previous chapters.
Why a staged rollout
A benchmark shows that a workload can run well on Graviton. It does not show that your production traffic will behave the same way. Production adds cache warm-up, odd request shapes, long-lived connections and dependencies you did not test. A staged rollout limits the damage if the benchmark missed something.
A good rollout has three properties:
- Small first step. Only a few percent of traffic reaches the new instances, so a failure affects few users.
- Explicit gates. You decide before the rollout which metrics must stay healthy, and for how long, before the next step.
- Fast, rehearsed rollback. Returning to the old fleet takes one command or one console change and does not need a new build.
The same approach applies to a size change on x86 and to a move to Graviton. Change one variable at a time. If you move to Graviton and downsize in the same step, you cannot tell which change caused a regression.
The rollout stages
The sequence below works for most stateless services.
- Pre-production. Run the Graviton build in a staging environment with replayed or synthetic traffic. Confirm the process starts, health checks pass and the service handles its normal request mix.
- Canary. Send a small share of live traffic, typically 1 to 5 percent, to Graviton instances. This is the first real test.
- Ramp. Increase the share in steps, such as 25, 50 and 100 percent. Hold each step long enough to cover a representative load cycle, which for many services means at least one traffic peak.
- Retention. Keep the old x86 capacity running, with traffic weight at zero, for a defined period after 100 percent. Rollback depends on that capacity existing.
- Retirement. Remove the x86 fleet only after the retention window passes without regressions.
Running both architectures side by side
You need a way to run both fleets and to control how much traffic each gets.
Two Auto Scaling groups and two target groups
An AMI is built for one architecture, so an x86 launch template cannot launch Graviton instances. The simplest reliable design is two separate ASGs, one with an x86 launch template and one with an Arm64 launch template. Each ASG registers with its own target group behind the same ALB. Capacity and health are then independent, and the ALB listener controls traffic with weights.
Use the Arm64 AMI from the SSM lookup shown in the Arm64 chapter for the Graviton launch template. Check the architecture on a running instance with uname -m, which prints aarch64 on Graviton and x86_64 on Intel and AMD.
Weighted forwarding
The ALB listener accepts weights for several target groups in one forward action. This command sends 5 percent of requests to the Arm64 group:
aws elbv2 modify-listener \
--listener-arn arn:aws:elasticloadbalancing:us-east-1:111122223333:listener/app/my-alb/0123456789abcdef/0123456789abcdef \
--default-actions '[{
"Type": "forward",
"ForwardConfig": {
"TargetGroups": [
{"TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:111122223333:targetgroup/app-x86/0123456789abcdef", "Weight": 95},
{"TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:111122223333:targetgroup/app-arm64/0123456789abcdef", "Weight": 5}
]
}
}]'Rollback uses the same command with weights of 100 and 0. Because the change is a listener setting, it takes effect without launching or terminating any instance.
Other platforms
The idea is the same on other compute platforms, and only the mechanism differs.
- Amazon ECS. Set
runtimePlatformin the task definition to the architecture you want, and run the Arm64 service next to the x86 service behind weighted target groups. Both services can pull the same multi-architecture image tag. - Kubernetes (Amazon EKS). Use separate node groups per architecture. Use a
kubernetes.io/archnode selector, or let a multi-architecture image schedule onto either. Shift traffic with a weighted ingress or a service mesh. - AWS Lambda. Change the function architecture and shift traffic with a weighted alias. This is covered in the managed services chapter.
This ECS fragment pins a task definition to Arm64:
{
"family": "my-app-arm64",
"requiresCompatibilities": ["FARGATE"],
"networkMode": "awsvpc",
"cpu": "512",
"memory": "1024",
"runtimePlatform": {
"cpuArchitecture": "ARM64",
"operatingSystemFamily": "LINUX"
},
"containerDefinitions": [
{
"name": "app",
"image": "111122223333.dkr.ecr.us-east-1.amazonaws.com/my-app:1.0.0",
"essential": true
}
]
}Choosing gates
A gate is a metric and a threshold that must hold for a set time. Choose gates that reflect what users experience, and compare the Graviton group against the x86 group at the same time. A comparison removes the noise of daily traffic patterns.
| Gate | CloudWatch source | What a regression looks like |
|---|---|---|
| Error rate | `HTTPCode_Target_5XX_Count` on the target group | More 5xx responses than the x86 group |
| Latency | `TargetResponseTime`, p99 | Tail latency climbs even if the average is flat |
| Health | `UnHealthyHostCount` | Instances fail health checks or restart loops |
| Saturation | `CPUUtilization`, memory from the CloudWatch agent | CPU runs higher than the benchmark predicted |
| Business signal | Custom metric such as checkouts per minute | Throughput per request drops with no visible error |
Watch tail latency, not only the average. A change in instruction mix or memory behavior often shows first in p99.
Create the alarm before the canary starts. This alarm fires if p99 latency on the Arm64 target group exceeds 250 ms for 3 of 5 one-minute periods:
aws cloudwatch put-metric-alarm \
--alarm-name app-arm64-p99-latency \
--namespace AWS/ApplicationELB \
--metric-name TargetResponseTime \
--dimensions Name=TargetGroup,Value=targetgroup/app-arm64/0123456789abcdef Name=LoadBalancer,Value=app/my-alb/0123456789abcdef \
--extended-statistic p99 \
--period 60 \
--evaluation-periods 5 \
--datapoints-to-alarm 3 \
--threshold 0.25 \
--comparison-operator GreaterThanThreshold \
--treat-missing-data notBreachingThe threshold is in seconds, because TargetResponseTime is reported in seconds. Set your own number from the x86 baseline you measured earlier, usually with some headroom above it.
Automating the ramp and rollback
You can run the ramp by hand, but a short script keeps the steps consistent and makes rollback automatic. This version steps through the weights, waits at each step, and reverts if the alarm is in the ALARM state.
#!/usr/bin/env bash
set -euo pipefail
LISTENER_ARN="arn:aws:elasticloadbalancing:us-east-1:111122223333:listener/app/my-alb/0123456789abcdef/0123456789abcdef"
X86_TG="arn:aws:elasticloadbalancing:us-east-1:111122223333:targetgroup/app-x86/0123456789abcdef"
ARM_TG="arn:aws:elasticloadbalancing:us-east-1:111122223333:targetgroup/app-arm64/0123456789abcdef"
ALARM="app-arm64-p99-latency"
SOAK_SECONDS=900
set_weights() {
local arm=$1
local x86=$((100 - arm))
aws elbv2 modify-listener \
--listener-arn "$LISTENER_ARN" \
--default-actions "[{\"Type\":\"forward\",\"ForwardConfig\":{\"TargetGroups\":[{\"TargetGroupArn\":\"$X86_TG\",\"Weight\":$x86},{\"TargetGroupArn\":\"$ARM_TG\",\"Weight\":$arm}]}}]" \
> /dev/null
echo "Weights set: x86=$x86 arm64=$arm"
}
for pct in 5 25 50 100; do
set_weights "$pct"
sleep "$SOAK_SECONDS"
state=$(aws cloudwatch describe-alarms \
--alarm-names "$ALARM" \
--query 'MetricAlarms[0].StateValue' \
--output text)
echo "Alarm state after ${pct}%: $state"
if [ "$state" = "ALARM" ]; then
echo "Gate failed. Rolling back to x86."
set_weights 0
exit 1
fi
done
echo "Ramp complete. Keep x86 capacity during the retention window."A script like this checks the alarm only once per step. For production use, poll during the soak period, so a failure triggers rollback within a minute and does not wait out the full wait.
Edge cases and failure modes
- Too little traffic at the canary. At 5 percent, a low-traffic service may produce so few requests that percentile metrics are noisy or missing. An alarm in
INSUFFICIENT_DATAis not a pass. Use a larger canary share, a longer soak, or synthetic traffic. - Sticky sessions. If target group stickiness is on, users stay on the target group they first hit. Weights then change only the share of new sessions, and the ramp is slower than you expect. Rollback also leaves existing sessions on Graviton until they expire.
- Rollback capacity. If you scale the x86 ASG down as Graviton takes more traffic, a 100-to-0 rollback sends full load to a fleet that is too small. Hold x86 at enough capacity to take 100 percent until the retention window ends.
- Scaling policies differ. Graviton instances may reach a given load at a different CPU percentage than x86 instances. A target-tracking policy tuned on x86 can over-scale or under-scale the Arm64 group. Check the scaling activity during the canary.
- Architecture-specific artifacts. Compiled caches, native packages and build outputs keyed on a path or hash can collide or fail across architectures. A shared cache that holds both formats can serve an x86 binary to an Arm64 host and produce
exec format error. - State and schema changes. Do not combine the architecture change with a database migration or a data-format change. Rollback is only safe if the old fleet can still read what the new fleet wrote.
- Deregistration delay. When you shift traffic away from a target group, in-flight requests finish within the deregistration delay. Check that it is long enough for your slowest requests.
A rollout checklist
- Image and AMI exist for Arm64, and
uname -mconfirmsaarch64on a test instance. - Both target groups are healthy, and the alarms for the Arm64 group exist.
- The rollback command is written down and has been run once in staging.
- Capacity on x86 can take 100 percent of traffic.
- The canary runs for at least one representative load period.
- Each step has a recorded result for errors, latency and saturation.
- The x86 fleet stays until the retention window ends.
Exercise
You shift 5 percent of traffic to a Graviton target group. The p99 latency alarm stays in INSUFFICIENT_DATA for the whole soak because the service receives very few requests. Should you advance to 25 percent? What would you do instead?
Show answer
No. INSUFFICIENT_DATA means the gate gave no evidence, so it is not a pass. Either extend the soak, raise the canary share, or add synthetic traffic so the metric gets enough samples. Advance only when the alarm reports OK on real data.
Exercise
Your ASG scales the x86 fleet down as the Graviton share increases. At 80 percent Graviton, the error-rate gate fails and you set the weights back to 100 percent x86. Name one reason the rollback might still cause an outage, and one way to prevent it.
Show answer
The x86 fleet may now be too small to carry 100 percent of traffic, so it becomes overloaded. Prevent it by holding the x86 group at full capacity (for example, minimum size set to the peak need) until the retention window ends, and scale down only after that.
Exercise
Why is it better to use two Auto Scaling groups with separate launch templates for x86 and Graviton than one group with a single launch template?
Show answer
An AMI is built for a single architecture, so one launch template cannot launch both x86 and Arm64 instances. Separate groups give each architecture its own AMI, capacity and health, and let the ALB weights control the traffic split.