Implementing Deployment Patterns
1. Blue-Green Deployment Pattern
| Aspect | Detail |
|---|---|
| Mechanism | Two identical envs; switch router from blue → green |
| Rollback | Switch router back; instant |
| Cons | 2× infra cost during deploy; DB schema must be compatible |
| Best For | Stateless services with fast cutover need |
2. Canary Deployment Pattern
| Step | Detail |
|---|---|
| Deploy | New version receives 1% traffic |
| Observe | SLO metrics, error rates |
| Promote | Step up: 5% → 25% → 50% → 100% |
| Rollback | Auto if SLO breach |
| Tools | Argo Rollouts, Flagger, Spinnaker |
3. Rolling Deployment Pattern
| Aspect | Detail |
|---|---|
| Mechanism | Replace pods N at a time (maxSurge / maxUnavailable) |
| Default | K8s Deployment default strategy |
| Pros | No extra infra; gradual |
| Cons | Mixed versions during rollout (must be compatible) |
4. A/B Testing Pattern
| Aspect | Detail |
|---|---|
| Goal | Compare variants on business metric (not infra) |
| Routing | By user attribute (cohort), not random per-request |
| Stat Significance | Power analysis; min sample size |
| Tools | LaunchDarkly, Optimizely, Statsig |
5. Shadow Deployment Pattern
| Aspect | Detail |
|---|---|
| Mechanism | Mirror production traffic to new version; discard response |
| Use | Validate performance/correctness without user impact |
| Cautions | Avoid double side-effects (writes); idempotent only or read-only |
| Tools | Istio mirror, Envoy traffic mirroring |
6. Feature Toggle Deployment Pattern
| Aspect | Detail |
|---|---|
| Mechanism | Deploy code dark; enable later via flag |
| Decouples | Deploy from release |
| Hygiene | Remove flags after rollout (avoid debt) |
7. Immutable Infrastructure Pattern
| Principle | Detail |
|---|---|
| Definition | Never patch in place; always deploy new artifact |
| Artifact | Container image / VM image |
| Benefits | Repeatable, predictable, eliminates config drift |
| Tools | Docker, Packer, K8s |
8. Zero-Downtime Deployment Pattern
| Requirement | Detail |
|---|---|
| Graceful Shutdown | Stop accepting; finish in-flight; SIGTERM handling |
| Readiness Probe | Remove from LB before terminate |
| Connection Draining | Wait for active conns to close |
| Backward-Compatible Schema | Migrations always compatible with N-1 |
| Idempotent Startup | New version safe to roll out gradually |
9. Parallel Run Pattern
| Aspect | Detail |
|---|---|
| Mechanism | Run old and new system; compare outputs; old is source of truth |
| Use | High-risk migrations (billing, payments) |
| Cutover | After confidence period, switch |
10. Progressive Delivery Pattern
| Aspect | Detail |
|---|---|
| Definition | Combine canary + feature flags + analytics for guarded rollouts |
| Tools | Argo Rollouts + Prometheus, Flagger, LaunchDarkly |
| Auto-Rollback | Based on SLO checks |
| Audience Targeting | By region, user segment, plan |