Customers want their cloud to easily right-size their compute fleet to handle the current application load -- and to only pay for the compute resources they need at any given time. To address this need, Oracle Cloud Infrastructure has developed autoscaling for its Compute service, which we will launch publicly soon.
Autoscaling leverages Compute instance pools and Oracle Cloud Infrastructure Monitoring. Instance pools let you pool virtual machine (VM) instances together and keep all VM instances in your pool healthy and running. Monitoring lets you capture average CPU and memory utilization metrics from your pool. With autoscaling, you can create an autoscaling configuration with policies and rules that will launch or terminate instances if thresholds are exceeded on the metrics coming from your pool of VM instances. Autoscaling will be a free-to-use feature in Compute.
You can use autoscaling to scale web front-end, middleware, and back-end workload tiers dynamically. Autoscaling can reduce your DevOps load for adding and removing instances manually. You can also save infrastructure costs with on-demand scaling of instances, instead of pre-provisioning instances for your peak demand.
The autoscaling configuration is used to control scaling actions on an instance pool. We allow one autoscaling configuration per instance pool. Each autoscaling configuration defines a policy and contains two rules.
The autoscaling policy defines the minimum and maximum number of instances to scale to and the initial size of the instance pool. You also need to define the policy type; at launch, the only supported policy type is threshold. The policy also defines a cool-down period for waiting before the next scaling event. You can set only one autoscaling policy in an autoscaling configuration.
Each autoscaling policy contains an autoscaling rule. An autoscaling rule defines which metric to use for scaling and the thresholds for scaling (either in or out). You must use the same metric for scaling in and scaling out. The supported metrics are CPU utilization and memory utilization. You also define the count of instances to scale in and scale out with each scaling action. You define one rule for scaling in and one rule for scaling out.
Before you can set an autoscaling policy on an instance pool, you must first create the instance pool. If you have an existing pool, you can use the CLI to create an autoscaling configuration for it by using the following command:
./oci autoscaling auto-scaling-configuration create --policies file://policies.json --resource instancePool.json --displayName MyTestAutoScalingConfiguration --is-enabled true
The following figure shows example policy.json and instancePool.json files.
The following example shows how to stress your CPU and trigger autoscaling. In this example, we used a VM.Standard2.1 instance type with the latest Oracle Linux image, and we passed in the following cloud-init script as a launch parameter to the instance:
- [sudo, yum, install, stress, -y]
- [stress, -c, 2]
The stress application launches two threads that consume 100 percent of the single CPU core on the VM.Standard2.1 instance.
We used the newly launched instance to generate the instance configuration and then launched an instance pool of size 1 and selected which availability domains to use. Note that you should ensure that you have available limits to launch new instances in the pool.
Then we performed the following steps:
1. On the Instance Pools Details page, click Create Autoscaling Configuration.
2. In the Create Autoscaling Configuration dialog box, enter the configuration details. For this example, we chose to scale on CPU metrics, set the scale-out rule threshold to 90 percent, set the scale-in threshold to 70 percent, and set the max pool size to 6. We already confirmed that we have enough limit to support launching an additional six instances.
3. Click Create. The configuration is set on the pool, and autoscaling will evaluate scaling actions on the pool every 300 seconds.
Optionally, you can navigate to the Monitoring console, select the new pool that you have created, and see the CPU metrics emit and get tracked. To monitor the pool from the monitoring console, follow these steps:
You will then see metrics for all the instances in your pool. You can also choose to aggregate the metrics.
Please be sure to delete your autoscaling config and terminate your instance pool after this tutorial to avoid being charged.
Please monitor https://cloud.oracle.com/en_US/iaas/new for our launch announcement. Autoscaling will be available in all commercial Oracle Cloud Infrastructure regions. Please contact your Oracle sales person if you want to be included in our Limited Availability release.