Deployments (blue-green, rolling)

Deployment strategies control how new code is rolled out with minimal downtime and risk. Blue-green: two identical environments (blue = current, green = new); switch traffic in one go. Rolling: replace instances one (or a few) at a time while the rest serve traffic.

Blue-green: flip switch

flowchart TB LB[Load Balancer] LB --> Blue[Blue (v1) - active] LB -.->|Before| Green[Green (v2) - idle] LB -->|After switch| Green LB -.->|After| Blue

Rolling: gradual replacement

flowchart LR S1[v1] --> S2[v1] --> S3[v2] --> S4[v1] Note[One by one replace with v2]
StrategyHowPros / cons
Blue-greenDeploy to idle env; switch trafficFast rollback (switch back); double capacity during deploy
RollingReplace instances graduallyNo double capacity; mixed versions during deploy
CanarySend small % traffic to new versionLow-risk validation; more complex routing

Use blue-green when you want instant switch and easy rollback. Use rolling when you want to avoid running two full environments. Use canary to validate new version with a fraction of traffic before full rollout.