Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions pages/features/autoscale.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,71 @@ You can use the `watch` tool to see if you catch the instance changing state fro
watch --color -n 0.5 kraft cloud instance list
```

## Policy types

Four autoscale policy types are available.
A service can have more than one policy active at the same time.

### Step policy

The step policy scales instances based on metric thresholds.
You define up to **4 steps**, each specifying a lower bound, upper bound, and the scaling change to apply when the metric falls in that range.

Order steps by lower bound with no gaps between them and no overlaps.

```bash title=""
kraft cloud scale add <service-name> \
--name my-step-policy \
--type step \
--metric cpu \
--adjustment-type change \
--step 600:800/2 \
--step 800:/4
```

### On-demand policy

The on-demand policy creates a new instance as soon as a request arrives with no available instances to handle it.
This minimises latency at the cost of cold starts.

### Create policy

The create policy pre-warms instances ahead of demand, keeping a pool of ready instances available.
Use it for workloads where cold-start latency can't occur.

### Idle policy

The idle policy scales in (removes instances) when the service has been idle—receiving no requests—for a configurable period.

## Metrics

The following metrics can drive a step policy:

| Metric | Description |
|--------|-------------|
| `cpu` | CPU utilization in millicores |
| `inflight_reqs` | Number of requests the platform is processing across all instances |
| `reqs_per_sec` | Request throughput in requests per second |

## Scale change types

Step policies support three scaling change types:

| Type | Description |
|------|-------------|
| `change` | Change the instance count by the specified value (positive to scale out, negative to scale in) |
| `exact` | Set the instance count to exactly the specified value |
| `percent` | Change the instance count by the specified percentage of the current count |

## Step policy constraints

- Maximum **4 steps** per step policy
- **Sort** steps by lower bound, ascending
- **Contiguous**: no gap between the upper bound of one step and the lower bound of the next
- Steps must not **overlap**
- Each step must have `lower_bound < upper_bound`
- A step can't span the entire range (`lower_bound = -∞` and `upper_bound = +∞` simultaneously)

## Learn more

* The `kraft cloud` [command-line tool reference](/cli/), and in particular the [scale](/cli/scale) subcommand.
Expand Down
Loading