Deploying Models with Guardrails and Automatic Rollback
This lesson explains deployment strategies that shift traffic gradually to a new model and roll back automatically, limiting the impact of a model that is slower, error-prone or less accurate on live data.
Learning outcomes
After completing this lesson, you will be able to:
- Use SageMaker AI deployment guardrails for blue/green updates.
- Roll back automatically on CloudWatch alarms.
- Choose between all-at-once, canary and linear shifting.
- Choose alarms and baking periods.
SageMaker AI deployment guardrails
When an endpoint is updated, SageMaker AI can perform a blue/green deployment: it creates a new fleet (green) beside the old one (blue) and shifts traffic according to a mode. All at once shifts everything, then watches for a baking period. Canary shifts a small portion, such as 10%, waits, then shifts the rest. Linear shifts traffic in equal steps, such as 20% every 10 minutes. Rolling deployment replaces instances in batches without creating a full second fleet, which suits large endpoints or scarce instance types.
Traffic shifting modes
Automatic rollback
Each deployment can specify CloudWatch alarms, for example on Invocation5XXErrors, ModelLatency or a custom business metric. If any alarm enters ALARM during traffic shifting or the baking period, SageMaker AI automatically rolls traffic back to the blue fleet. Beyond endpoint updates, rollback can also mean redeploying the previous approved model package or pointing an alias back to an earlier agent or prompt version.
The following diagram shows the traffic on each fleet over time during a canary deployment of a new recommendation model.

Automatic rollback
Choosing a strategy
SageMaker AI deployment guardrails offer several ways to shift traffic to a new model on an existing endpoint. All-at-once shifts all traffic immediately, which is fastest but riskiest. Canary shifts a small share first and the rest after a baking period. Linear shifts traffic in equal steps. Each can roll back automatically on alarms, and the right choice depends on how much risk a bad release would carry. The following table summarises the strategies.
| Strategy | Traffic shift | Extra capacity | Best for |
|---|---|---|---|
| All at once | 100% then bake | Full second fleet | Low-risk changes, fast rollout |
| Canary | Small share, then the rest | Full second fleet | Catching problems on a small share first |
| Linear | Equal steps over time | Full second fleet | Gradual exposure with checks at each step |
| Rolling | Batches of instances | Only one batch | Large endpoints, limited capacity |
Choosing alarms and baking periods
Automatic rollback is only as good as the alarms it watches. Operational alarms on Invocation5XXErrors and ModelLatency catch a model that crashes or slows down, but a model can serve fast, error-free and wrong predictions. To catch that, the application can publish a business or quality signal, such as the click-through rate of recommendations or the share of low-confidence predictions, as a custom CloudWatch metric and add an alarm on it to the rollback configuration.
Thresholds should be set relative to the current model's normal behaviour, for example a p99 latency 20% above the usual value, rather than at arbitrary absolute numbers. With a small canary, such as 10% of capacity, a metric is computed from fewer requests and is therefore noisier, so the wait interval must be long enough to collect a meaningful sample, and the alarm may need several evaluation periods before it fires.
The baking period is the time SageMaker AI keeps the old fleet after all traffic has shifted, while it continues to watch the alarms. It should cover the time a problem needs to appear, such as memory growth that causes failures after half an hour or a daily traffic peak. A shadow test before the deployment complements these mechanisms: it validates the new model on real traffic without user impact, and the guarded deployment then limits the impact of anything the shadow test could not measure, such as user behaviour.
Watch the canary
A canary with rollback
A recommendation model update must expose at most 10% of users to problems, and roll back automatically if error rates or latency rise.
"DeploymentConfig": {
"BlueGreenUpdatePolicy": {
"TrafficRoutingConfiguration": {
"Type": "CANARY",
"CanarySize": {"Type": "CAPACITY_PERCENT", "Value": 10},
"WaitIntervalInSeconds": 600 },
"TerminationWaitInSeconds": 300,
"MaximumExecutionTimeoutInSeconds": 3600 },
"AutoRollbackConfiguration": {
"Alarms": [{"AlarmName": "recs-5xx-high"}, {"AlarmName": "recs-p99-latency-high"}] } }10% of capacity receives the new model for ten minutes. If either alarm fires during that time or the baking period, traffic returns to the old fleet without human action.
Which deployment strategy suits large fleets or scarce capacity?
Show answer
A rolling deployment, which updates instances in batches without doubling capacity.
Exam Tips
Remember for the exam
- Small share first with automatic rollback: canary with CloudWatch alarms.
- Equal traffic steps: linear; everything at once: all-at-once with baking.
- Large fleets or scarce capacity: rolling deployment.
- Rollback is triggered by CloudWatch alarms during shifting or baking.
- Deployment guardrails apply when updating an existing endpoint.