Zero-Downtime Deployments
Deploy application updates without any period of unavailability by gradually replacing old instances with new ones.
Description
Zero-downtime deployment is the practice of releasing new application versions without any interruption to end users. This is achieved by running old and new versions simultaneously during the transition period, gradually shifting traffic from old instances to new ones while monitoring for errors. The approach requires that the application, database schema, and APIs support running two versions concurrently.
Rolling deployments are the most common strategy: instances are updated one at a time (or in small batches), with each new instance passing health checks before the next old instance is taken down. Kubernetes implements this via Deployment resources with configurable maxSurge (extra instances during update) and maxUnavailable (instances that can be offline). The combination of maxSurge=1 and maxUnavailable=0 ensures capacity never drops below the desired replica count.
Critical prerequisites for zero-downtime deployments include backward-compatible database migrations (additive schema changes, not destructive), API versioning or backward-compatible changes, graceful shutdown in application code, properly configured health checks that only pass when the new version is ready to serve traffic, and sufficient load balancer drain time. Session management must be externalized (not stored in-process) so that sessions survive instance replacement.
Prompt Snippet
Configure rolling deployments with zero downtime: set Kubernetes Deployment strategy to RollingUpdate with maxSurge=1 and maxUnavailable=0. Ensure readiness probes pass only after full initialization (database connection pool warmed, caches primed). Set the load balancer's deregistration delay to 30s to drain in-flight connections. Require all database migrations to be backward-compatible (add columns as nullable, never rename/drop columns in the same release as code changes). Implement a deployment checklist gate that verifies API contract compatibility between old and new versions using consumer-driven contract tests.
Tags
Related Terms
Blue-Green Deployments
Maintain two identical production environments and switch traffic between them for instant deployment and rollback.
Canary Releases
Gradually roll out changes to a small subset of users before full deployment to detect issues with minimal blast radius.
Graceful Shutdown
Handle process termination signals to finish in-flight requests and close resources cleanly before exiting.
Health Check Endpoints
Expose HTTP endpoints that report application health status for use by load balancers, orchestrators, and monitoring systems.
Load Balancing
Distribute incoming network traffic across multiple server instances to ensure reliability and optimal resource utilization.
Database Migration in CI/CD
Automate database schema changes as versioned migrations integrated into the CI/CD pipeline with rollback safety.