Deployment Strategies | Blue-Green & Canary
Implement automated deployment pipelines that are reliable and safe. GitScrum supports blue-green, canary releases, and feature flag strategies with rollback.
7 min read
Manual deployments are slow, error-prone, and stressful. Automated deployments are repeatable, fast, and boringβwhich is exactly what you want. This guide covers strategies for building deployment automation that teams can trust.
Deployment Approaches
| Strategy | Risk Level | Rollback Speed |
|---|---|---|
| Blue-green | Low | Instant |
| Canary | Low | Fast |
| Rolling | Medium | Medium |
| All-at-once | High | Slow |
CI/CD Pipeline
End-to-End Automation
CI/CD PIPELINE STRUCTURE
ββββββββββββββββββββββββ
STAGES:
βββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CI/CD PIPELINE β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Build Test Deploy Deploy Deploy β
β βββββ ββββ ββββββ ββββββ ββββββ β
β Staging Canary Prod β
β βββββββ βββββββ βββββββ βββββββ βββββββ β
β βBuildβββββΆβTestsβββββΆβStageβββ[OK]ββΆβCanaryββββΆβ Prod β β
β βββββββ βββββββ βββββββ βββββββ βββββββ β
β β β β β
β [Auto] [Auto] [Manual] β
β or [Auto] β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
BUILD STAGE:
βββββββββββββββββββββββββββββββββββββ
βββ Compile/transpile code
βββ Install dependencies
βββ Generate artifacts
βββ Create Docker image
βββ Store in registry
βββ Versioned, reproducible
TEST STAGE:
βββββββββββββββββββββββββββββββββββββ
βββ Unit tests
βββ Integration tests
βββ Security scan
βββ Lint and style checks
βββ Build verification
βββ Quality gates
DEPLOY STAGING:
βββββββββββββββββββββββββββββββββββββ
βββ Automatic on main merge
βββ Full production-like environment
βββ Run smoke tests
βββ Manual testing possible
βββ Gate before production
DEPLOY PRODUCTION:
βββββββββββββββββββββββββββββββββββββ
βββ Manual approval (optional)
βββ Canary first (percentage)
βββ Monitor for errors
βββ Full rollout if healthy
βββ Auto-rollback on failure
βββ Zero downtime
Blue-Green Deployment
Instant Rollback Capability
BLUE-GREEN DEPLOYMENT
βββββββββββββββββββββ
CONCEPT:
βββββββββββββββββββββββββββββββββββββ
Two identical environments:
βββ Blue: Current production
βββ Green: New version
βββ Only one active at a time
βββ Switch is instant
βββ Rollback = switch back
FLOW:
βββββββββββββββββββββββββββββββββββββ
1. Blue is live (current version)
2. Deploy new version to Green
3. Test Green thoroughly
4. Switch traffic to Green
5. Green is now live
6. Blue becomes staging/backup
7. If problems: switch back to Blue
Before switch:
βββββββββββββββ βββββββββββββββ
β BLUE β β GREEN β
β v1.4.0 β β v1.5.0 β
β (LIVE) β β (testing) β
ββββββββ¬βββββββ βββββββββββββββ
β
βββββββΆβ Traffic
After switch:
βββββββββββββββ βββββββββββββββ
β BLUE β β GREEN β
β v1.4.0 β β v1.5.0 β
β (backup) β β (LIVE) β
βββββββββββββββ ββββββββ¬βββββββ
β
βββββββΆβ Traffic
BENEFITS:
βββββββββββββββββββββββββββββββββββββ
βββ Instant rollback (seconds)
βββ Zero downtime
βββ Full testing before go-live
βββ Clear separation
βββ Confidence in deployments
CONSIDERATIONS:
βββββββββββββββββββββββββββββββββββββ
βββ Need 2x infrastructure (temp)
βββ Database compatibility
βββ Session handling
βββ Cache warming
βββ Worth the complexity
Canary Releases
Gradual Rollout
CANARY DEPLOYMENT
βββββββββββββββββ
CONCEPT:
βββββββββββββββββββββββββββββββββββββ
Gradual traffic shift:
βββ Deploy new version
βββ Send small % of traffic
βββ Monitor for issues
βββ Increase % if healthy
βββ Full rollout or rollback
βββ Controlled risk
PHASES:
βββββββββββββββββββββββββββββββββββββ
Phase 1: 1% traffic (canary)
βββ New version gets 1%
βββ Monitor errors, latency
βββ Compare to baseline
βββ 15-30 minutes
βββ Quick detection
Phase 2: 10% traffic
βββ Increase if Phase 1 good
βββ More traffic validates
βββ Monitor same metrics
βββ 30 minutes
βββ Building confidence
Phase 3: 50% traffic
βββ Significant rollout
βββ Watch carefully
βββ Ready to rollback
βββ Approaching full
Phase 4: 100% traffic
βββ Full rollout
βββ Monitor continues
βββ Old version retired
βββ Deployment complete
AUTOMATION:
βββββββββββββββββββββββββββββββββββββ
Automated canary:
stages:
- deploy-canary:
weight: 1%
duration: 15m
- analyze-canary:
check: error_rate < 0.1%
check: latency_p99 < 200ms
on_fail: rollback
- expand-rollout:
weights: [10%, 50%, 100%]
duration_each: 30m
on_fail: rollback
Rollback Strategies
Fast Recovery
ROLLBACK STRATEGIES
βββββββββββββββββββ
AUTOMATIC ROLLBACK:
βββββββββββββββββββββββββββββββββββββ
Trigger rollback on:
βββ Error rate > threshold
βββ Latency spike
βββ Health check failures
βββ Memory/CPU issues
βββ Smoke test failures
βββ No manual intervention needed
Example config:
rollback:
triggers:
- condition: error_rate > 1%
duration: 5m
- condition: p99_latency > 500ms
duration: 10m
- condition: health_check == failing
count: 3
action: revert_to_previous
INSTANT ROLLBACK (Blue-Green):
βββββββββββββββββββββββββββββββββββββ
βββ Traffic switch
βββ Seconds to recover
βββ Previous version still running
βββ No redeploy needed
βββ Best rollback experience
REVERT DEPLOY (Redeploy):
βββββββββββββββββββββββββββββββββββββ
βββ Deploy previous version
βββ Minutes to recover
βββ Needs deployment time
βββ Works with any strategy
βββ Common approach
FEATURE FLAG ROLLBACK:
βββββββββββββββββββββββββββββββββββββ
βββ Disable feature flag
βββ Instant effect
βββ No deployment needed
βββ Granular control
βββ Best for feature issues
βββ Separate from deploy rollback
Database Migrations
Safe Schema Changes
DATABASE MIGRATION STRATEGY
βββββββββββββββββββββββββββ
PRINCIPLES:
βββββββββββββββββββββββββββββββββββββ
βββ Always backward compatible
βββ Separate from app deploy
βββ Rollback script ready
βββ Test in staging first
βββ Monitor during migration
βββ Never break running app
EXPAND-CONTRACT PATTERN:
βββββββββββββββββββββββββββββββββββββ
Adding column:
1. Expand: Add new column (nullable)
2. Deploy: App writes to both
3. Migrate: Fill old data
4. Contract: Make required, remove old
Example:
Phase 1 (expand):
ALTER TABLE users ADD COLUMN email_new VARCHAR;
Phase 2 (deploy):
App writes to both email and email_new
Phase 3 (migrate):
UPDATE users SET email_new = email WHERE email_new IS NULL;
Phase 4 (contract):
ALTER TABLE users DROP COLUMN email;
ALTER TABLE users RENAME email_new TO email;
TIMING:
βββββββββββββββββββββββββββββββββββββ
1. Run migration (before deploy)
2. Deploy app (uses new + old)
3. Verify success
4. Run cleanup migration (later)
Never run breaking migrations
in same deploy as code changes.
Deployment Notifications
Team Awareness
DEPLOYMENT NOTIFICATIONS
ββββββββββββββββββββββββ
NOTIFY ON:
βββββββββββββββββββββββββββββββββββββ
βββ Deployment started
βββ Deployment succeeded
βββ Deployment failed
βββ Rollback triggered
βββ Canary status changes
βββ Keep team informed
CHANNELS:
βββββββββββββββββββββββββββββββββββββ
βββ Slack #deployments channel
βββ Email for failures
βββ PagerDuty for critical failures
βββ Dashboard status
βββ Multiple channels for redundancy
GOOD NOTIFICATION:
βββββββββββββββββββββββββββββββββββββ
β
Deploy started: app v1.5.0 β staging
by @sarah via GitHub Actions
[View pipeline] [View PR]
β
Deploy complete: app v1.5.0 β staging
Duration: 3m 24s
All health checks passed
[View logs]
β Deploy failed: app v1.5.0 β production
Error: Health check timeout
Auto-rollback initiated
[View logs] [View incident]
GitScrum Deployment
Integration
GITSCRUM DEPLOYMENT FEATURES
ββββββββββββββββββββββββββββ
TASK STATUS ON DEPLOY:
βββββββββββββββββββββββββββββββββββββ
βββ Task deployed β automatic status update
βββ Environment tracking per task
βββ "Deployed to staging" label
βββ "In production" indicator
βββ Visibility of what's where
RELEASE TRACKING:
βββββββββββββββββββββββββββββββββββββ
βββ Release contains tasks
βββ Release deployment status
βββ What shipped with this release
βββ Changelog generation
βββ Complete release picture
βββ Stakeholder communication
DEPLOYMENT DASHBOARD:
βββββββββββββββββββββββββββββββββββββ
βββ Recent deployments
βββ What's in each environment
βββ Pending items for release
βββ Deployment frequency metrics
βββ Team visibility
Best Practices
For Deployment Automation
Anti-Patterns
DEPLOYMENT AUTOMATION MISTAKES:
β Manual deployments
β All-at-once to production
β No rollback plan
β DB migration in same deploy
β No monitoring during deploy
β Deploy Friday afternoon
β No staging environment
β No deployment notifications