Skip to content

Guide

Blue-green deployment for Go

Blue-green keeps two slots per application. One serves traffic; the other is where the next version starts, proves itself, and waits for an atomic switch.

The sequence

A blue-green deploy builds a new version, starts it on the inactive slot with its own internal port, and waits for the configured health tier to pass. Only then does the proxy switch traffic, and only then is the previous instance drained and stopped.

Because the switch happens inside a host-local reverse proxy rather than by rebinding your public port, clients keep their connections and no request lands on a process that is not ready.

phelix · blue-green
phelix rebuild api --blue-green
starting candidate v8 on :8081
health http ok
proxy cutover :8080 to v8
drained v7

The app contract

The application must read the PORT environment variable for its listen port, which Phelix sets per instance. Prefer an explicit readiness endpoint so the deploy uses the strongest health tier; without one, Phelix falls back to any HTTP response or a TCP check and warns you.

An app that currently binds the public port itself (a classic stop-then-start build) cannot be enrolled in the proxy in place. Stop it once, deploy with --blue-green, and every deploy after that switches with zero downtime.

When a candidate fails

If the new instance fails its health check, the deploy aborts, the candidate is killed, and the current version keeps serving. The version pointer is promoted only after the deploy succeeds, so a failed release never leaves a broken current version.

Rollback uses the same topology: Phelix inspects how the app was deployed and uses blue-green or classic rollback to match.

Frequently asked questions

Short answers; the docs go deeper.

How do I do a blue-green deployment of a Go app?

Build a new version, start it on an inactive slot with its own internal port, wait for its health check to pass, switch traffic with an atomic proxy update, then drain the previous instance. Phelix runs that sequence with phelix rebuild <app> --blue-green.

Does blue-green deployment need a second server?

No. Both slots run on the same host and are distinguished by internal port. The public port stays bound to the proxy, which routes to whichever slot is active.

One binary between git push and production.

Install the CLI, verify the host, and follow the quick start to build your first application.

Read the docs