Vahn Gomes

Fullstack Developer and Aviation Enthusiast

Keeping Your Oracle Cloud Infrastructure (OCI) ForeverFree Tier Instances Active

Hello, everyone!

If you’ve been using Oracle Cloud Infrastructure’s ForeverFree tier, you’d know about Oracle’s policy which might delete instances if they’re perceived as idle for too long. A few months ago, I stumbled upon the OCIScripts repository by Drag-NDrop, designed to help users maintain their OCI instances’ activity.

Inspired by this, I set out to optimize and extend this work, culminating in the Prevent-OCI-Deletion-for-being-idle repository. While I’ve made modifications and optimizations, the core idea and script mechanisms owe their existence to Drag-NDrop’s original work.

Introducing startPointlessProcesses.sh

My major contribution is the modification of startPointlessProcesses.sh. Here are some highlights:

  1. Lock Mechanism: To ensure only a single instance of the script runs, I’ve introduced a lockfile mechanism. This prevents any overlapping processes that might overburden the CPU.
  2. Log Management: The script maintains and manages its own log file, ensuring it doesn’t grow endlessly. If the log becomes too large, it’s renamed with a timestamp, and a new log file is initiated.
  3. Dynamic Load Management: Instead of a blind/uncontrolled approach, the script checks CPU usage and only induces load when necessary. The threshold is currently set at 20% – if CPU usage drops below this, the script spawns child processes to increase load.
  4. Manager Instance: The previous version of this code from Drag-NDrop would have the manager run every minute. Constantly creating new instances of it, which can result in maxing out the CPU. My version of the code ensures only one manager exists at a time ensuring the script doesn’t run away.

Automated Setup

For those who prefer a hands-off approach, I’ve also added a setup.sh script. Running a simple one-liner will clone the repo, set the necessary permissions, and automate the process using crontab.

Ethical Consideration

It’s vital to highlight the ethical and environmental implications. While it’s tempting to keep an instance running to prevent its deletion, this strategy consumes energy. Please deploy only if you truly need to keep the instance active.

Final Thoughts

A huge shout-out to the original OCIScripts repository for laying the foundation. For those interested in my modifications, you can check out the entire repository here.

Remember, tools and scripts like these should be used responsibly. Happy coding!

Leave a Reply