Automatic scaling
Let a server grow to the next larger size by itself when its CPU stays busy, with a limit, a cooldown and optional hours. In the console, the API and Terraform.
A server with automatic scaling grows by itself: when its average CPU load stays above your limit for a while, HF Cloud shuts it down, moves it to the next larger size and starts it again. You choose the largest size it may reach, so the cost has a ceiling.
Read this before you turn it on
Every step restarts the server. It is offline for about 30–60 seconds (a graceful shutdown, the new size, a start). Open connections drop, and your services must start by themselves at boot.
It only grows, never shrinks. The larger size is billed from the moment it applies, exactly as if you had changed the size yourself, until you make the server smaller yourself (Settings → Change size).
The boot disk can grow for good. When the new size has a larger disk than the boot disk, the boot disk grows with it. Disks cannot shrink, so the larger disk stays, and is billed, even after you reduce vCPU and memory again. The card shows how far the boot disk can grow with the largest size you choose.
The guest must shut down on request. It needs
acpidorqemu-guest-agent. If it does not stop within 3 minutes, it is left running on its current size (never switched off hard); a very slow guest may still power off later, so check the server after such an e-mail.
- CPU only: memory use does not trigger it (the host's view of a guest's memory includes its file cache, so it would look full most of the time).
- Hours are in the time zone of the person who saved the rule (or the
timezonegiven through the API).
In the console you confirm these points when you turn it on or choose a new largest size. Through the API and Terraform there is nothing to tick, so the organization's owners and members get them by e-mail whenever the rule is turned on or gets a new largest size, whichever way it was set (at most one such e-mail per server every 10 minutes).
Set it up
On the server page open Settings → Automatic scaling:
| Setting | Allowed | Default | Meaning |
|---|---|---|---|
| CPU above | 50–95 % | 80 % | average over all vCPUs |
| For | 5–60 minutes | 15 | how long the average must stay above the limit |
| Largest size | a larger size | — | it never grows beyond this one; the price per month is shown |
| Pause between scale-ups | 30–1440 minutes | 60 | gives the load time to settle after a step |
| Only during these hours | optional | always | e.g. 22:00–06:00 (may wrap midnight), in your time zone |
Owners and members can change the rule; viewers see it.
Next larger size is the smallest offered size with more vCPU and at least as much memory, up to your largest size. A boot disk that is smaller than the new size's disk grows with it (disks never shrink).
When it does not scale
Each check is shown on the card as the last result, and you get one e-mail per reason (again only after the load dropped and rose again):
- snapshots exist (delete them first, as for a manual resize),
- a backup is running, the server is busy with another operation, or it is isolated after an abuse report,
- quota: the organization's vCPU, memory or disk limit would be exceeded,
- payment: no billing details, payment method or credit,
- outside the allowed hours (it waits for the window), or within the pause after the last step (no e-mail),
- the server already has the largest allowed size.
If the guest does not shut down within 3 minutes (it does not react to the ACPI shutdown; check that acpid or
qemu-guest-agent runs), the server is left running on its current size: it is never switched off hard. If the
new size cannot be applied, the server is started again on its old size. Either way you get an e-mail.
API
curl -X PUT https://hfcloud.eu/api/cloud/v1/servers/$SERVER/autoscale -H "Authorization: Bearer $HFCLOUD_TOKEN" \
-H "Content-Type: application/json" \
-d '{"cpu_threshold": 85, "minutes": 10, "max_size": 4, "cooldown_minutes": 60, "window_start": 22, "window_end": 6}'
GET /servers/{id}/autoscale: the rule, or"data": null. It also showsstate(idle,scaling),last_scaled_at,last_result(succeeded,skipped,failed),last_reasonandlast_cpu.PUT /servers/{id}/autoscale: create or replace the rule (max_sizeis required; fields you leave out get the defaults above). A read-write token of an owner or member.DELETE /servers/{id}/autoscale: remove it.
Turning it on (or a new max_size) through the API e-mails the warnings above
to the organization's owners and members: read them before you automate it.
Each scale-up sends the webhook event server.autoscaled with data.autoscale.from, to and
cpu_average, and appears in the server's activity as vm.autoscale (done by the system, not a person).
Terraform
resource "hfcloud_server" "app" {
name = "app-1"
image = "ubuntu-24.04"
size = 2
autoscale {
max_size = 4
cpu_threshold = 85
minutes = 10
}
}
While an autoscale block is set, a size that grew by itself is not treated as drift: Terraform does not shrink the
server back. See Terraform.