May 2020 Update: If you need to power on/off or scale up/down many instances, you might run into the issue of OCI rate limiting. The Autoscaling script now manages this. Also other new features have been added, like support for notification service to report on the activity.
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).
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. Some services are billed per second and some 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 separate 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. The script supports instance principle for authentication. Meaning you can run the script inside an instance on OCI and use a Dynamic Group to give it the right privileges. Meaning you do not have to specify any details in side the OS where the script runs.
You can download the script from my GitHub repository:
Which Services can you scale?
Want to have an overview which service in OCI support power on/off or scaling operations? Check out my overview here:
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
. 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.