Skip to content

Blue-green deploy on PaaS: DNS swap vs LB target swap

Choosing the cutover mechanism for blue-green on managed PaaS — what DNS TTLs really cost you, what an LB target swap moves in milliseconds, and which one fits your rollback budget.

You ship a blue-green deploy at 2 PM on a Tuesday. Blue is the live environment, green is the new build. The cutover script swings DNS from blue.app.example.com to green.app.example.com, you watch the dashboards, and 50% of traffic moves over within five minutes. The other 50% keeps hitting the blue pool for the next four hours because somebody’s recursive resolver decided to honour its own minimum TTL instead of the 60 seconds you set. You roll forward, hot-patch a bug in green, and now the half of your traffic that’s still on blue is missing the fix. The mechanism you picked for the cutover is the bug.

What’s happening

Blue-green has two production realities. Pool A (blue) runs the current version. Pool B (green) runs the candidate. Cutover means redirecting client traffic from A to B in a single observable moment, and rollback means reversing it in less time than the incident takes to escalate. There are two common mechanisms on managed PaaS:

  • DNS swap. You update an A or CNAME record from blue’s address to green’s. Resolvers re-fetch when their cached TTL expires. The TTL you publish is a hint — many recursive resolvers enforce a minimum (commonly 30–300 seconds, occasionally up to an hour for older infrastructure), and some clients cache aggressively in-process (Java networkaddress.cache.ttl defaults to 30s but legacy values of -1 still exist). Practical convergence on a 60s TTL is “most traffic in five minutes, the long tail in 30–60 minutes.”
  • Load balancer target swap. Your PaaS exposes a single hostname pointing at a shared LB. Blue and green are two backend pools registered with the LB. Cutover is “change the active pool in the LB config” — typically an atomic operation that completes in under a second. Existing in-flight connections continue draining on the old pool while new connections route to the new one. Convergence is bounded by your connection-drain window (commonly 30–120 seconds), not by anybody else’s resolver.

If your rollback budget is ten minutes, DNS swap can’t meet it under adversarial caching. LB target swap can.

How to verify

Check what TTL is actually being served for your apex domain and any CDN-fronted record:

# Authoritative answer (skip resolver caches)
dig +short @ns1.example.com app.example.com A
dig app.example.com A | grep -E "IN\s+A"
# The TTL column is what your record advertises. The resolver lottery is what
# actually gets honoured.

# What public resolvers currently see
for r in 1.1.1.1 8.8.8.8 9.9.9.9 208.67.222.222; do
  echo "=== $r ==="
  dig +short @$r app.example.com
  dig @$r app.example.com | awk '/^app\.example\.com\./ { print $2; exit }'
done

Inspect the LB target group on a Jelastic-style PaaS (or whichever managed PaaS exposes the shared LB):

# Active targets on the load balancer
curl -sS -H "Authorization: Bearer $PAAS_TOKEN" \
  "https://app.paas.example.com/1.0/environment/control/rest/getenvinfo?envName=app-prod" \
  | jq '.nodes[] | {id: .id, name: .displayName, status: .status, ip: .intIP}'

# How long the LB takes to drain a node
curl -sS -H "Authorization: Bearer $PAAS_TOKEN" \
  "https://app.paas.example.com/1.0/environment/control/rest/getenvproperty?envName=app-prod&property=lbConnectionDrain"

If the drain window is shorter than your slowest in-flight request (long-polling, large file uploads, streaming responses), you’ll get connection resets on the old pool — measure the p99 request duration before you tune it.

The fix

Pick the cutover mechanism by your rollback budget. Anything tighter than “an hour” needs LB target swap, not DNS.

Mechanism 1 — LB target swap (recommended for sub-15-minute rollback). Both blue and green are PaaS environments behind a shared LB. The LB is the only thing the public hostname resolves to, so DNS never changes during a deploy.

# deploy-hook.yaml — runs from CI on cutover
name: blue-green-cutover
on:
  workflow_dispatch:
    inputs:
      target_color:
        description: "Pool to send traffic to (blue|green)"
        required: true
        type: choice
        options: [blue, green]

jobs:
  cutover:
    runs-on: ubuntu-latest
    steps:
      - name: Pre-flight green health
        run: |
          curl -fsS https://${{ inputs.target_color }}.internal.app.example.com/healthz
          # Block cutover if green is not 200

      - name: Swap LB target pool
        run: |
          curl -fsS -X POST \
            -H "Authorization: Bearer ${{ secrets.PAAS_TOKEN }}" \
            -d "envName=app-prod&pool=${{ inputs.target_color }}" \
            https://app.paas.example.com/1.0/lb/rest/setactivepool

      - name: Wait for drain
        run: |
          for i in $(seq 1 60); do
            DRAINING=$(curl -fsS -H "Authorization: Bearer ${{ secrets.PAAS_TOKEN }}" \
              "https://app.paas.example.com/1.0/lb/rest/getdrainstate?envName=app-prod" \
              | jq -r '.activeOldConnections')
            [ "$DRAINING" = "0" ] && break
            sleep 2
          done

      - name: Post-cutover smoke
        run: |
          curl -fsS https://app.example.com/healthz
          curl -fsS https://app.example.com/api/v1/version | jq -e ".color == \"${{ inputs.target_color }}\""

Rollback is the same hook with the other color as input. Cutover and rollback both complete in under two minutes including health gates.

Mechanism 2 — DNS swap (acceptable when LB swap isn’t available). If the PaaS doesn’t expose a single-hostname LB layer, you control the cutover at the DNS provider. The math you need to do honestly:

Effective rollback window = TTL_published + resolver_min_TTL + client_in_process_cache

# Realistic floor on the public internet, even with TTL=60:
#   ~5 min for the majority of resolvers
#   ~30 min for the long tail (corporate DNS, ISP recursors with min TTLs)
#   ~hours for hardcoded /etc/hosts or restarting-only-on-deploy clients

# Pre-deploy TTL reduction (run 24h before cutover):
#   The record's *old* TTL is what governs how fast the *new* TTL takes effect.
#   If your steady-state TTL is 3600 and you want a 60s cutover, lower it to 60
#   at least 3600s (one full TTL) before the deploy.

Pre-deploy DNS prep (24 hours before cutover):

# Drop apex TTL to 60s. Wait one full old-TTL window before cutting over.
curl -sS -X PUT \
  -H "Authorization: sso-key ${DNS_KEY}:${DNS_SECRET}" \
  -d '[{"data":"203.0.113.10","ttl":60}]' \
  "https://api.dnsprovider.example.com/v1/domains/example.com/records/A/app"

Cutover script:

#!/usr/bin/env bash
set -euo pipefail

GREEN_IP="203.0.113.20"
BLUE_IP="203.0.113.10"
DOMAIN="app.example.com"

# 1. Health-gate green
curl -fsS "https://green.internal.${DOMAIN}/healthz"

# 2. Update DNS to green
curl -fsS -X PUT \
  -H "Authorization: sso-key ${DNS_KEY}:${DNS_SECRET}" \
  -d "[{\"data\":\"${GREEN_IP}\",\"ttl\":60}]" \
  "https://api.dnsprovider.example.com/v1/domains/example.com/records/A/app"

# 3. Watch propagation honestly — don't claim success until majority resolvers agree
echo "Waiting for propagation across public resolvers..."
TARGETS=("1.1.1.1" "8.8.8.8" "9.9.9.9" "208.67.222.222" "4.2.2.2")
for i in $(seq 1 30); do
  HITS=0
  for r in "${TARGETS[@]}"; do
    [ "$(dig +short @$r ${DOMAIN})" = "${GREEN_IP}" ] && HITS=$((HITS+1))
  done
  echo "Propagation: ${HITS}/${#TARGETS[@]} resolvers on green"
  [ "$HITS" = "${#TARGETS[@]}" ] && break
  sleep 30
done

# 4. KEEP BLUE WARM. Do not tear it down until the long-tail traffic decays.
#    Recommended hold: 24h minimum for any non-trivial TTL history.
echo "Cutover complete on majority resolvers. Blue stays warm for 24h."

Tune health checks so they don’t lie. A passing /healthz that doesn’t touch the database is a check that promotes broken builds. The check should exercise the dependency chain — a single read query against the primary, a single PING against the cache, a confirmation that the queue consumer registered. Set the PaaS LB health-check parameters honestly:

# healthcheck-tuning.yaml
healthcheck:
  path: /healthz/deep
  port: 8080
  interval_seconds: 5            # poll cadence
  timeout_seconds: 3             # fail if no response in 3s
  healthy_threshold: 2           # 2 consecutive passes to mark UP
  unhealthy_threshold: 3         # 3 consecutive failures to mark DOWN
  initial_delay_seconds: 15      # let the app finish boot before any check
  drain_seconds: 60              # honour in-flight requests on the old pool

  # Deep check that actually proves serviceability
  payload_assertions:
    - field: ".db.read"
      equals: "ok"
    - field: ".cache.ping"
      equals: "pong"
    - field: ".queue.consumer_registered"
      equals: true

Pick LB target swap when the PaaS exposes it. The cutover is observable, atomic, and reversible in under two minutes — DNS swap can’t match that under adversarial caching conditions.

Stack Harbor runs the LB layer, health-check tuning, and cutover hooks for customers on our managed Cloud PaaS — see how we wire that into a release pipeline on the deployment management page.