OCI Autoscale Super Script

By | June 26, 2019

There are multiple OCI resources that support some form of Autoscaling and/or Power on/off operations. These operations can allow you to reduce cost or get the correct performance when needed.

Currently OCI has 2 native build-in auto scaling policies:
– Autoscaling Configurations for Instance pools
– Autoscaling option for Autonomous Databases

Both build-in auto scaling policies work on the current workload of the resource, but does not really keep into account that OCI billing in done on an hourly basis.

The OCI Autoscaling Script

Hence, I would like to introduce to you the OCI AutoScaling script. This script can Scale and Power On/Off resources just based on a time schedule. Managing the schedule for each resource can easily be done using a pre-defined tag. The value of the tag needs to contain 24 numbers, were each number stands for the size of the resource for that hour of the day. When the value of 0 is specified, the resource will be powered off (if supported by that resource).

Example Auto Scaling of an Instance Pool
Example Automatic Power On / Off schedule for Database VM

The script supports 3 running methods: All, Up, Down

  • All: This will execute any scaling and power on/off operation
  • Down: This will execute only power off and scaling down operations
  • Up: This will execute only power on and scaling up operations

The thinking behind this is that most OCI resources are charged per hour. So you likely want to run scale down / power off operations just before the end of the hour and run power on and scale up operations just after the hour.

To ensure the script runs as fast as possible, all blocking operations (power on, wait to be available and then re-scale) are executed in seperate threads. I would recommend you run scaling down actions 2 minutes before the end of the hour and run scaling up actions just after the hour.

The script can run anywhere that has internet access to the OCI API services.

You can download the script from my GitHub repository:

Database backup considerations

If you want to stop your Database Cloud Service instances at certain time, you probably want to make sure you manage the backup schedule to fall in windows when you instance is powered on, else the backup can not be made.

According to Oracle’s Database documentation:

  • Backup Window Time Zone - Automatic backups enabled for the first time after November 20, 2018 on any database will run between midnight and 6:00 AM in the time zone of the DB system's region. If you have enabled automatic backups on a database before this date, the backup window for the database will continue to be between midnight and 6:00 AM UTC. You can create a My Oracle Support service request to have your automatic backups run in a backup window of your choice.

Additionally On-Demand Full Backups can be created for your database at any time unless your database is assuming the standby role in a Data Guard association.

One thought on “OCI Autoscale Super Script

  1. Pingback: How Elastic is the Oracle Cloud – Oracle Cloud Blog

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.