> ## Documentation Index
> Fetch the complete documentation index at: https://inframan.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Scale to zero

> Let a web service stop entirely when nobody is using it, and start again on the next request.

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](https://inframan.mintlify.site/provision/add-ons/knative.md). 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:

```yaml inframan.yaml theme={null}
services:
  web:
    port: 3000
    scaling:
      type: concurrency
      min_replicas: 0
      max_replicas: 5
      target: 100
```

**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](https://inframan.mintlify.site/monitor/metrics.md) 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](https://inframan.mintlify.site/optimize/autoscaling.md#nodes).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.