# Autoscaling

Source: https://docs.sliplane.io/servers/autoscaling

Let Sliplane grow a server or PostgreSQL database automatically when CPU, memory or disk usage stays high.

Autoscaling grows a server or a [PostgreSQL database](/databases/overview) to a larger size when its usage stays above a threshold you set. It never goes past the maximum size you choose. Once it has resized, you can't go back to a plan with less memory, and the disk can't be made smaller. You can set it up in the dashboard or through the [API](https://ctrl.sliplane.io/#description/introduction).

## How it works

A policy has up to three rules: CPU, memory and disk. Each enabled rule has a threshold and a duration. When the one-minute average stays above the threshold for every minute of the duration, Sliplane increases the size:

- **CPU or memory:** the server or database moves to the next compute size in the same CPU family, up to the maximum size you picked.
- **Disk:** the disk grows to the next disk size, up to the maximum disk size you picked.

Automatic increases are at least 15 minutes apart and keep the current billing cycle. You pay for the larger size from the moment it grows. Each increase is logged as an event on the server or database. Missing metrics never trigger an increase.

Thresholds accept 10–95 percent and durations accept 1–60 minutes. Autoscaling is off by default.

> A compute increase on a PostgreSQL database restarts PostgreSQL. Open connections are dropped for a short time, so make sure your application reconnects automatically.

## Set up in the dashboard

You can turn on autoscaling when you create a server or database, or later on its **Upgrade** page:

1. Open your server from the [servers overview](https://sliplane.io/app/servers), or your database from the [databases overview](https://sliplane.io/app/databases), and select **Upgrade**.
2. In the **Autoscaling** card, switch on **CPU & memory**, **Disk**, or both.
3. Set the usage threshold in percent and the duration in minutes for each rule.
4. Under **Up to**, pick the largest compute size or disk size autoscaling may grow to. The price of each size is shown next to it.
5. Click **Save autoscaling**. If you also changed the size on the page, the button reads **Save changes** and saves both.

The billing summary shows the most the server or database can cost with autoscaling.

To turn autoscaling off, switch off both sections and save.

### Status

Once autoscaling is on, the card shows its status and when the last resize happened:

| Status       | Meaning                                                |
| ------------ | ------------------------------------------------------ |
| **Active**   | Autoscaling watches the usage and resizes when needed. |
| **Resizing** | An automatic increase is running.                      |
| **Paused**   | The last resize failed. The card shows the error.      |

To resume a paused policy, save it again.

## Set up with the API

You can also manage autoscaling through the Sliplane API with an [API key](/teams/api-keys). See the [API reference](https://ctrl.sliplane.io/#description/introduction) for the `autoscaling` policy on servers and PostgreSQL databases.

## Limits

- The maximum compute size must be in the current CPU family and larger than the current size.
- The maximum disk size must be larger than the current disk.
- Without a disk rule, a compute increase can still bring the larger disk bundled with the new size.
- Demo servers and databases can't autoscale. Some older servers can't resize in place, so autoscaling isn't available for them.
- A database can autoscale once it is running.
- Your team [quotas](/teams/quotas) still apply. An increase that exceeds a quota fails and pauses autoscaling.
