Chapter D · 4 of 4~10 min

Health check lab

**Liveness vs readiness** — keep load balancers from sending traffic to broken AI backends.

Reviewed July 2026 · interactive lab

Paths & resources for this lesson

1Try it yourself

Playground

Health check lab

Liveness = restart me. Readiness = don't send users yet.

Process up but event loop stuck

2Read & reflect

Recap

#What you just did

You classified stuck processes vs missing dependencies as liveness or readiness failures.

Teach

#Pattern

@app.get("/health/live")
def liveness():
    return {"ok": True}  # process responsive

@app.get("/health/ready")
def readiness():
    if not vector_db.ping():
        raise HTTPException(503)
    return {"ok": True}

Readiness should check dependencies your request path needs — not every microservice in the company.

Use it

#When you'd use this

  • Kubernetes / Cloud Run AI APIs
  • Blue-green deploys with traffic drain
  • Autoscaling on queue depth + readiness

Watch out

#Watch out

Heavy checks on /ready every second can DDOS your own database — cache briefly or use synthetic checks.

Try next

#Try this next

List three dependencies your capstone must pass before accepting chat traffic.

3Spark check

Continue learning · glossary & guides