Spot instances on CloudFerro Cloud

Spot instances let you run jobs on spare cloud capacity at a lower price than regular instances. CloudFerro can terminate them when that capacity is needed, so use them for work that can save progress and resume or be repeated.

What We Are Going To Cover

  • When to use spot instances

  • Understanding spot flavor names

  • How to choose a spot flavor in your cloud

  • How to create spot instances

  • Additional configuration via tags

  • What is the expected behaviour

When to use spot instances

Use spot instances for work that can stop and resume on another VM. Typical examples include:

  • Processing independent files or images in batches.

  • Running automated builds and tests that can be repeated.

  • Adding temporary workers to a queue while keeping the queue and job records on regular instances.

For example, a worker can process one file, save its result to object storage and record that the file is complete. If the worker is deleted, a replacement can continue with unfinished files. Save results and checkpoints outside the spot VM while the job runs; do not wait for a termination notification.

Use regular instances for a primary database, the only copy of important data, or a service that must remain available. A long-running job also needs a way to save and restore progress before it is suitable for spot instances. Compare the price of the selected spot flavor with a suitable regular flavor, allowing for work that may need to be repeated after an interruption.

Understanding spot flavor names

A name such as spot.eo2a.medium combines the spot prefix, a hardware family and a size label. The parts used in the spot flavors listed below mean:

Part of the name

What it means

spot.

An interruptible VM using spare cloud capacity. It can be terminated when that capacity is needed for regular instances.

eo2 in eo2 and eo2a

The general-purpose CPU family, suitable for restartable scripts, batch processing and worker jobs.

hm in hma

The high-memory family, intended for jobs that need more RAM per vCPU. For spot instances, the job must still tolerate interruption.

a in eo2a and hma

The AMD processor variant: eo2a is the general-purpose AMD family, and hma is the high-memory AMD family.

medium, large, xlarge, 2xlarge, etc.

A size label within the selected family. It does not specify a fixed amount of RAM or a fixed vCPU count across families and clouds. For example, 2xlarge does not mean two vCPUs.

For example, spot.eo2a.medium selects an interruptible VM from the general-purpose AMD family, while spot.hma.medium selects one from the high-memory AMD family. Compare the actual resource values in the cloud tabs below before choosing between them.

RAM and disk sizes below are shown in GiB. RAM values from openstack flavor list are converted from MiB to GiB by dividing by 1024 and rounded to two decimal places where needed. Disk values are already in GiB.

Flavor

vCPUs

RAM (GiB)

Disk (GiB)

spot.eo2.medium

1

4

16

spot.eo2.large

2

8

32

spot.eo2.xlarge

4

16

64

spot.eo2.2xlarge

8

32

128

spot.eo2.3xlarge

16

64

256

spot.eo2.4xlarge

32

128

512

Prerequisites

No. 1 Account

You need a CloudFerro Cloud hosting account with access to the Horizon interface: https://horizon.cloudferro.com/auth/login/?next=/

No. 2 Select a cloud and project

Spot flavors are listed in all six clouds. In Horizon, select the project and cloud where you want to create the VM.

The screenshots below use WAW3-2 as an example. Select your chosen cloud in the same control:

../_images/waw3-2-cloud-activated.png

A flavor appearing in the list does not guarantee that there is spare capacity to create a spot VM at that moment.

No. 3 Using quotas and flavors

For quotas, see this article: Dashboard Overview – Project Quotas And Flavors Limits on CloudFerro Cloud

No. 4 OpenStack CLI client (optional)

If you want to interact with CloudFerro Cloud cloud using OpenStack CLI client, you need to have it installed. Check one of these articles:

Once you have installed this piece of software, you need to authenticate to start using it: How to activate OpenStack CLI access to CloudFerro Cloud cloud using one- or two-factor authentication

To test whether the openstack command is working, list flavors:

openstack flavor list

In the output, look for names beginning with spot..

No. 5 VM creation procedure

Use the guide for your preferred method to prepare the image, network, key pair and other VM settings:

How to create spot instances

Step 1. Check the flavor

Choose a flavor whose name begins with spot. in Horizon or OpenStack CLI.

Warning

Similar or identical flavor names can have different specifications in different clouds. A spot flavor can also differ from a similarly named regular flavor. Before creating the VM, verify its exact vCPU count, RAM and disk size in the selected cloud and project, using Horizon or openstack flavor show.

For CLI users, run this command in the terminal authenticated to the selected cloud and project:

openstack flavor show SPOT_FLAVOR_NAME

Replace SPOT_FLAVOR_NAME with a complete name from that cloud’s flavor list. For example, use spot.eo2.medium on WAW3-1, spot.hma.medium on WAW3-2, or spot.eo2a.medium on WAW4-1, FRA1-2, FRA1-3 and LCJ1-1. Check the displayed resource sizes. The properties field should contain cf:spot.instance set to True.

The following screenshot shows that property for a WAW3-2 flavor:

../_images/value_of_spot.png

Step 2. Create the instance

Follow the VM creation procedure from Prerequisite No. 5. In Horizon, choose the spot. flavor you checked in Step 1. The example below uses WAW3-2:

../_images/spot_flavors_when_creating.png

If you use OpenStack CLI, set –flavor to the same checked flavor name in your openstack server create command.

After creation, check that the instance has the flavor you selected:

../_images/spot_hma_created.png

Additional configuration via tags

This configuration is optional. Use it if your application or automation service has an HTTPS endpoint that accepts POST requests and can be reached by CloudFerro. You supply the full URL of that receiver. If you do not have a receiver, skip this section.

In the terminal authenticated to the VM’s cloud and project, find the instance name or ID:

openstack server list

Replace SPOT_INSTANCE_NAME with that name or ID, and replace the entire example URL https://YOUR_CALLBACK_HOST/spot-termination with your receiver’s URL. Keep the tag in quotes so that URL query parameters are passed as part of the same value:

openstack --os-compute-api-version 2.26 server set \
  --tag "callback_url:https://YOUR_CALLBACK_HOST/spot-termination" \
  SPOT_INSTANCE_NAME

Check the saved tag:

openstack --os-compute-api-version 2.26 server show SPOT_INSTANCE_NAME -c tags

The tags field should contain callback_url: followed by your receiver’s URL. Saving the tag does not test whether the receiver accepts notifications.

To add the callback during VM creation instead, include the same –tag option in the complete openstack server create command prepared using Prerequisite No. 5, and use –os-compute-api-version 2.52 or later.

Currently supported tags

callback_url:URL sets the address to which CloudFerro can send a termination notification. The receiver must accept a POST request with a JSON body such as:

{
  "instance_uuid": "00000000-0000-0000-0000-000000000000",
  "time_until_deletion": 120
}

In an actual notification, instance_uuid identifies your VM and time_until_deletion gives the time remaining in seconds. A notification with time_until_deletion set to 0 confirms deletion. Keep saving results and checkpoints while the job runs; do not depend on receiving a notification.

The expected behaviour of spot instances

Currently, spot instances use the same project quota as on-demand instances and, under normal circumstances, behave identically to their non-ephemeral counterparts. When resources in the cloud become tight, the behaviour changes as well – scheduling an on-demand instance might still be possible but scheduling a spot instance may become unavailable. This is to make sure that on-demand user’s experience is prioritized.

You can temporarily shelve spot instances. While they are shelved, you pay for the persistent storage they retain.

How to convert spot instance to on-demand instance

To continue on a regular instance, choose a compatible non-spot flavor and request a resize. This requires sufficient quota and capacity in the cloud. After conversion, the regular flavor’s price applies. Keep saving progress outside the VM; do not depend on completing a resize during a termination notice.

You can resize instance through Horizon:

../_images/resize_instance.png

With CLI, you can use a command like this:

openstack server resize --flavor FLAVOR_NAME INSTANCE_NAME

Replace INSTANCE_NAME with your VM name or ID and FLAVOR_NAME with the selected regular flavor. Check the resize status:

openstack server show INSTANCE_NAME

When the status is VERIFY_RESIZE, check that the VM and application work, then confirm the resize:

openstack server resize confirm INSTANCE_NAME

If the resized VM does not work as expected, revert instead of confirming:

openstack server resize revert INSTANCE_NAME

What to do next

Prepare storage for the worker’s results using How to use Object Storage on CloudFerro Cloud. For the full Horizon resize procedure, follow Resizing a virtual machine using OpenStack Horizon on CloudFerro Cloud.

For service behaviour and billing information, see Spot Virtual Machines.

Still need help?
If this article doesn’t answer all of your questions, our support team will do their best to help you.
Contact support