We hope you find this tutorial helpful. In addition to guides like this one, we provide simple cloud infrastructure for developers. Learn more →

How To Resize Your Droplets on DigitalOcean

UpdatedJanuary 16, 2018 134.9k views DigitalOcean Scaling Product Documentation

Introduction

Resizing a server, also known as vertical scaling, increases your server's capacity by allowing it more memory (RAM), CPU, and disk storage. This is useful in a variety of situations, such as when your concurrent user base increases or you need to store more data.

There are two resizing options for Droplets: CPU and RAM only, and Disk, CPU, and RAM.

Type of Resize Reversible Increases CPU Increases RAM Increases Disk Storage Estimated Downtime (Approximate)
CPU and RAM only Yes Yes Yes No 1 minute per GB of storage in use
Disk, CPU and RAM No Yes Yes Yes 1 minute per GB of storage in use

CPU and RAM only resizes can be reversed if you want to return to using a smaller Droplet. Disk, CPU, and RAM resizes cannot be reversed because decreasing the size of the disk poses data integrity issues.

This tutorial will help you choose between the two Droplet resizing options and show you how to perform both types of resize via the Control Panel and the DigitalOcean API.

Choosing a Resize Type: Disk or No Disk

The CPU and RAM only resize option adjusts the amount of CPU and RAM available to a Droplet, but does not affect its disk storage. Because the disk is not resized, this option can be used to scale the Droplet's RAM and CPU up and then back down as your resource requirements change.

The Disk, CPU, and RAM resize option permanently increases the size of a Droplet's SSD disk. Regardless of how much disk is actually in use, decreasing the disk size poses data integrity issues. Consequently, once the Droplet has been upgraded to the new disk size, you cannot return to a plan with less disk space.

Here are some general guidelines for Droplet resizing:

  • Choose a CPU and RAM only resize if you need more CPU and RAM and you want the ability to roll back to a less expensive Droplet size in the future.
  • If you need more of everything (CPU, RAM, and disk storage) and don't intend to roll back to a smaller Droplet in the future, use the Disk, CPU, and RAM resize.
  • For flexible control of all three resources, combine a CPU and RAM only resize with DigitalOcean Block Storage.

Estimated Downtime

When resizing, the downtime varies depending on how much space is in use. This is true even when resizing CPU and RAM only because a resize may move the Droplet to a new hypervisor, which will transfer disk data over the network. Allow one minute per GB of storage in use. You can check how much disk storage your filesystem is using with the df command. Here, we check the file system root (\) and display the output in human-readable terms (-h).

  • df / -h
Output
Filesystem Size Used Avail Use% Mounted on /dev/vda1 20G 15G 4.4G 78% /

The output shows that this 20 GB Droplet is using 15 GB of space, so a disk resize can take up to 15 minutes, although the actual time required is typically shorter.

Droplets must be powered down in order to perform either kind of resize. You will need to power down your Droplet manually if you resize using the Control Panel. If you resize using the API, the Droplet will be automatically powered off as part of the resize API request.

Resizing via the Control Panel

From the DigitalOcean Control Panel on the Droplets page, click on the name of the Droplet you want to resize.

Next, click the Resize option on the left navigation section:

Resize page

The current Droplet size will be highlighted. Choose CPU and RAM only or Disk, CPU, and RAM resizing, then select the new Droplet size.

Note that you won't be able to use the Resize button unless the server is shut off. If you use the On/Off switch to power down, you'll encounter the following reminder:

Turn off Droplet warning - You should power off from the command line, not from the UI.

To power down from the command line, connect to the Droplet with SSH and issue the shutdown command:

  • sudo shutdown -h now

Whether you use the Turn off button or the shutdown command, once the server is shut down, you can select Resize, and a progress bar will display as the resize takes place.

Screenshot of the Progress Bar

When the resize event is finished, the Droplet needs to be powered back on. Click the On/Off button to start it:

Power On

The new size will be visible below the Droplet name. Once the Droplet is booted, you can begin verifying that the your services are working as expected.

Resizing via the DigitalOcean API

If you prefer to resize your Droplets via the DigitalOcean API, you will need:

  • The ID of the Droplet you want to resize.

    The ID is shown in a Droplet's Control Panel URL when you've clicked its name (e.g. https://cloud.digitalocean.com/droplets/12345678/...), or you can use the API to look it up.

  • A DigitalOcean API token with read and write access.

    If you don't have one, you can create a new API token. by visiting the Control Panel's API page and using the Generate New Token button in the Personal access token section.

Once you have the Droplet ID, you will use it with the Droplet actions API endpoint.

For example, the curl command below performs a CPU and RAM only resize to a 4GB Droplet, including automatically powering down the Droplet. Substitute your own API token, Droplet ID, and desired size below.

curl -X POST -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer EXAMPLE947b217efb6f3ec3bdEXAMPLE' \
     -d '{"type":"resize","size":"4gb"}' \
    "https://api.digitalocean.com/v2/droplets/droplet_id/actions"

If you want to perform a Disk, CPU, and RAM resize with the same options as the previous example, set the disk attribute to true. Make sure the target size has more disk than your original Droplet.

curl -X POST -H 'Content-Type: application/json' \ 
    -H 'Authorization: Bearer EXAMPLE947b217efb6f3ec3bdEXAMPLE' \ 
    -d '{"type":"resize","size": 4gb","disk":true}'  \
    "https://api.digitalocean.com/v2/droplets/droplet_id/actions"

Then, for either kind of resize, power on the Droplet when it's is complete.

curl -X POST -H 'Content-Type: application/json' 
    -H 'Authorization: Bearer EXAMPLE947b217efb6f3ec3bdEXAMPLE' \
    -d '{"type":"power_on"}' \
    "https://api.digitalocean.com/v2/droplets/droplet_id/actions"

More details are available in the DigitalOcean API documentation on resizing.

Conclusion

In this tutorial, we covered the difference between a reversible CPU and RAM only resize and the permanent Disk, CPU and RAM resize, then demonstrated how to perform both with the Control Panel and the API.

Any time you resize a Droplet, be sure to test that all your services are running as expected. If you want flexible resizing but also need more disk storage, you can look into combining a CPU and RAM only resize with DigitalOcean Block Storage.

79 Comments

Creative Commons License