Skip to main content
A web service that scales to zero runs no replicas at all while it gets no requests, and starts one when a request arrives. For staging environments, internal tools and anything used in bursts, that’s most of the day at no compute cost.

Turn it on

1

Install Knative

Scale to zero runs on Knative. An Admin installs it once per infrastructure from the App Store.
2

Set the service's scaling

In inframan.yaml, use the concurrency scaling type with a minimum of zero:
inframan.yaml
3

Deploy

Push the change. Once the service has had no requests for a while, its replicas stop.
min_replicas defaults to 1, so a service only scales to zero when you ask for it.

What a cold start looks like

While a service is at zero, Knative’s activator holds an incoming request, starts a replica, and passes the request on once the replica is ready. Nothing is dropped, but that first request waits for your container to start. Keep cold starts short with a small image and a fast start-up. The Cold Start Latency chart in Metrics shows how long requests waited, at the 50th, 95th and 99th percentiles.

Where it applies

  • Web services on non-production infrastructures. Production infrastructures keep at least one replica of every Knative service, so production traffic never waits for a cold start.
  • Not workers. A worker with min_replicas: 0 runs one replica.
  • Not hpa services. A Deployment always keeps at least one replica.

Scale to zero, then shrink the nodes

When services stop, their nodes empty. Application pools whose minimum is zero, the default on Google Cloud, then give the empty nodes back. See Autoscaling.