Solved: php-cgi hogging 100% CPU

Started by trick77, April 21, 2024, 09:29:13 AM

Previous topic - Next topic
April 21, 2024, 09:29:13 AM Last Edit: April 21, 2024, 09:35:11 AM by trick77
I had been experiencing an issue where the CPU usage spiked to 100% when accessing the OPNsense dashboard or navigating through the UI. When using the top command, I saw one or more php-cgi processes consuming close to 100% CPU and using up all available memory until they were terminated. This problem worsened over the past few weeks, and I found myself having to manually terminate the php-cgi processes frequently.

While exploring the file system, I stumbled upon the /var/lib/php/sessions directory and discovered I couldn't list its contents due to the sheer number of leftover PHP session files. These files were so abundant that they severely impacted PHP's session handling capabilities. I was unable to delete the files using rm * due to their volume. Ultimately, I had to remove the entire directory with rm -f /var/lib/php/sessions/ (it gets recreated automatically).

I traced the issue back to an unusually high value set for Session Timeout under System -> Settings -> Administration. I don't recall changing this setting to a value in the millions of minutes, it just makes no sense. I don't know how the default was changed, maybe during previous a config restore?

After deleting the session files and setting the timeout back to 240 minutes no more CPU hogging php-cgi processes!

I'm sharing this in case anyone else encounters a similar issue.