Spot

Overview

Spot Instances are Amazon Web Services line of budget instance options. They allow you to pay a substantially cheaper price for instances. The tradeoff is that the instances are not guaranteed, they may be shutdown at any time. The current design of the Deadline Balancer does not allow users to take advantage of these discount instances. This event plugin tries to replicate the functionality of the Balancer while using Spot Fleet Instances. Spot Fleet is a convenient way to manage many Spot Instances simultaneously. You can learn more about Spot Instances on the AWS Spot Instance Website.

Setup

Before you can use the Spot event plugin, you are going to need an AWS account. You will need to get an API Access Key and Secret Key from the IAM Console under Users and Security Credentials. You can find more information about that in this AWS blog entry and the AWS documentation.

To access these settings, simply enter Super User mode and select Tools -> Configure Events form the Monitor’s menu. From there, select the Spot entry from the list on the left.

../_images/cep_spot.png

The Spot event plugin settings are:

Login

  • Access Key ID: This is what we use to login to the AWS API. See Setup for more information on how to get this value.
  • Secret Access Key: This is the passcode for login into the AWS API. See Setup for more information on how to get this value.

Configuration

  • Region: The AWS Region we will be launching Spot Instances in.
  • Spot Fleet Request Configurations: This is a one to one mapping of Deadline Groups and Spot Fleet Configurations. This is a JSON dictionary, with the Deadline Group being a key and the Spot Fleet Configuration the value. You can download your Spot Fleet Configuration from the Review page of the Create Spot Fleet page of the EC2 Web Console.
  • Idle Shutdown: The number of minutes the Spot Instance will wait after in finishes rendering before it shuts itself down.

Process

Here is an overview of how the Spot event plugin works.

Firstly, we aggregate the number of queued tasks (the work to be done) for every Deadline Group. Next, we either create or modify a Spot Fleet Request for every Deadline Group that has a Spot Fleet Configuration. Each Spot Fleet Request will ask AWS for a number of Spot Instances equal to the queued tasks or the maximum capacity set by the user.

Once the Spot Fleet Requests have been fulfilled and the Slaves have started, they will automatically assign themselves to the group they were created for.

Finally, once the Slaves have been in a state other than Rendering for a certain amount of time, they will shut themselves down. The Slave will mark itself as offline and remove itself from the Slave List. When a Spot Instance is shutdown, it is terminated.

Spot Fleet Configuration

The Spot Fleet Configuration setting is a JSON dictionary. It represents a one to one mapping between a Deadline Group and Spot Fleet Configurations.

The dictionary has Deadline Group names as keys and Spot Fleet Configurations as values. To download a Spot Fleet Configuration, start by creating a new Spot Fleet Request.

../_images/events_spot_start.png

In the Spot Fleet Request’s Review page, there is a button to download the Configuration as JSON.

../_images/events_spot_review.png

Copy everything in the downloaded file and place it into the Spot Fleet Configuration for the desired Deadline Group.

Here’s an example with two Deadline Groups:

{
        “amazon_group”:{
                "IamFleetRole": "arn:aws:iam::357432474442:role/aws-ec2-spot-fleet-role",
                "AllocationStrategy": "lowestPrice",
                "TargetCapacity": 1,
                "SpotPrice": "0.105",
                "ValidFrom": "2016-12-13T16:48:12Z",
                "ValidUntil": "2017-12-13T16:48:12Z",
                "TerminateInstancesWithExpiration": true,
                "LaunchSpecifications": [
                {
                        "ImageId": "ami-b04s92d0",
                        "InstanceType": "c3.large",
                        "KeyName": "key_pair",
                        "SpotPrice": "0.105",
                        "BlockDeviceMappings": [
                        {
                                "DeviceName": "/dev/xvda",
                                "Ebs": {
                                        "DeleteOnTermination": true,
                                        "VolumeType": "gp2",
                                        "VolumeSize": 8,
                                        "SnapshotId": "snap-c87f35ec"
                                }
                        }
                        ],
                        "NetworkInterfaces": [
                        {
                                "DeviceIndex": 0,
                                "SubnetId": "subnet-3efcba4b",
                                "DeleteOnTermination": true,
                                "Groups": [
                                   "sg-2d623a54"
                                ],
                                "AssociatePublicIpAddress": true
                        }
                        ]
                }
                ],
                "Type": "maintain"
        },
        “another_deadline_group”:{
                "IamFleetRole": "arn:aws:iam::357466224442:role/aws-ec2-spot-fleet-role",
                "AllocationStrategy": "lowestPrice",
                "TargetCapacity": 1,
                "SpotPrice": "0.133",
                "ValidFrom": "2016-12-15T16:47:06Z",
                "ValidUntil": "2017-12-15T16:47:06Z",
                "TerminateInstancesWithExpiration": true,
                "LaunchSpecifications": [
                {
                        "ImageId": "ami-d722f0b7",
                        "InstanceType": "m3.medium",
                        "SpotPrice": "0.067",
                        "BlockDeviceMappings": [
                        {
                                "DeviceName": "/dev/sda1",
                                "Ebs": {
                                        "DeleteOnTermination": true,
                                        "VolumeType": "gp2",
                                        "VolumeSize": 8,
                                        "SnapshotId": "snap-42713105"
                                }
                        }
                        ],
                        "SecurityGroups": [
                        {
                                "GroupId": "sg-06b82060"
                        },
                        {
                                "GroupId": "sg-5058c026"
                        }
                        ],
                        "SubnetId": "subnet-2040e466"
                },
                {
                        "ImageId": "ami-d722f0b7",
                        "InstanceType": "m4.large",
                        "SpotPrice": "0.12",
                        "BlockDeviceMappings": [
                        {
                                "DeviceName": "/dev/sda1",
                                "Ebs": {
                                        "DeleteOnTermination": true,
                                        "VolumeType": "gp2",
                                        "VolumeSize": 8,
                                        "SnapshotId": "snap-47113105"
                                }
                        }
                        ],
                        "SecurityGroups": [
                        {
                                "GroupId": "sg-06b44060"
                        },
                        {
                                "GroupId": "sg-5238c036"
                        }
                        ],
                        "SubnetId": "subnet-1010e466"
                },
                {
                        "ImageId": "ami-d722b0b7",
                        "InstanceType": "m3.large",
                        "SpotPrice": "0.133",
                        "BlockDeviceMappings": [
                        {
                                "DeviceName": "/dev/sda1",
                                "Ebs": {
                                        "DeleteOnTermination": true,
                                        "VolumeType": "gp2",
                                        "VolumeSize": 8,
                                        "SnapshotId": "snap-47743105"
                                }
                        }
                        ],
                        "SecurityGroups": [
                        {
                                "GroupId": "sg-06b84063"
                        },
                        {
                                "GroupId": "sg-5058c016"
                        }
                        ],
                        "SubnetId": "subnet-1042e466"
                }
                ],
        "Type": "maintain"
        }
}

FAQ

Can the Spot Event Plugin be used in combination with the Deadline Balancer?

No. The Deadline Balancer and Spot Event plugin can technically be run at the same time but they do not complement each other. They will create Slaves for the same tasks.