Ployter

Autoscaling

How the panel scales a service's replicas up and down by CPU and requests, using servers from a pool or creating servers on AWS or DigitalOcean.

Autoscaling increases and decreases the number of replicas of a service according to load. It starts from the replicas you already turned on and uses CPU and, if you want, each replica's requests per minute. A new replica starts on the version that's live and only receives traffic after the health check.

Since it depends on the load balancer, autoscaling exists on AWS and DigitalOcean, with the same rules. A service on a Hetzner, Vultr or Linode server or on your own server has no autoscaling.

Requirements

  • The plan must include Autoscaling (and Replicas and load balancer).
  • The service already runs with replicas: two or more AWS or DigitalOcean servers in Settings → Servers, with a deploy done.
  • The service has a port and a live version deployed after the current replicas. If not, run a deploy.
  • Servers created by autoscaling count toward the plan's Servers limit.

Turn on autoscaling

  1. Open the service and go to Settings.
  2. In the Autoscaling card, turn on the switch.
  3. Set the Minimum and Maximum number of replicas (from 2 to 10).
  4. Set the CPU target, per replica. CPU is measured relative to 1 vCPU: 100% is one full core.
  5. Optionally, set the Requests target, in requests per minute per replica. If blank, autoscaling decides by CPU only.
  6. In Servers that can receive a replica, check the servers that can receive new replicas. They must be from the same provider and on the same network as the replicas.
  7. If you want the panel to create servers when the pool runs out, turn on Create servers at the provider when the group runs out and pick the Machine type and Disk. On DigitalOcean, the type is a droplet size (e.g. s-2vcpu-4gb) and the disk comes with it: there's no Disk field.
  8. Click Save.

Autoscaling card with minimum, maximum, targets and pool servers
Autoscaling card with minimum, maximum, targets and pool servers

Note

Pool servers stay on, and billing, even without a replica. Servers created by autoscaling are deleted when load drops.

How it decides

The agent measures each replica every 10 seconds. The panel evaluates the average:

  • Scale up: when the average over the last 3 minutes goes above the target. At most 2 replicas are added at a time. After scaling up, it waits 3 minutes before scaling up again.
  • Scale down: one replica at a time, when the load, divided across the remaining replicas, stays below 75% of the target for 10 minutes. After scaling up, it waits 10 minutes before scaling down. Between two scale-downs, it waits 5 minutes.

With both targets set, whichever asks for more replicas wins. The number always stays between the minimum and the maximum.

Example, with the CPU target at 70%:

  • 3 replicas at a 90% average: above the target, the panel scales up.
  • 4 replicas at 35%: divided across 3, that would be about 47%, below 52.5% (75% of the target). The panel removes one.
  • 4 replicas at 40%: divided across 3, that would be about 53%. The panel keeps all 4.

If any replica is down or has no measurement, the panel doesn't scale down: the others may be carrying the load.

Where new replicas come from

  1. First, a free server from Servers that can receive a replica.
  2. If the pool ran out and Create servers at the provider when the group runs out is on, the panel creates a server in the same region and network (VPC) as the replicas, with the chosen type (and, on AWS, the disk). It takes 3 to 5 minutes until it receives traffic (creating the server, installing the agent and, for a GitHub service, building).

On AWS, ARM types (such as t4g and m7g) aren't accepted: the agent image is x86.

When scaling down, the replica leaves the load balancer and waits for open connections to finish. Then the service is removed from the server, and the server is deleted if autoscaling created it.

If creation fails 3 times in a row, the panel pauses server creation for 1 hour. A created server that doesn't come online within 12 minutes is deleted.

Monitor it

The Autoscaling card shows:

  • the current replicas, the Average CPU and the requests per replica, with each target;
  • when the last evaluation happened;
  • what's happening now (for example, Adjusting now or Creating server).

In the Metrics tab, the Events panel records each replica that was added or removed. See Logs, metrics and requests.

To get emails, turn them on in Notifications:

  • Autoscaling problem: couldn't scale up, a new server didn't come up, creation paused.
  • Autoscaling scaled up or down: each replica added or removed. That can be a lot of email on a peak day.

See Notifications and alerts.

Turn it off

Turn off the switch in the Autoscaling card and click Save. The current replicas stay. To pick servers by hand again, use Settings → Servers.