Readiness probes and the shutdown delay apply to scaling groups and functions. A function takes readiness_probe and shutdown_delay_seconds and passes them to the scaling group it runs on. Startup probes apply to scaling groups only.


​
Health checks

Two probes control when Chalk treats a replica or a group as ready:

  • Readiness probe (readiness_probe): checks each replica directly, on a repeating schedule. A replica receives traffic only while its readiness probe passes.
  • Startup probe (startup_probe): checks the group’s web_url once per deploy. deploy() waits until the probe passes, and the group reports the Unhealthy status if it does not.
import chalkcompute

img = chalkcompute.Image.debian_slim("3.12").entrypoint(
    ["python", "-m", "http.server", "8080"]
)

sg = chalkcompute.ScalingGroup(
    image=img,
    name="hello-api",
    port=8080,
    readiness_probe=chalkcompute.ReadinessProbe.http(
        "/",
        period_seconds=10,
        timeout_seconds=2,
        failure_threshold=3,
    ),
    startup_probe=chalkcompute.StartupProbe.http("/"),
).deploy()

ReadinessProbe.http(path) sends an HTTP GET to path on each replica. ReadinessProbe.grpc(service) calls the standard gRPC health check. Both take optional period_seconds, timeout_seconds, and failure_threshold.

StartupProbe.http(path) sends an HTTP GET to path on the group’s web_url and passes on a 2xx or 3xx response. Without a path, it requests /. StartupProbe.grpc(method) calls method through the group’s route and passes when the call returns OK. The method must be fully qualified. Without a method, the probe passes once the route answers gRPC.

A startup probe requires a port. An HTTP startup probe requires an HTTP group, and a gRPC startup probe requires protocol="grpc".

From the CLI, --startup-probe adds a startup probe that requests / on the group’s web_url. The CLI has no flag for readiness probes.


​
Shutdown delay

shutdown_delay_seconds sets the grace period, in seconds, before replicas are forcibly killed during scale-down. It lets in-flight requests finish cleanly. It defaults to 30 seconds on the server.

import chalkcompute

@chalkcompute.function(shutdown_delay_seconds=120)
def infer(text: str) -> str:
    return text.upper()

On a scaling group, pass the same argument to ScalingGroup.