Openstack HEAT tutorials: 3. Autoscaling with Ceilometer

The real power of Heat is creating autoscaling resources which automatically scale up/down resources based on Ceilometer metrics.

In the example below, Heat will create an autoscaling group with a minimum of 1 instances and a maximum of 5 instances (at launch time it will create only one instance) and will adjust the number of instances based on the average CPU utilization. If the average CPU utilization, calculated over all existing instances, will be higher than 50% (average measured on a 10 minutes period), it will add another instance, identical to the existing ones. If the average CPU utilization, calculated over all existing instances is lower than 15% (average measured on a 10 minutes period) it will remove one instance, in order to free up resources.

All the parameters are configurable: the number of instances to be created at launch time, the minimum/maximum number of instances, the CPU utilization thresholds, the number of instances to be added/deleted when an alarm is triggered etc.

For more introductory details about the structure of a template, please see tutorial 1 and tutorial 2.

In the template below there are 5 resources defined. The autoscaling group which configures the desired number of instances to be created at launch time and the minimum/maximum number of instances in the stack and also the typical OS::Nova::Server properties (instance properties).

The next two resources define the scale up and the scale down policy resources. They configure the autoscaling policies and their main parameters are: scaling_adjusment (+/-N – where N is the number of instances to be created or deleted when the Ceilometer alarm is triggered) and the cooldown period (time to wait after an adjustment is made before another adjusment can be done).

The next two resources define the Ceilometer alarms that are triggered when the average CPU utlization is higher/lower than the configured thresholds for a duration >= period * evaluation_periods.