Technitium DNS server zone high-availability

Oracle Cloud Free Tier: Prevent Reclaimation of idle compute instance

Oracle Cloud Free Tier offer 2 free VM instance for testing and personal usage. But Oracle will reclaim any idle compute instance within 7 days if the instance meet below status.

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

Follow below step to create "fake" workload to prevent trigger the reclamation process. Disclaimer, use this methods as your own risk as Oracle may view this as violation of their terms and services.

1. Install stress-ng package to generate system workload.

sudo apt-get install stress-ng

2. Install and enable supervisord service to automate the workload process.

sudo apt-get install supervisor
sudo systemctl enable --now supervisor

3. Create the automate configuration file (/etc/supervisor/conf.d/stress.conf). You can always adjust the CPU and memory usage accordingly.

# consume 2 CPU 10% usage
[program:cpu_stress]
command=/usr/bin/stress-ng --cpu 2 --cpu-load 10
directory=/usr/bin/
#user=root
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/stress.log

# consume 15% of total memory usage
[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/supervisor/stress.log

4. Optional. Housekeep supervisord log using logrotate (/etc/logrotate.d/supervisord).

/var/log/supervisor/*.log
{
        rotate 4
        weekly
        missingok
        notifempty
        compress
}

5. Double check and restart supervisord service with the new configuration file.

ubuntu@pihole:/etc/logrotate.d$ sudo supervisorctl status
cpu_stress                       RUNNING   pid 102541, uptime 16:23:50
ubuntu@pihole:/etc/logrotate.d$ sudo supervisorctl reread
No config updates to processes
ubuntu@pihole:/etc/logrotate.d$ sudo supervisorctl reload
Restarted supervisord
ubuntu@pihole:/etc/logrotate.d$ sudo supervisorctl status
cpu_stress                       RUNNING   pid 139505, uptime 0:00:03
ubuntu@pihole:/etc/logrotate.d$ systemctl status supervisor.service
● supervisor.service - Supervisor process control system for UNIX
     Loaded: loaded (/lib/systemd/system/supervisor.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2024-03-20 02:00:54 +08; 2 days ago
       Docs: http://supervisord.org
   Main PID: 564 (supervisord)
      Tasks: 4 (limit: 1056)
     Memory: 33.3M
        CPU: 12h 53min 41.338s
     CGroup: /system.slice/supervisor.service
             ├─   564 /usr/bin/python3 /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
             ├─139505 /usr/bin/stress-ng --cpu 2 --cpu-load 10
             ├─139506 "stress-ng-cpu [run]" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
             └─139507 "stress-ng-cpu [run]" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

Mar 22 18:25:15 pihole supervisord[564]: 2024-03-22 18:25:15,119 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
Mar 22 18:25:15 pihole supervisord[564]: 2024-03-22 18:25:15,119 INFO Included extra file "/etc/supervisor/conf.d/oracle_stress.conf" during parsing
Mar 22 18:25:15 pihole supervisord[564]: 2024-03-22 18:25:15,121 INFO RPC interface 'supervisor' initialized
Mar 22 18:25:15 pihole supervisord[564]: 2024-03-22 18:25:15,121 CRIT Server 'unix_http_server' running without any HTTP authentication checking
Mar 22 18:25:15 pihole supervisord[564]: 2024-03-22 18:25:15,121 INFO supervisord started with pid 564
Mar 22 18:25:16 pihole supervisord[564]: 2024-03-22 18:25:16,124 INFO spawned: 'cpu_stress' with pid 139505
Mar 22 18:25:16 pihole stress-ng[139505]: invoked with '/usr/bin/stress-ng --cpu 2 --cpu-load 10' by user 0 'root'
Mar 22 18:25:16 pihole stress-ng[139505]: system: 'pihole' Linux 6.5.0-1019-oracle #19~22.04.1-Ubuntu SMP Mon Mar 11 15:33:36 UTC 2024 x86_64
Mar 22 18:25:16 pihole stress-ng[139505]: memory (MB): total 947.49, free 104.22, shared 6.41, buffer 15.42, swap 0.00, free swap 0.00
Mar 22 18:25:17 pihole supervisord[564]: 2024-03-22 18:25:17,134 INFO success: cpu_stress entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
ubuntu@pihole:/etc/logrotate.d$

Comments