# Canary Deployment

Canary deployment releases a new application or model version to a small portion of production traffic before expanding exposure after validation.

Cloud concept. Updated 2026-10-29. Page: https://blowstack.com/tools/cloud-concepts-hub/canary-deployment

> A canary deployment runs the current and candidate versions concurrently, exposing only a limited share of real requests or users to the candidate. Engineers use production metrics and explicit acceptance criteria to decide whether to promote the candidate or redirect traffic to the stable version, reducing the impact of faulty releases.

Practice exams covering Canary Deployment: [ANS-C01 AWS Certified Advanced Networking - Specialty](https://blowstack.com/practice-exams/aws-certified-advanced-networking-specialty), [SOA-C03 AWS Certified CloudOps Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-cloudops-engineer-associate), [DVA-C02 AWS Certified Developer - Associate](https://blowstack.com/practice-exams/aws-certified-developer-associate), [DOP-C02 AWS Certified DevOps Engineer - Professional](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional), [MLA-C02 (beta) AWS Certified Machine Learning Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-machine-learning-engineer-associate), [SAP-C03 AWS Certified Solutions Architect - Professional](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional).

## 6 key aspects of Canary Deployment

Canary deployment combines limited exposure, concurrent versions, measurable promotion gates, and a tested rollback path to reduce release risk.

1. **Limited production exposure**: Send only a small portion of live traffic or a controlled user cohort to the candidate. Choose the initial exposure according to workload risk and the volume needed to detect failures.
2. **Concurrent stable and candidate versions**: Keep both versions available during evaluation so traffic can be redirected without rebuilding the previous release. Provision enough capacity for the rollout and for the stable version to resume serving the full workload.
3. **Metric-driven promotion**: Define acceptance thresholds and observation periods before deployment. Evaluate candidate-specific errors, latency, resource pressure, and relevant application or model outcomes rather than relying only on basic health checks.
4. **Automated rollback**: Configure alarms and deployment controls to halt promotion and restore stable traffic when validation fails. Test this path explicitly, including alarm handling, routing changes, and recovery of full serving capacity.
5. **Controlled traffic progression**: Use routing weights or cohort assignments to increase exposure after successful evaluation. Account for sampling variation, session affinity, and uneven traffic before treating a configured percentage as an exact request distribution.
6. **Compatibility across versions**: Ensure both versions can safely use shared databases, queues, APIs, and session data during coexistence. Prefer backward-compatible changes because redirecting traffic does not reverse writes or external side effects.

## Cloud services for Canary Deployment

CodePipeline coordinates artifact delivery and deployment stages, while CodeDeploy manages supported canary rollouts for Lambda and ECS. Lambda weighted aliases or Application Load Balancer weighted target groups provide traffic-routing mechanisms, depending on the workload. CloudWatch supplies metrics and alarms that configured deployment controls use to stop or roll back a release. For machine learning, SageMaker AI deployment guardrails manage supported endpoint traffic shifts and use configured CloudWatch alarms for rollback. These services serve different roles: pipeline coordination, traffic control, health evaluation, and recovery must be connected explicitly rather than assumed to occur automatically.

- **[AWS CodeDeploy](https://blowstack.com/tools/cloud-services-hub/aws-codedeploy)**: Orchestrates canary traffic shifting for AWS Lambda and Amazon ECS deployments, with validation hooks and configurable alarm-based rollback. Its predefined canary configurations do not apply to EC2/on-premises deployments in the same way.
- **[AWS Lambda](https://blowstack.com/tools/cloud-services-hub/aws-lambda)**: Weighted aliases can distribute invocations between two published function versions. CodeDeploy can automate promotion and rollback, while alias routing supplies the underlying traffic split.
- **[Amazon SageMaker](https://blowstack.com/tools/cloud-services-hub/amazon-sagemaker)**: Deployment guardrails support canary traffic shifting for supported real-time inference endpoint updates. Configured CloudWatch alarms can trigger automatic rollback while the new serving fleet is evaluated.
- **[Amazon CloudWatch](https://blowstack.com/tools/cloud-services-hub/amazon-cloudwatch)**: Collects release-health metrics and evaluates alarms used by deployment automation. Publish or select version-specific metrics so candidate failures are not hidden by the larger stable population.
- **[AWS CodePipeline](https://blowstack.com/tools/cloud-services-hub/aws-codepipeline)**: Coordinates source, build, test, approval, and deployment stages in a CI/CD workflow. A deployment stage can invoke CodeDeploy, while model-serving workflows can invoke automation that updates SageMaker AI endpoints.

## Canary Deployment exam questions

Real practice exam questions on Canary Deployment, with the correct answer and its explanation.

### Question 1 (MLA-C02 (beta))

**Question:**

A retailer serves a recommendation model through an Amazon SageMaker AI real-time endpoint. A candidate model passes offline tests, but the ML team must measure its effect on completed purchases before promoting it. During a 24-hour evaluation, approximately 5% of signed-in customers must receive candidate recommendations, and each customer's model assignment must remain consistent across requests. Other customers must continue receiving recommendations from the current model. An existing application router can select an endpoint variant, and an automated workflow can evaluate purchase metrics and change routing configuration. If the candidate reduces purchase completion beyond an established threshold, the workflow must return affected customers to the current model.

Which deployment approach meets these requirements?

**Correct answer:** Deploy both models as production variants. Use a deterministic customer-ID assignment in the router to select approximately 5% of customers for the candidate, and specify TargetVariant on every invocation. Have the workflow promote the candidate only if acceptance criteria pass, or route all customers to the current variant if they fail.

**Explanation:** This limits exposure to a consistent customer cohort while returning actual candidate recommendations to those customers. Explicit variant targeting preserves assignments across requests. The automated acceptance gate can promote the candidate or restore routing to the retained current variant.

### Question 2 (SAP-C03)

**Question:**

A company uses AWS CodeDeploy to release a payment-processing Lambda function through a production alias. Each deployment sends 10% of requests to a candidate version for 10 minutes before shifting the remaining traffic. Some regressions cause the candidate to return errors while the stable version remains healthy, so the overall alias error rate can remain below 1%.

The company requires the deployment to stop and automatically restore all traffic to the stable version if the candidate's invocation error rate exceeds 5% for two consecutive 1-minute periods during the canary interval. Traffic is sufficient to evaluate this condition every minute. The solution must use managed deployment capabilities without custom rollback code.

Which configuration meets these requirements?

**Correct answer:** For each release, create a CloudWatch metric math alarm that calculates 100 × Sum(Errors) / Sum(Invocations), using metrics scoped to the production alias and the candidate's ExecutedVersion. Set the threshold to greater than 5% for two consecutive 1-minute periods. Associate the alarm with the CodeDeploy deployment group and enable automatic rollback for DEPLOYMENT_STOP_ON_ALARM.

**Explanation:** Scoping both metrics to the alias and candidate ExecutedVersion isolates the candidate's invocation error rate. The alarm stops the active CodeDeploy deployment when the threshold is breached. Enabling rollback for DEPLOYMENT_STOP_ON_ALARM makes CodeDeploy restore the previously successful version without custom rollback code.

### Question 3 (SOA-C03)

**Question:**

A company runs a payment-validation API by using Amazon API Gateway and AWS Lambda. The API Gateway integration invokes published Lambda version 41. A CloudOps engineer publishes version 42 and configures a Lambda alias named production with version 41 as its primary version and a routing weight of 5% for version 42.

During a release evaluation, API requests continue to invoke only version 41. The engineer verifies that the alias configuration is correct. All required invocation permissions are already configured.

The company requires approximately 5% of API invocations to reach version 42 while the remaining invocations continue to reach version 41. The public API endpoint must not change, and the engineer must be able to return all traffic to version 41 by changing only the alias configuration.

Which change meets these requirements?

**Correct answer:** Update the API Gateway integration to invoke the production alias ARN, retain the existing alias weights, and deploy the API change.

**Explanation:** Weighted alias routing applies only to invocations made through that alias. Pointing the integration to production exposes approximately 5% of invocations to version 42 while version 41 serves the remainder. Removing the additional version weight returns all subsequent alias invocations to version 41 without changing the public endpoint.

### Question 4 (DOP-C02)

**Question:**

A company runs a multi-tenant billing API on Amazon EC2 behind an Application Load Balancer (ALB). A release pipeline provisions a separate candidate fleet and target group while leaving the stable fleet unchanged. Both versions are compatible with the shared database.

The company selects 2% of tenant accounts to evaluate each release using real production requests. Every request from a selected tenant must reach the candidate version, including requests from different users, devices, and sessions. All other tenants must continue using the stable version. Tenants can share public IP addresses.

An existing trusted authentication gateway adds an X-Release-Cohort header with the value evaluation or stable to every request before forwarding it to the ALB. The gateway removes any client-supplied value for this header. The pipeline can modify ALB listener rules and evaluate release-specific billing-success metrics.

The pipeline must restore all requests to the stable version if acceptance criteria fail and promote the candidate for all tenants only after the criteria pass. Neither action may require replacing instances or changing DNS.

Which deployment design meets these requirements?

**Correct answer:** Create a higher-priority listener rule that forwards requests with X-Release-Cohort equal to evaluation to the candidate target group. Keep the default action forwarding to the stable target group. If acceptance criteria fail, remove the cohort rule; if they pass, change the default action to the candidate target group and remove the cohort rule.

**Explanation:** The trusted header provides a consistent tenant-level routing decision across clients and sessions. The selected tenants exercise the candidate under production conditions while other tenants remain on the stable release. Removing the rule restores stable routing, and changing the default action promotes the candidate without replacing instances or changing DNS.

### Question 5 (DVA-C02)

**Question:**

A company uses AWS CodeDeploy to release an AWS Lambda function. During the first stage of each deployment, the production alias routes 10% of invocations to the candidate version and 90% to the stable version. CodeDeploy monitors a CloudWatch alarm and is configured to roll back automatically if the alarm enters the ALARM state.

During a recent release, 8% of the candidate version's invocations failed, but the stable version had no failures. The alarm monitored the error percentage across all production alias invocations with a threshold of 2%, so the deployment continued. Invocation volume is sufficient to evaluate each version separately.

The developer must ensure that future deployments roll back when more than 2% of the candidate version's invocations fail during the evaluation period, regardless of the stable version's traffic volume. Which change meets this requirement?

**Correct answer:** Configure the alarm to evaluate 100 × candidate-version errors ÷ candidate-version invocations, and update the monitored version for each deployment. Retain the 2% threshold.

**Explanation:** Evaluating the candidate's errors against its own invocations measures the health of the limited-exposure release independently of stable traffic. The described release would produce an 8% error rate, triggering the alarm and the configured CodeDeploy rollback.

### Question 6 (ANS-C01)

**Question:**

A company runs a stateless HTTPS application on Amazon EC2 instances behind an Application Load Balancer (ALB). The production listener forwards requests to two target groups: 90% to a stable release and 10% to a candidate release. Each target group is associated with a separate EC2 Auto Scaling group spanning three Availability Zones. Target group stickiness is disabled, and the stable fleet has capacity to handle all traffic.

During a deployment test, every candidate instance fails its ALB health check. Some requests still fail instead of being routed to the stable release. The company requires automatic rollback of subsequent new requests as soon as its deployment monitor declares the candidate release failed, without waiting for replacement instances to become healthy. Normal operation must retain the independently scalable fleets and the 90/10 traffic split.

Which solution meets these requirements?

**Correct answer:** Configure the deployment monitor to invoke an AWS Lambda function that modifies the ALB listener's forward action, setting the candidate target group weight to 0 and the stable target group weight to 100 when the release fails.

**Explanation:** ALB weighted forwarding does not automatically redistribute a target group's weight when that group has no healthy targets. Explicitly changing the listener weights removes the failed candidate group from selection for subsequent new requests. The separate Auto Scaling groups remain independently scalable, and the normal 90/10 configuration can be used for future deployments.

## Practice Canary Deployment in a full exam

Questions on Canary Deployment in each practice exam, with every answer option and an explanation for each:

- [DOP-C02](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional): 6 questions
- [SOA-C03](https://blowstack.com/practice-exams/aws-certified-cloudops-engineer-associate): 5 questions
- [MLA-C02 (beta)](https://blowstack.com/practice-exams/aws-certified-machine-learning-engineer-associate): 3 questions
- [DVA-C02](https://blowstack.com/practice-exams/aws-certified-developer-associate): 3 questions
- [SAP-C03](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional): 1 question
- [ANS-C01](https://blowstack.com/practice-exams/aws-certified-advanced-networking-specialty): 1 question

## What is Canary Deployment

Canary deployment is a release strategy that limits initial exposure to a new version while validating it under real production conditions. Instead of replacing the entire workload immediately, engineers direct a small share of requests or a selected user cohort to the candidate version. The stable version continues serving the remaining traffic. If the candidate satisfies predefined health and performance criteria during an observation period, the release proceeds; otherwise, traffic returns to the stable version.

A practical example is an API release that initially receives 5% of requests while the existing version receives 95%. The deployment pipeline compares version-specific error rates, tail latency, resource saturation, and business outcomes such as successful checkout completion. After enough representative requests and a suitable observation period, the pipeline can promote the candidate to full traffic. Some implementations use one initial canary step followed by complete promotion; others increase exposure through several stages. Neither a particular percentage nor a fixed number of stages defines the concept.

Cloud implementations separate deployment from traffic exposure. For virtual machines, engineers can provision a small candidate fleet and use weighted load-balancer target groups or another routing layer to control traffic. Deploying to a small percentage of instances does not necessarily produce the same percentage of requests, because instance capacity, connection reuse, and routing behavior affect distribution. For containers, stable and candidate task sets or Kubernetes workloads can coexist behind weighted routing. A standard rolling update does not by itself provide a metric-gated canary release.

For serverless functions, a versioned alias can split invocations between an established version and a candidate. AWS CodeDeploy supports canary traffic shifting for Lambda and Amazon ECS deployments, including predefined configurations and configurable rollback behavior. Its EC2/on-premises deployment configurations do not provide the same predefined weighted canary traffic shifting; instance-based canaries require an appropriate orchestration and routing design. A CI/CD pipeline should publish immutable artifacts, execute validation hooks, start the rollout, evaluate its outcome, and retain the previous artifact for recovery.

Machine learning deployments apply the same principle to model-serving endpoints. A candidate model initially receives limited live inference traffic while engineers monitor invocation failures, latency, capacity, and model-specific quality indicators. Amazon SageMaker AI deployment guardrails support canary traffic shifting for supported real-time endpoint updates, with CloudWatch alarm-based rollback when configured. Operational health alone does not establish model quality: accuracy, business impact, or fairness measures may require delayed labels and longer observation. Shadow testing differs because copied requests normally do not determine the response returned to the user.

The main trade-offs are additional capacity, longer release duration, and more complex routing and observability. Metrics must distinguish stable and candidate versions; an aggregate error rate can hide a severe failure affecting only a small canary population. Low traffic may produce too few observations for a reliable decision. Random request weighting also does not guarantee that a user consistently reaches one version, so session-sensitive applications may need cohort assignment or suitable stickiness.

Canary and blue/green deployment are related but not identical. Blue/green describes maintaining separate current and replacement environments, while canary describes limiting and evaluating initial exposure; a blue/green deployment can therefore use canary traffic shifting. Canary deployment is also not primarily an A/B experiment, whose purpose is comparing alternatives rather than validating a release. Finally, rollback requires explicit configuration and cannot undo external side effects or incompatible database changes. Backward-compatible schemas, idempotent operations, and tested recovery procedures remain necessary.

## Learn Canary Deployment in lessons

12 short lessons on Canary Deployment in 4 certification courses.

- MLA-C02 (beta): Canary Deployment: automated traffic promotion and rollback (Premium), https://app.blowstack.com/lessons/canary-deployment-automated-traffic-promotion-and-rollback-mla-c02
- SAP-C03: Canary Deployment: Metric-gated traffic shifting (Premium), https://app.blowstack.com/lessons/canary-deployment-metric-gated-traffic-shifting-sap-c03
- SOA-C03: Canary Deployment: controlled production exposure (Premium), https://app.blowstack.com/lessons/canary-deployment-controlled-production-exposure-soa-c03
- DOP-C02: Canary Deployment: metric-gated traffic exposure (Premium), https://app.blowstack.com/lessons/canary-deployment-metric-gated-traffic-exposure-dop-c02
- MLA-C02 (beta): Blue-Green Deployment vs Canary Deployment (Premium), https://app.blowstack.com/lessons/blue-green-deployment-vs-canary-deployment-mla-c02
- SAP-C03: Blue-Green Deployment vs. Canary Deployment (Premium), https://app.blowstack.com/lessons/blue-green-deployment-vs-canary-deployment-sap-c03
