6 min read • Guide 364 of 877
Continuous Deployment Strategies
Continuous deployment means every change that passes tests goes to production automatically. This requires confidence in your testing, monitoring, and rollback capabilities. Done well, it accelerates delivery and reduces risk. Done poorly, it creates chaos.
Deployment Spectrum
| Level | Automation | Risk |
|---|---|---|
| Manual | Low | High per deploy |
| Continuous Delivery | High | Lower |
| Continuous Deployment | Full | Lowest (small changes) |
Prerequisites
What You Need First
CD PREREQUISITES
════════════════
TESTING:
─────────────────────────────────────
Before continuous deployment:
├── Comprehensive unit tests
├── Integration tests
├── E2E tests for critical paths
├── High confidence in test suite
├── Tests catch real bugs
└── No flaky tests
PIPELINE:
─────────────────────────────────────
├── Fast CI (< 15 minutes ideal)
├── Automated quality gates
├── No manual steps
├── Reliable infrastructure
├── Parallel execution
└── Fast feedback
MONITORING:
─────────────────────────────────────
├── Real-time error tracking
├── Performance monitoring
├── Business metrics dashboards
├── Alerting on anomalies
├── Know when things break
└── Fast detection
ROLLBACK:
─────────────────────────────────────
├── One-click rollback
├── Database migration rollback
├── Tested regularly
├── Fast execution (< 5 min)
├── Confidence to roll back
└── Safety net
FEATURE FLAGS:
─────────────────────────────────────
├── Decouple deploy from release
├── Control feature activation
├── Gradual rollout capability
├── Kill switch for issues
├── Essential for CD
└── Safe experimentation
Deployment Pipeline
Automated Flow
CD PIPELINE
═══════════
PIPELINE STAGES:
─────────────────────────────────────
Push to main
│
▼
┌─────────────┐
│ Build │ Compile, dependencies
└──────┬──────┘
│
▼
┌─────────────┐
│ Unit Tests │ Fast, comprehensive
└──────┬──────┘
│
▼
┌─────────────┐
│ Integration │ Database, APIs
│ Tests │
└──────┬──────┘
│
▼
┌─────────────┐
│ Security │ SAST, dependency scan
│ Scan │
└──────┬──────┘
│
▼
┌─────────────┐
│ Deploy │ Staging environment
│ Staging │
└──────┬──────┘
│
▼
┌─────────────┐
│ E2E Tests │ Against staging
│ Smoke Tests │
└──────┬──────┘
│
▼
┌─────────────┐
│ Deploy │ Production deploy
│ Production │ (canary or full)
└──────┬──────┘
│
▼
┌─────────────┐
│ Monitor │ Watch metrics
│ & Verify │ Auto-rollback if issues
└─────────────┘
PIPELINE SPEED:
─────────────────────────────────────
Target times:
├── Build: 2-3 min
├── Unit tests: 3-5 min
├── Integration: 5-10 min
├── Deploy staging: 2-3 min
├── E2E tests: 5-10 min
├── Deploy prod: 2-5 min
├── Total: 20-35 min
└── As fast as possible
Rollout Strategies
Deployment Approaches
ROLLOUT STRATEGIES
══════════════════
ROLLING DEPLOYMENT:
─────────────────────────────────────
Gradual replacement:
├── Deploy to subset of servers
├── Health check passes
├── Deploy to more
├── Eventually all replaced
├── Zero downtime
└── Gradual transition
[Old] [Old] [Old] [Old]
↓
[New] [Old] [Old] [Old]
↓
[New] [New] [Old] [Old]
↓
[New] [New] [New] [New]
CANARY DEPLOYMENT:
─────────────────────────────────────
Test with small traffic:
├── Deploy to 1-5% of traffic
├── Monitor metrics
├── Compare to baseline
├── If good, expand
├── If bad, roll back
└── Controlled risk
Traffic split:
│ 95% → [Old Version]
│ 5% → [New Version] ← Watch closely
BLUE-GREEN:
─────────────────────────────────────
Parallel environments:
├── Blue: Current production
├── Green: New version
├── Test green fully
├── Switch traffic
├── Keep blue for rollback
└── Instant switch
┌──────────┐
Users ─┤ Router ├─── Blue (current)
│ │
│ ├─── Green (new)
└──────────┘
│
Switch when ready
FEATURE FLAGS:
─────────────────────────────────────
Deploy code, control activation:
├── Code deployed but flag off
├── Enable for internal users
├── Enable for 10% users
├── Enable for all
├── Separate deploy from release
└── Maximum control
Monitoring
Deployment Monitoring
DEPLOYMENT MONITORING
═════════════════════
KEY METRICS TO WATCH:
─────────────────────────────────────
After deploy:
├── Error rates
├── Response times
├── CPU/memory usage
├── Request volume
├── Business metrics
└── Compared to baseline
AUTOMATED CHECKS:
─────────────────────────────────────
Post-deploy verification:
├── Health endpoint check
├── Smoke test suite
├── Error rate threshold
├── Latency threshold
├── Auto-rollback triggers
└── Automated safety
DASHBOARD:
─────────────────────────────────────
Real-time visibility:
│ Error Rate: 0.1% ✓ (baseline: 0.1%)
│ p99 Latency: 120ms ✓ (baseline: 115ms)
│ Requests: 1.2K/min ✓
│ CPU: 45% ✓
│ Deploys today: 3
│ Last deploy: 15 min ago
└── At-a-glance health
ALERTING:
─────────────────────────────────────
Alert triggers:
├── Error rate > 1%
├── Latency > 2x baseline
├── Failed health checks
├── Memory > 90%
├── Immediate notification
└── Fast response
Rollback
Fast Recovery
ROLLBACK STRATEGY
═════════════════
ROLLBACK TYPES:
─────────────────────────────────────
Instant rollback:
├── Deploy previous version
├── Kubernetes: kubectl rollout undo
├── Container: previous image
├── Blue-green: switch back
├── < 5 minutes
└── Always possible
Feature flag disable:
├── Turn off feature
├── Code stays deployed
├── Feature disabled
├── Instant effect
├── No deploy needed
└── Fastest option
WHEN TO ROLL BACK:
─────────────────────────────────────
Trigger rollback:
├── Error rate spike
├── Major performance degradation
├── Critical bug discovered
├── Customer-facing issues
├── Don't wait, roll back
└── Fix forward later
AUTOMATED ROLLBACK:
─────────────────────────────────────
Criteria:
├── Error rate > threshold for 5 min
├── Failed health checks x3
├── p99 latency > 2x baseline
├── Auto-revert to previous
├── Notify team
└── Automated safety net
DATABASE CONSIDERATIONS:
─────────────────────────────────────
├── Forward-compatible migrations
├── Additive changes only
├── Old code works with new schema
├── Separate migration deploys
├── Careful with data changes
└── Rollback-friendly migrations
GitScrum Integration
Tracking Deployments
GITSCRUM FOR CD
═══════════════
DEPLOYMENT TRACKING:
─────────────────────────────────────
├── Link commits to tasks
├── Deployment history visible
├── What shipped when
├── Traceability
└── Connected
DEPLOYMENT TASKS:
─────────────────────────────────────
├── Label: deployment
├── Track deployment improvements
├── Pipeline enhancements
├── Monitoring setup
└── Continuous improvement
INCIDENT TRACKING:
─────────────────────────────────────
When issues occur:
├── Create incident task
├── Link to deployment
├── Root cause analysis
├── Improvement actions
└── Learn and improve
Best Practices
For Continuous Deployment
- Small changes — Less risk per deploy
- Comprehensive tests — Confidence to deploy
- Feature flags — Control releases
- Monitor everything — Know when broken
- Fast rollback — Recover quickly
Anti-Patterns
CD MISTAKES:
✗ Deploying without tests
✗ No monitoring
✗ Slow rollback
✗ Big bang changes
✗ No feature flags
✗ Ignoring failures
✗ No staging environment
✗ Coupled database migrations