Last modified: April 27, 2026

This article is written in: πŸ‡ΊπŸ‡Έ

Deployment Strategies

A deployment strategy defines how a new version of an application is released to production. The right strategy balances risk, speed, infrastructure cost, and rollback complexity.

Rolling Update

A rolling update replaces instances of the old version one at a time (or in small batches), keeping the cluster available throughout.

Before   Step 1       Step 2       Step 3   After
  ──────   ──────────   ──────────   ──────   ─────
  [v1]     [v2]         [v2]         [v2]     [v2]
  [v1]  β†’  [v1]    β†’   [v2]    β†’   [v2]  β†’  [v2]
  [v1]     [v1]         [v1]         [v2]     [v2]

Characteristics:

When to use: Most stateless services with backward-compatible changes.

Kubernetes configuration:

strategy:
  type: RollingUpdate
  rollingUpdate:
    maxSurge: 1        # extra pods allowed during update
    maxUnavailable: 0  # no pods removed until replacement is ready

Blue-Green Deployment

Two identical production environments exist simultaneously. Only one environment (blue) receives live traffic. The new version is deployed to the idle environment (green), tested, then traffic is switched over instantly.

Load Balancer
              |
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β–Ό                   β–Ό
  [Blue v1]          [Green v2]  ← new version deployed here
  (live traffic)     (idle)

        ──── switch ────►

         Load Balancer
              |
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β–Ό                   β–Ό
  [Blue v1]          [Green v2]
  (idle / standby)  (live traffic)

Characteristics:

When to use: High-stakes releases where instant rollback is essential; when infrastructure cost of running two environments is acceptable.

Canary Release

A small percentage of traffic is gradually shifted to the new version. Metrics and error rates are monitored before widening the rollout.

β”Œβ”€β”€β–Ί [v2] 5% of traffic
  Load Balancer ───►│
                    └──► [v1] 95% of traffic

              ... watch metrics ...

                    β”Œβ”€β”€β–Ί [v2] 50%
  Load Balancer ───►│
                    └──► [v1] 50%

              ... watch metrics ...

                    β”Œβ”€β”€β–Ί [v2] 100%
  Load Balancer ───►│
                    └──► [v1] 0%  (decommissioned)

Characteristics:

When to use: High-traffic services where bugs have a large customer impact; machine learning model updates; significant user-facing changes.

Kubernetes with Nginx Ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: myapp-canary
  annotations:
    nginx.ingress.kubernetes.io/canary: "true"
    nginx.ingress.kubernetes.io/canary-weight: "10"  # 10% to canary
spec:
  rules:
    - host: api.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: myapp-v2-svc
                port:
                  number: 80

Feature Flags

Feature flags (also called feature toggles) decouple deployment from release. Code is shipped to production in a disabled state, then enabled independently of a deployment.

Deploy (always)                 Release (controlled)
  ──────────────────              ──────────────────────
  git push β†’ CI β†’ prod    +       Feature Flag ON/OFF
                                  (per user, group, %)

Types:

Type Lifespan Purpose
Release toggle Short Hide incomplete features until ready
Experiment toggle Medium A/B testing, canary experiments
Ops toggle Long Kill switch for expensive or risky code paths
Permission toggle Long Grant features to specific user groups

Simple implementation:

import os

FEATURE_FLAGS = {
    "new_checkout_flow": os.getenv("FF_NEW_CHECKOUT", "false").lower() == "true",
    "recommendations_v2": os.getenv("FF_RECS_V2", "false").lower() == "true",
}

def is_enabled(flag: str) -> bool:
    return FEATURE_FLAGS.get(flag, False)

In production, tools like LaunchDarkly, Unleash, or Flagsmith provide dynamic flag evaluation, user targeting, and percentage rollouts without redeployment.

Benefits:

Risks:

Recreate (Big Bang)

All old instances are terminated before new instances start. Results in a brief outage.

[v1] [v1] [v1]  β†’  (down)  β†’  [v2] [v2] [v2]

When to use: Development or staging environments where downtime is acceptable; breaking database schema changes that cannot be run side-by-side.

Comparison

Strategy Downtime Rollback Speed Resource Cost Risk Scope
Recreate Brief outage Fast (redeploy old) Low 100%
Rolling None Slow (redeploy) Low (+1 surge) Decreasing
Blue-Green None Instant (traffic flip) 2Γ— 0% after switch
Canary None Fast (reroute) Low (+canary) Small %
Feature Flag None Instant (toggle off) None Configurable

Choosing a Strategy

  1. Is downtime acceptable? If no, rule out Recreate.
  2. Are the changes backward-compatible? If no, Blue-Green avoids mixed-version coexistence.
  3. Is production traffic the only way to validate? If yes, use Canary.
  4. Is infrastructure cost a constraint? If yes, prefer Rolling over Blue-Green.
  5. Should release be decoupled from deployment? If yes, add Feature Flags.

Rollback Planning

Every deployment strategy must have a tested rollback procedure before the change goes to production.

Document the rollback steps in a runbook and test them in staging before each significant release.