B. Blue Green a software delivery tutorial
Vol. I § Zero-downtime series § A series for junior developers
Zero-downtime delivery · 2 / 10 ·

Two slots, one of them live

The Titik Terang lab uses two names: blue and green. Both are containers from the same image, with different host ports.

Ports that stay on loopback

  • The app inside the container listens on :3000.
  • The blue slot maps to 127.0.0.1:18080.
  • The green slot maps to 127.0.0.1:18081.
  • Caddy listens on :8080 and picks one of those two ports.

Mapping to 127.0.0.1 keeps the slots local. Public readers only see Caddy.

Slot playground · two-slots
readerCaddy :8080blue :18080 · upgreen :18081 · down
Blue is live on :18080. Green sits idle on :18081.
  1. Blue is live on :18080. Green sits idle on :18081.
  2. Green can become live. Only one slot receives traffic.
state.jsonlive · last_deployed · rollback_versionstate.json remembers the live slot and the rollback version.

state.json

This small file remembers which slot is live and which version can be restored. The playbook reads it before it works. Change the live key in the explainer below to see which idle slot it would pick.

explainer · state
Explanation

The live slot is blue. The playbook will deploy to green on port 18081.

Reader notes

Chapter discussion appears once Giscus is connected to the site repository.