LEARN. PRACTICE. EXPLAIN.
Learning paths & interview practiceP
← Build a health-probe & rollout controller
BUILD → VERIFY → EXPLAIN · STEP 3 OF 6

Coordinate graceful request draining

Finish in-flight requests within a bounded termination grace window.

UNDERSTAND

Bring these concepts with you

BUILD

Your implementation

  1. Implement createDrainController({ graceMs, now }) tracking active request IDs.
  2. Reject new enterRequest calls once beginDrain() has started.
  3. Report canExit = true once active requests hit zero OR the injected clock reaches the grace deadline.
export function createDrainController({ graceMs = 5000, now = Date.now } = {}) {
  // Track active requests and enforce shutdown drain deadline.
}
Need a hint?
  • Compute deadline = now() + graceMs on the first beginDrain() call.
  • Distinguish timedOut (deadline reached with requests still active) from clean drain.

Saved on this device · 0 / 6000 · Do not include passwords or private data.

VERIFY

Acceptance checks

From the folder containing your downloaded files, run:

node checks.mjs ./starter.mjs 3

This runs checks up to this step. Earlier steps must work first. Mark each result only after checking your implementation; the website does not run or grade it.

Record your attempt to enable the checklist and reference comparison.

Compare with the reference

Attempt the step first, then compare decisions and behavior. There can be more than one correct implementation.

EXPLAIN

Your interviewer asks

During a rolling deploy, why can new connections still arrive briefly after a pod starts shutting down?

Say your answer aloud, then record the trade-offs and evidence in your notes above.

LOCAL VOICE REHEARSAL

Rehearse your step walkthrough aloud

Target pacing: 02:00 · Stays in this browser only; never uploaded.

00:00/ 02:00
AlifBay Prep