php-fpm 100% cpu usage

Discussion in 'General' started by HenrysCat, Feb 21, 2025.

  1. HenrysCat

    HenrysCat Member

    How do I go about solving this? one website is causing random 100% cpu usage for an hour or so a few time a day.
    Screenshot 2025-02-21 at 18.58.32.png
    I have looked at php7.4-fpm.log but no entries for the last 10 hours, and 100% usage is happening now.
    This morning there was an entry
    [pool web1] server reached max_children setting (10), consider raising it
    So I raised pm.max_children from 10 to 100 and rebooted the server, but this evening 100% cpu usage started again.
    Any ideas?
    Thanks all
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Take a look into the access.log of the website. There are multiple reasons for such a spike, it can be a kind of DOS attack, a website spider that has gone crazy, or a high load due to regular users like an post that has gone viral. Or maybe the site lacks proper caching or contains some code that consumes a lot of CPU cycles because it is not optimized. Or the site is infected by malware. There are many possibilities.

    Your system is probably not able to handle 100 concurrent PHP-FPM processes, so better lower that again down to 10 or maybe try 15 or 20. This setting exists to protect your server, so do not overwhelm the system by choosing a value that's too high. lets say you set this to 100 and each PHP process consumes 500 MB RAM, then setting it to 100 means you must have at least 50GB RAM for this website alone, plus RAM for other services like MySQL. So unless you have at least 64GB to 128GB RAM, better not use such high values.
     

Share This Page