What is blue-green deployment and how does it achieve zero-downtime releases?

Answer

Blue-green deployment maintains two identical production environments — blue (currently live) and green (new version). The new release is deployed to the idle environment (green), where it is fully tested including smoke tests and health checks. When confident, the load balancer switches 100% of traffic from blue to green in seconds — this is the actual "deployment" moment and it is instantaneous. If the green environment exhibits problems after the switch, rollback is immediate: flip the load balancer back to blue. The key requirements are: both environments must be provisioned and maintained simultaneously (doubling infrastructure cost during transitions), database migrations must be backward-compatible (both blue and green must work with the same database schema), and session affinity must be handled carefully. Blue-green is particularly effective for stateless services and is widely used with AWS Elastic Beanstalk, Kubernetes, and Heroku.