Skip to content

Deploying While Scans Are Running

Run the Deploying While Scans Are Running MicroSim Fullscreen

Deploying While Scans Are Running screenshot

About This MicroSim

Eight scans run on a timeline from 0 to 180 seconds. At 60 seconds a deploy happens. The new version is already healthy, so new scans go to it, and the old version gets SIGTERM. Five scans are still running inside the old version at that moment.

What happens to those five depends on the strategy. A hard stop ends them at once. Graceful shutdown lets each one finish if it ends before the force-stop. A job queue puts any scan still running at the force-stop back on the queue, and it restarts on the new version. It finishes late, but it finishes.

The problem comes from the running example, where a deploy killed scans in flight. All scan times are illustrative.

How to Use

  1. Read the question. The strategy and the 30-second wait are set for you.
  2. Type how many scans are lost and press Check. You get two tries. When the question is done, the timeline plays: an X marks each scan cut off, and a restarted scan appears again in orange on the new version.
  3. Hover over any scan bar to see when it starts, how long it takes, and what happened to it. Hover over the deploy line or the force-stop line to see what happens there.
  4. Question 4 asks for the smallest wait, in seconds, at which graceful shutdown alone loses no scans.
  5. After question 4, press Explore freely. Change the strategy and the shutdown wait, and watch Lost and Delayed change.

Four of four correct shows mastery. Notice that a longer wait helps graceful shutdown only until it covers the longest scan, while the job queue loses nothing at every wait.

Iframe Embed Code

You can add this MicroSim to any web page by adding this to your HTML:

<iframe src="https://arunbatchu.github.io/good-enough-engineering/sims/deploy-during-scans/main.html"
        height="584px"
        width="100%"
        scrolling="no"></iframe>

Lesson Plan

Learning Objective

The learner will calculate how many of eight scans are lost and how many are delayed when a deploy happens at 60 seconds, under a hard stop, a graceful shutdown and a job queue, for a given shutdown wait.

Grade Level

Adult professional (Good Enough Engineering)

Duration

10-15 minutes

Prerequisites

  • Deploy
  • In-flight work at deploy
  • Graceful shutdown
  • SIGTERM
  • Job queue

Activities

  1. Prediction (6 min): Answer the four questions before each run plays. For each scan, decide whether it is still running at 60 seconds and when it would end.
  2. Exploration (4 min): In free exploration, set the wait to 0 and then to 120 under each strategy. Record lost and delayed counts.
  3. Discussion (4 min): Your platform waits 30 seconds and a scan can run for 90. Which fix do you need, and what does a member see while it runs?

Assessment

  • All four answers correct (5, 2, 0 and 60).
  • The learner can explain why graceful shutdown at a 0-second wait loses the same scans as a hard stop.
  • The learner can explain why a job-queue scan counts as delayed, not lost.

References

  1. Railway docs: Deployment teardown - how Railway stops an old deploy and how long it waits.
  2. Express docs: Health checks and graceful shutdown - handling SIGTERM in an Express server.
  3. p5.js reference - the library used to draw this timeline.