Autoscaling Groups

Create and manage autoscaling groups, scheduled actions, scaling policies and policy alarms with configuration.

Overview

The Cumulus Autoscaling module defines autoscaling groups, scheduled scaling actions, scaling policies and policy alarms in JSON files. Cumulus syncs those configuration files with AWS to create and manage autoscaling resources.

Cumulus has three different types of policy definitions. Inline policies are defined on the resource and are used to define a policy that will not be used elsewhere. If a policy will be used as is in multiple places, it should be defined as a static policy. Finally, a template policy can produce policies that differ only by the variables passed to the template.

The following sections will describe the unique properties of each resource type. Example configurations are included with the Cumulus repo.

Autoscaling Groups

An autoscaling group definition is just a JSON object. By default, the definitions are located in {path-to-cumulus}/conf/autoscaling/groups, but this can be configured. The JSON object can contain the following attributes (most of which are analogous to AWS configuration of autoscaling groups):

Scheduled Scaling Actions

An autoscaling group can be configured such that scaling actions take place on a scheduled basis. Scheduled scaling actions change the min, max, and desired number of instances in the autoscaling group. When syncing autoscaling groups that have scheduled actions, the size of the group may depend on what is configured in a scheduled action (see Syncing Size for more information). Each scheduled scaling action is a JSON object in the scheduled array of the autoscaling group definition, and contains the following attributes:

Scaling Policies

Scaling policies specify scaling actions that can be taken on the autoscaling group. They are defined in JSON objects containing the following attributes:

The policies attribute of autoscaling group definitions is a JSON object that contains three attributes: inlines, templates, and static. Each corresponds to a different method for specifying scaling policies.

{
  "template": "example-template",
  "vars": {
    "n": "2"
  }
}

Policy Alarms

Scaling policies can contain alarms. Alarms correspond to Cloudwatch alarms, and will take the action defined by the autoscaling policy when the alarm is fired. Alarms are defined in JSON objects with the following attributes:

Diffing and Syncing Configuration

Cumulus’s autoscaling module has the following usage:

cumulus autoscaling [diff|help|list|migrate|sync] <asset>

Autoscaling groups can be diffed, listed, and synced (migrate is covered in migration). These three actions do the following:

Syncing Size

Because autoscaling groups can change in size in response to alarms or scheduled actions, the size (min, max, and desired instances) of an autoscaling group is synced a little differently than the other configuration options. If the local configuration has any scheduled actions configured, we will set the min and max size of the autoscaling group to match the last scheduled action that would have ran. Desired is never updated unless it is not in the min/max bounds. This behavior can be overridden by passing the --autoscaling-force-size argument with the sync command, which will use the configured size on the autoscaling group instead of the most recent scheduled action.

For example, suppose we have an autoscaling group configured as follows:

{
  ...
  "scheduled": [
    {
      "name": "Scale up at 9am UTC",
      "recurrence": "0 9 * * *",
      "min": 9
    }
  ],
  "size": {
    "min": 3,
    "max": 21,
    "desired": 4
  }
  ...
}

If the current time is 10am UTC, we will use a min value of 9, a max value of 21, and a desired value of 9 when comparing the local configuration to AWS configuration. Notice that if the desired value in AWS is outside of the new range, it will be updated to be within the range by raising the value to the min or lowering it to the max. If using the --autoscaling-force-size argument when diffing or syncing, the values of 3, 21, and 4 will be used for min, max, and desired respectively.

Migration

Cumulus provides a migrate task that makes migrating to Cumulus easy. Autoscaling configuration is pulled down to produce Cumulus configuration. All scaling policies are converted to inline policies.

IMPORTANT - because Cumulus assumes that the action taken by the alarm is triggering the policy, if you add another action to the alarm from the AWS console, it will be deleted when Cumulus syncs autoscaling. This is particularly important when migrating, as your previous configuration may have a single Cloudwatch alarm triggering a scaling policy, as well as taking some other action, like SNS notifications. In this case, if you wish to keep the other actions, it is recommended that you create a separate alarm for the other actions.

Configuration

Cumulus reads configuration from a configuration file, conf/configuration.json (the location of this file can also be specified by running cumulus with the --config option). The values in configuration.json can be changed to customized to change some of Cumulus’s behavior. The following is a list of the values in configuration.json that pertain to the Autoscaling module: