Continuous Deployment | Auto-Deploy to Production
Every change that passes tests deploys automatically. Requires comprehensive testing, feature flags, canary deployments, instant rollback, and excellent monitoring.
6 min read
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
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