AI Hints
Home›CI/CD with GitHub Actions Tutorial›Deployment Strategies
CI/CD with GitHub Actions · Lesson 89 of 138

Rolling Deploys

A few at a time.

⏱ 2 min read▶ Video at 1:42:48🎓 Free
Watch this lesson in the CI/CD with GitHub Actions courseWatch on YouTube ↗Full CI/CD with GitHub Actions course

A rolling deploy updates servers one by one, or a few at a time. The others keep serving users. Each new server must pass a health check, before the rollout moves on.

Rolling Deploys
From the video: Rolling Deploys
  • One server at a time
  • Others keep serving
  • Health check each one

A small simulation

Here's a script that simulates a rollout across four servers. Cat shows the loop. Each server gets the new version, and a health check. When all is well, all four end up on version two.

Terminal
cat roll.sh
for s in web1 web2 web3 web4; do
  if [ "$s" = "$BAD" ]; then
    echo "$s: health check FAILED, stopping"; exit 1
  fi
  echo "$s: updated to v2, healthy"
done
echo "All servers on v2"
bash roll.sh
web1: updated to v2, healthy
web2: updated to v2, healthy
web3: updated to v2, healthy
web4: updated to v2, healthy
All servers on v2

A failed health check

Now we pretend web three is broken. The rollout updates web one and web two, then stops at web three, with exit code one. Web four still runs the old version, so most users are fine, and the bug doesn't spread.

Terminal
BAD=web3 bash roll.sh; echo "exit code $?"
web1: updated to v2, healthy
web2: updated to v2, healthy
web3: health check FAILED, stopping
exit code 1

Rolling settings

Real tools let you tune the rollout. Max unavailable says how many servers can be down at once. Max surge allows extra servers during the update. And the readiness check decides when a new server can take traffic.

keyvalue
maxUnavailablehow many down at once
maxSurgeextra during rollout
Readiness checkready for traffic?
Stop on failuredon't spread a bug

Summary

Rolling deploys update a few servers at a time, and stop when a health check fails. Next, blue green and canary releases.

Key takeaways
  • One by one
  • Health checks
  • Stop on failure
Next up: Blue-Green and Canary — switch or test with a few