CLOUD CONCEPT

Canary Deployment

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

Cloud Concepts Hub →

What is 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.

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.

Key aspects of Canary Deployment

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

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.

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.

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.

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.

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.

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

Open AWS CodeDeploy →
AWS Lambda image 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.

Open AWS Lambda →
Amazon SageMaker image 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.

Open Amazon SageMaker →
Amazon CloudWatch image 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.

Open Amazon CloudWatch →
AWS CodePipeline image 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.

Open AWS CodePipeline →