Deployment Strategies
Deployment Patterns
Two identical production environments (blue and green). Deploy new version to inactive environment. Test thoroughly before switching. Instant cutover via load balancer or DNS. Quick rollback by switching back. Zero downtime deployment. Full environment duplication cost. Stateful applications require data synchronization. Database migrations challenging. AWS Elastic Beanstalk, Cloud Foundry support.
Gradual rollout to subset of users. Start with 5-10% traffic to new version. Monitor metrics and errors. Increase traffic progressively (10% → 25% → 50% → 100%). Automated or manual promotion. Early detection of issues with limited blast radius. Requires traffic routing capability. Feature flags for fine-grained control. Kubernetes, service mesh, API gateway support. Similar to phased rollout.
Gradual replacement of instances with new version. Update subset at a time maintaining availability. Stop-the-world for batch, then proceed to next. Configurable batch size and interval. Slower than blue-green but no duplicate environment. Kubernetes rolling update. Mixed versions running temporarily. Requires backward compatibility. Automatic rollback on failures. AWS ECS rolling update.
Stop all instances then deploy new version. Simplest strategy with downtime. Suitable for non-critical applications. Complete shutdown before startup. No resource duplication needed. No compatibility concerns between versions. Fast when downtime acceptable. Maintenance windows for planned downtime. Development and staging environments. Legacy applications without HA requirements.
Deploy new version alongside production receiving copy of traffic. New version processes requests without affecting users. Compare results between versions. Performance and behavior testing with real traffic. Risk-free validation before full deployment. Requires traffic mirroring/duplication. Resource overhead for parallel processing. Detect bugs and performance issues. Service mesh (Istio) traffic mirroring. Also called dark launching.
Deploy multiple versions for experimentation. Route users based on criteria (location, device, user segment). Measure business metrics and user behavior. Statistical analysis determines winner. Feature flags for user targeting. Multi-armed bandit algorithms. Gradual shift to winning variant. Marketing and product experimentation. LaunchDarkly, Optimizely. Different from canary (business metrics vs technical metrics).
CI/CD Practices
Automated path from code commit to production. Source control triggers. Build, test, security scan, artifact creation, deployment stages. Pipeline as code (Jenkinsfile, GitHub Actions YAML). Parallel stages for speed. Manual approval gates for production. Environment-specific configurations. Rollback capabilities. GitLab CI, Jenkins, GitHub Actions, Azure DevOps, CircleCI. Fail fast principle. Visualize pipeline status.
Progressive testing confidence levels. Unit tests (fast, isolated). Integration tests (service interactions). Contract tests (API compatibility). Performance tests (load, stress). Security tests (SAST, DAST, dependency scanning). End-to-end tests (user journeys). Smoke tests post-deployment. Test pyramid: many unit, fewer integration, few E2E. Shift-left testing. Quality gates block bad code. Parallel test execution.
Storing and versioning build outputs. Container images in registries (Docker Hub, ECR, ACR, GCR). Package repositories (npm, Maven, PyPI, NuGet). Binary artifacts (JARs, WARs, ZIPs). Immutable artifacts with semantic versioning. Tag with git commit SHA, build number. Artifact promotion between environments. Retention policies for storage management. Security scanning of artifacts. JFrog Artifactory, Nexus Repository.
Zero-touch deployment process. Infrastructure as Code provisioning. Configuration management. Database migrations. Service startup and health checks. Traffic routing updates. Monitoring and alerting setup. Rollback triggers. Ansible, Terraform, CloudFormation for automation. GitOps with ArgoCD, Flux. Reduce human error and increase velocity. Consistent deployments across environments. Deployment frequency as DORA metric.
Continuous Delivery: automated pipeline to production-ready state, manual release decision. Continuous Deployment: every change automatically deployed to production. CD enables business to choose release timing. CD requires high confidence in automated testing. Gradual progression from CI → Continuous Delivery → Continuous Deployment. Feature flags separate deployment from release. Deployment frequency and lead time for changes (DORA metrics).
Single artifact deployed across all environments. Environment-specific configuration external to artifact. Prevents environment drift and surprises. Container images ideal for this pattern. Configuration via environment variables, config files, secret managers. Immutable infrastructure principle. Same artifact tested in dev runs in prod. Reduces build time. Twelve-factor app methodology. Separates code from config.
Release Management
Runtime control of feature availability. Decouple deployment from release. Gradual feature rollout and A/B testing. Kill switch for problematic features. Canary releases at feature level. Permanent flags (ops toggles) vs temporary (release toggles). Flag management platforms (LaunchDarkly, Split.io, Unleash). Technical debt from stale flags. Testing complexity with flag combinations. Experimentation and trunk-based development enabler.
Scheduled, regular release cadence. Weekly, bi-weekly, or monthly releases. Features ready board the train, others wait. Predictable release schedule. Reduces release pressure and risk. Aligns with business planning. Combined with feature flags for flexibility. Spotify model with weekly releases. SAFe Agile Release Train. Trade-off between predictability and speed. Suitable for large organizations.
Quick recovery from bad deployments. Blue-green: instant switch to previous environment. Rolling: redeploy previous version incrementally. Database rollback more complex (migrations, data changes). Feature flags to disable features. Forward-fix vs rollback decision. Automated rollback on error thresholds. Maintain previous artifacts for rollback. Test rollback procedures regularly. Immutable infrastructure simplifies rollback.
Communicate changes to stakeholders. User-facing changes and bug fixes. Breaking changes and migration guides. Performance improvements and deprecations. Semantic versioning implications. Automated generation from commits (conventional commits). Multiple audiences (users, developers, operators). API changelog for integration partners. Keep-a-changelog format. Link to documentation and issues. Transparency builds trust.
Expedited process for critical production issues. Branch from production, not develop. Minimal changes to fix specific issue. Fast-tracked testing and approval. Deploy via standard pipeline when possible. Document for post-mortem. Merge back to develop and main. Balance speed with safety. Avoid technical debt from rushed fixes. Security patches often hotfixes. Clear criteria for hotfix vs regular release.
Scheduled times for deployments. Change freeze during critical periods (holidays, major events). Deployment windows during business hours or off-hours. Balance stability with velocity. Freeze can create pileup of changes. Exception process for critical fixes. Reduced freeze with better practices (feature flags, automated testing). Document and communicate schedules. Cultural shift toward continuous deployment reduces need.
Environment Management
Dev, Test/QA, Staging/Pre-prod, Production environments. Development for active coding. Test for QA team validation. Staging mirrors production for final validation. Production serves users. Additional: sandbox, demo, performance testing. Short-lived environments for features. Production-like staging essential. Environment parity reduces surprises. Cost vs fidelity tradeoff. Infrastructure as code for consistency.
Minimize differences between environments. Same OS, runtime versions, dependencies. Similar resource sizing (scaled-down OK). Same deployment process. Reduces 'works on my machine' issues. Infrastructure as code ensures consistency. Containers for portable environments. Configuration differences via environment variables. Regular validation of parity. Twelve-factor app principle. Prod-like data in staging (anonymized).
Environment-specific settings external to code. Environment variables (12-factor). Configuration files per environment. Hierarchical config (defaults overridden by env-specific). Secret management (AWS Secrets Manager, Vault). Avoid hardcoded values. Version control for non-sensitive config. Type safety and validation. Spring Cloud Config, Consul. Separate config from code. Runtime configurability without redeployment.
Short-lived environments for specific purposes. Pull request preview environments. Feature branch deployments. Spin up on demand, tear down when done. Cost optimization by avoiding idle resources. Parallel testing and development. Heroku review apps, Netlify deploy previews, Vercel. Kubernetes namespaces for isolation. Infrastructure as code enables automation. Faster feedback on changes. Enable independent work.
Clear separation and controls. Stricter access controls for production. Change approval processes. Enhanced monitoring and alerting. Backup and disaster recovery for prod. Non-prod uses synthetic or anonymized data. Cost optimization in non-prod (smaller instances, auto-shutdown). Network isolation. Tag resources by environment. Different SLAs. Prod-like staging for final validation but not business-critical.
Automated creation of environments. Infrastructure as Code (Terraform, CloudFormation). Template-based with parameters. Self-service portals for developers. Standardized environments reduce drift. Environment as a service. Cloud provider automation (CloudFormation, ARM templates). Ansible for configuration. Fast environment creation enables experimentation. Cost tracking per environment. Teardown automation for cleanup.
Infrastructure as Code
Declarative infrastructure as code by HashiCorp. HCL language, provider model (AWS, Azure, GCP, 1000+ providers). State management (local, remote in S3/Terraform Cloud). Modules for reusability. Plan before apply for safety. Immutable infrastructure approach. Terraform workspaces for environments. Import existing infrastructure. Community modules. Open source with commercial Terraform Cloud offering. Most popular multi-cloud IaC tool.
Native IaC for AWS (CloudFormation) and Azure (ARM/Bicep). JSON or YAML templates. Stack-based deployment. Change sets preview changes. Drift detection. Nested stacks for modularity. Template designer tools. Strong integration with cloud provider. No state file management needed. Free service. Troposphere/CDK for programmatic generation. Bicep improves ARM readability.
Infrastructure as code using general-purpose languages. TypeScript, Python, Go, C#, Java. Leverage IDE features (autocomplete, type checking). Reuse language ecosystem (npm packages, etc.). Pulumi state management like Terraform. Multi-cloud support. Component model for reusable infrastructure. Mix imperative and declarative. Pulumi Cloud for state and CI/CD. Appeals to developers more than ops-specific DSLs.
Cloud-native IaC using programming languages. AWS CDK supports TypeScript, Python, Java, C#, Go. Synthesizes CloudFormation templates. Higher-level constructs than CloudFormation. Azure Bicep: DSL compiling to ARM templates. Type safety and IDE support. Testable infrastructure code. Steep learning curve but powerful. Growing ecosystems. Native integration with cloud provider services.
Git as single source of truth for infrastructure and apps. Declarative config stored in Git. Automated sync from Git to cluster. Pull-based deployment model. ArgoCD, Flux for Kubernetes. Audit trail via Git history. Pull requests for changes with reviews. Rollback via Git revert. Continuous reconciliation to desired state. Separate deployment from CI pipeline. Reduces cluster access needs. Immutable, versioned infrastructure.
Identify and correct infrastructure changes outside IaC. Manual console changes create drift. Terraform plan shows drift. CloudFormation drift detection. Policy enforcement (AWS Config, Azure Policy). Automated remediation or alerting. Prevent console access to reduce drift. Immutable infrastructure minimizes drift impact. Regular drift checks in pipeline. Import drift into IaC. Cultural: all changes via IaC. Config drift causes unpredictable behavior.
