How to keep Oracle from reclaiming “your” Always Free Tier Instances.

3 Ways to keep Oracle from reclaiming “your” Always Free Instances

If you are reading this article chances are that you have probably received the following warning email from Oracle, and you are wondering how to prevent it from happening in the future.

Oracle Cloud Infrastructure Customer,

Oracle Cloud Infrastructure (OCI) will be reclaiming idle Always Free compute resources from Always Free customers. Reclaiming idle resources allows OCI to efficiently provide services to Always Free customers. Your account has been identified as having one or more compute instances that have been idle for the past 7 days. These idle instances will be stopped one week from today, May 30,2023. If your idle Always Free compute instance is stopped, you can restart it as long as the associated compute shape is available in your region. You can keep idle compute instances from being stopped by converting your account to Pay As You Go (PAYG). With PAYG, you will not be charged as long as your usage for all OCI resources remains within the Always Free limits.

As the the email suggests the easiest way would be to convert your account to Pay As You Go. This will be my first recommendation as well! With Pay As You Go account you still get to use all the Always Free services such as 4CPUs, 24GB of Memory, 200GB Block storage, Free Reserved IP, etc. Plus you don’t have to worry about your instances becoming idle and being reclaimed. On top of it, you will rarely see the infamous “Out of Capacity” error when you try to build new instance, and you will have access to Oracle Support team.

Your second option is to stop over-allocating resources. If you are only going to host a proof of concept web app, that will barely generate any traffic, you probably don’t need the 4CPUs and 24G memory. Go with the 1 CPU and 6G memory and chances are you will meet the 15% utilization requirement, and your instance will never become idle.

If non of the above works for you, the only option left is to put some load on your instance and make it meet the requirements posed by Oracle, which at the time of writing this article are:

  • CPU utilization for the 95th percentile is less than 15%
  • Network utilization is less than 15%
  • Memory utilization is less than 15% (applies to A1 shapes only)

You can get the current requirements here.

There are many ways to put load on your instance and of course the best way would be to have a natural load, unfortunately not all of us can do that. The good news is that if you are unable to do it naturally there are many free tools available to help you.

The tool the we will use in this tutorial is called “stress-ng”. Stress-ng is a command-line tool that can be used to induce stress on a computer system’s various hardware components such as CPU, memory, disk, etc. In our case we will use it to simulate CPU usage, and memory allocation so we can meet Oracle’s requirements and keep our instance from becoming idle. We are also going use a tool called “supervisorctl” that will help us manage the “stress-ng” process, and to ensure it is always running on our system.

Before we begin I want to give you a fair WARNING: There is a good chance that this setup violates Oracle’s Always Free Tier Terms of Services and implementing this solution may get your OCI account suspended or terminated. If you are willing to take this risk keep reading, otherwise follow my top recommendation and upgrade to Pay As You Go account.

The first thing that we need to do is ssh to our instance switch to root and install “stress-ng” and “supervisorctl”.

sudo su -
apt update
apt install supervisor stress-ng

After we have both tools installed we can go ahead and run the following commands to send some load to our CPUs and Memory:

The command below will put 15% load on each of the 4 CPUs available, we can tweak the numbers below as we wish to meet our requirements.

stress-ng --cpu 4 --cpu-load 15

The line below will take 15% of our total memory and hold it. So if we are already using lets say 2% of our total memory running this command will cause 17% memory utilization.  Again we can tweak these numbers as we wish to meet our requirements.

stress-ng --vm 1 --vm-bytes 15% --vm-hang 0

To terminate these commands all we need to do is press Ctrl-c.

Once we have adjusted these commands to fit our needs. We need to create supervisor configuration file . The supervisor configuration file will ensure that stress-ng is always running on our instance. To create the file we run the following command.

nano /etc/supervisor/conf.d/stress.conf

Copy and paste the following config to your “stress.conf” this is just and example make sure to tweak it to meet your requirements. The config below will create two programs “cpu_stress” and “memory_stress” the two programs will run the two “strass-ng” commands we ran above simultaneously, it will auto start them on boot and auto-restart them if they get crash or get killed.

[program:cpu_stress]
command=/usr/bin/stress-ng --cpu 4 --cpu-load 15 
directory=/usr/bin/
user=root
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/stress.log

[program:memory_stress]
command=/usr/bin/stress-ng --vm 1 --vm-bytes 15%% --vm-hang 0
directory=/usr/bin/
user=root
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/stress.log

To get supervisor to start the two program we have we first need to reload the configuration file we do that by running the following command. Run the command below anytime you make changes to this config file or create new file!

supervisorctl reread

Next we can go ahead and reload the “supervisorctl” to start the two programs.

supervisorctl reload

You can check the status of the programs by running

supervisorctl status

For more details and to see this set up in action check out my video on youtube: