Cloud concept · Updated

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

In short

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.

Cloud Concepts Hub →

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.

01
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.

02
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.

03
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.

04
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.

05
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.

06
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 CodeDeployAWS 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 LambdaAWS 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 SageMakerAmazon 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 CloudWatchAmazon 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 CodePipelineAWS 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. Answer them with every option in the exam simulator.

MLA-C02 (beta)

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?

Show answerCORRECT 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.

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.

SAP-C03

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?

Show answerCORRECT 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.

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.

SOA-C03

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?

Show answerCORRECT ANSWER

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

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.

Practice Canary Deployment in a full exam

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

Start a free practice exam

What is Canary Deployment

3 min read

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.

and 6 more lessons

Open the lessons