How to Use Droplet Autoscale Pools for Automatic Horizontal Scaling

DigitalOcean Droplets are Linux-based virtual machines (VMs) that run on top of virtualized hardware. Each Droplet you create is a new server you can use, either standalone or as part of a larger, cloud-based infrastructure.


Droplet autoscale pools enable automatic horizontal scaling for a pool of Droplets based on resource utilization or a fixed size.

For more information on how autoscaling works in autoscale pools, see our concepts article:

Conceptual and technical details on Droplet autoscale pools, like what happens during scaling events, how the size of the pool is calculated, and when to scale.

Create an Autoscale Pool using the Control Panel

From the DigitalOcean Control Panel, in the left menu, click Droplets, which has both a Droplets tab and an Autoscale Pools tab.

The autoscale pools tab in the control panel with one autoscale pool listed.

Click the Create an Autoscale Pool button to go to the autoscale pool creation page.

Autoscale Pool Configuration

In the Autoscale Pool Configuration section, you choose the configuration of the pool, which determines how the pool scales.

  • Autoscale dynamically manages the number of Droplets in the pool based on their aggregate resource utilization. You choose:

    • Pool Size, which controls the minimum and maximum number of Droplets in the pool.

    • Target Utilization, which control which metrics (CPU, memory, or both) to monitor and at what thresholds to scale.

    • Cooldown Duration, which is the minimum amount of time the autoscale pool waits between making modifications to the Droplets in the pool. Choose a cooldown duration at least as long as it takes your Droplets to boot.

  • Fixed Size maintains a fixed number of Droplets in the pool. You choose:

    • Number of Droplets. The quantity of Droplets you want in the pool.

Autoscale Pool Droplets Configuration

In the Autoscale Pool Droplets Configuration section, choose the configuration for Droplets within the autoscale pool:

  • Datacenter region

  • VPC network

  • Image, which can be a base OS image, a snapshot or backup, or a custom image

  • Droplet plan

  • SSH keys, which are mandatory

  • IPv6

  • Startup scripts, which is user data

Make sure that Droplets in the pool automatically run your application on boot to make the application available on Droplets that the autoscale pool provisions. For example, you can configure unit files in a custom image or specify user data.

Finalize

In the Finalize section, you choose following options:

  • A unique autoscale pool name

  • A project for the autoscale pool

  • Optionally, tags for the Droplets in the pool

We strongly recommend tagging the Droplets in your autoscale pool. This lets you use DigitalOcean Load Balancers to forward traffic to the entire pool and apply cloud firewall rules to the pool automatically.

When you finish selecting your configuration, click Create Autoscale Pool.

Edit or Destroy an Autoscale Pool

To view or edit an autoscale pool from the DigitalOcean Control Panel, in the left menu, click Droplets.

Click the Autoscale Pools tab to go to the autoscale pools page which lists your team’s autoscale pools with an overview of their status. Click an autoscale pool to go to its detail page:

The resources tab of an autoscale pool.

The tabs on this page (Resources, Insights, Activity, and Settings) have different information about the pool. Click the Settings tab to edit or modify the pool.

The settings tab of an autoscale pool.

To edit the pool, click Edit next to the setting you want to change. You can change the Droplet configuration for the pool, switch between autoscale and fixed size, and modify the pool configuration.

To permanently destroy the pool and all Droplets in the pool, in the Destroy Autoscale Pool section, click Destroy. In the window that opens, optionally check Destroy Droplets in the pool to destroy the Droplets in the pool, or leave it unchecked to keep the Droplets after the pool is destroyed. Enter the name of the autoscale pool in the confirmation box, then click Delete.

Manage Autoscale Pools with Automation

Using the API

How to Create a New Autoscale Pool Using the DigitalOcean API
  1. Create a personal access token and save it for use with the API.

  2. Send a POST request to https://api.digitalocean.com/v2/droplets/autoscale

    cURL

    Using cURL:

                    curl -X POST \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
      -d '{
        "name": "test-autoscalergroup",
        "config": {
          "min_instances": 1,
          "max_instances": 5,
          "target_cpu_utilization": 0.5,
          "cooldown_minutes": 5
        },
        "droplet_template": {
          "size": "c-2",
          "region": "tor1",
          "image": "ubuntu-20-04-x64",
          "tags": [
            "test-ag-01"
          ],
          "ssh_keys": [
            "392594",
            "385255"
          ],
          "vpc_uuid": "c472520a-831e-4770-8135-542c57a69daa",
          "ipv6": true,
          "user_data": "\n#cloud-config\nruncmd:\n- apt-get update\n"
        }
      }' \
      "https://api.digitalocean.com/v2/droplets/autoscale"
                  
How to Update Autoscale Pool Using the DigitalOcean API
  1. Create a personal access token and save it for use with the API.

  2. Send a PUT request to https://api.digitalocean.com/v2/droplets/autoscale/{autoscale_pool_id}

    cURL

    Using cURL:

                    curl -X PUT \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
      -d '{
        "name": "test-autoscalergroup-01",
        "config": {
          "min_instances": 1,
          "max_instances": 5,
          "target_cpu_utilization": 0.5,
          "cooldown_minutes": 10
        },
        "droplet_template": {
          "size": "c-2",
          "region": "tor1",
          "image": "ubuntu-20-04-x64",
          "tags": [
            "test-ag-01"
          ],
          "ssh_keys": [
            "372862",
            "367582",
            "355790"
          ],
          "vpc_uuid": "4637280e-3842-4661-a628-a6f0392959d3",
          "with_droplet_agent": true,
          "ipv6": true,
          "user_data": "\n#cloud-config\nruncmd:\n- apt-get update\n"
        }
      }' \
      "https://api.digitalocean.com/v2/droplets/autoscale/d0067f19-c9bd-4d8c-b28b-e464fd1fb250"
                  
How to Delete Autoscale Pool Using the DigitalOcean API
  1. Create a personal access token and save it for use with the API.

  2. Send a DELETE request to https://api.digitalocean.com/v2/droplets/autoscale/{autoscale_pool_id}

    cURL

    Using cURL:

                    curl -X DELETE \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
      "https://api.digitalocean.com/v2/droplets/autoscale/880fee37-d07a-4f94-94a0-f07d9fc7bbb4"
                  

Using Terraform

Provides a DigitalOcean Droplet Autoscale resource. This can be used to create, modify, read and delete Droplet Autoscale pools.
Get information on a Droplet Autoscale pool for use with other managed resources. This datasource provides all the Droplet Autoscale pool properties as configured on the DigitalOcean account. This is useful if the Droplet Autoscale pool in question is not managed by Terraform, or any of the relevant data would need to referenced in other managed resources.
In this article...