Skip to content

Zero-Downtime Blue/Green Deployments

Learn how epd ensures that zero live user requests are ever dropped during a deployment or rollback.


The Blue/Green Lifecycle

Unlike standard container restarts which drop connections while waiting for a new process to boot, epd uses alternating slots (blue and green):

[1. Build & Ship]             Builds image locally or uploads process archive


[2. Start Idle Slot]          Replicas boot up in the alternate slot (e.g., Green)


[3. Health Probe Loop]        Probes /health inside the server on each replica
        │                     └─► If fails: Green killed, Blue remains untouched!

[4. Atomic Traefik Switch]    Rewrites /var/lib/epd/proxy/dynamic/<app>.yml
        │                     └─► Traefik routes new traffic to Green instantly

[5. Connection Draining]      Waits drain seconds for in-flight requests to complete


[6. Retire Previous Slot]     Stops previous Blue slot replicas safely

1. Health Probe Verification

Before Traefik receives instructions to route traffic to the new version, epd probes every replica locally on the host server.

yaml
healthcheck:
  path: /health        # HTTP endpoint to probe (default: "/")
  status: 200-399      # Acceptable HTTP status codes (default: 200-399)
  timeout: 45          # Maximum seconds to wait before failing (default: 60)
  interval: 2          # Seconds between consecutive probe attempts
  delay: 2             # Delay in seconds before starting probes

Safety Guarantee:

If your new version crashes on boot, fails database migrations, or throws an unhandled exception:

  1. The health probe times out or encounters fatal errors.
  2. epd immediately cleans up the new slot.
  3. The existing slot remains live and serving traffic without interruption.
  4. No visitors experience an error or outage.

2. Connection Draining

When traffic is switched to the new slot, existing long-lived HTTP requests or WebSockets hitting the old slot need time to finish processing.

You can configure the drain period in epd.yml:

yaml
servers:
  web:
    hosts: [203.0.113.10]
    drain: 15          # Seconds to wait before stopping the old slot (default: 10)
    stop_timeout: 20   # SIGTERM to SIGKILL grace period for containers

3. Instant Rollback

Because epd preserves previous image releases and dynamic configurations on the host server:

bash
# Roll back immediately to the previous slot
epd rollback

# Or list all historical versions on servers:
epd rollback --list

# Roll back to a specific past version:
epd rollback v1.4.2

Rolling back does not require rebuilding or re-uploading your application code. epd spins up the previous version and performs an atomic route switch in under 3 seconds.


Next Steps

Released under the MIT License.