
Keep free Oracle Compute instances active with Stress-ng
Oracle Could Infrastructure generously provide completely free compute instances to all users. However, Oracle reserve the right to reclaim idle instances. This article describes how to generate a load capable of satisfying Oracle's definition of activity to prevent reclamation.
Oracle's definition of Idle
Oracle define idle compute instances as (amongst other things): CPU utilization for the 95th percentile is less than 15% during a 7-day period.
Generation of a qualifying workload
We can use the utility stress-ng (an extension of stress) to generate a qualifying CPU load of 20% utilisation per core for 75 minutes (or 4,500 seconds) per day.
Installation and proof
Assuming Oracle Linux 9, Stress-ng
is in the ol9_appstream
repository therefore can be installed with:
dnf install stress-ng -y
The following snippet generates the necessary workload:
stress-ng -c `grep -c ^processor /proc/cpuinfo` -t 4500 -l 20
where:
-c `grep -c ^processor /proc/cpuinfo`
gets the CPU count, to ensure each CPU will be stressed, and,
-t 4500
times the job for 4,500 seconds (One hour and 15 minutes), and,
-l 20
limits the CPU loading to 20%.
In the Oracle Cloud Infrastructure Compute Instance Detail page for the VM in question, we can observe CPU usage Metrics to confirm the load we generated:
Schedule the loading
To run the load regularly without intervention, sudo su -
to the root
user, then crontab -e
to access the root cron table. Append the following line to run the job at 04:30 each morning (adjust as per your own requirement):
30 04 * * * stress-ng -c `grep -c ^processor /proc/cpuinfo` -t 4500 -l 20