• Support
  • PHP-FPM Causing High CPU Usage and Server Overload

Hello fellow forum members,

I hope everyone is doing well. Today, I'm facing an urgent issue with PHP-FPM on my server, and I'm seeking some advice and guidance from the knowledgeable community here at the forum. The problem I'm encountering is that PHP-FPM is exhibiting very high CPU usage, and at times, it shoots up to 100%, overloading the server. I'm currently running an Intel Core i5 13th Gen 13500 CPU with 64GB RAM, but even with this setup, the CPU load is becoming unmanageable due to PHP-FPM.

Here's a bit more information about my setup:

Operating System: CentOS Stream 8 x86_64(Py3.7.9)
Web Server: Nginx
PHP Version: PHP 8.1
aaPanel Version: 6.8.29
The high CPU usage is causing performance issues for the website hosted on the server, resulting in slower response times and increased page loading times. I'm worried about the impact on the user experience and overall server stability.

I have already tried the following troubleshooting steps to address the issue:

Checked for any errors or warning logs in the PHP-FPM and web server logs.
Reviewed the PHP-FPM pool settings to ensure they are optimized for the server's resources.
Monitored the server using utilities like 'top' and 'htop' to identify any specific processes consuming excessive CPU resources.
Increased the number of PHP-FPM workers to handle incoming requests efficiently.
However, despite these efforts, the CPU usage remains persistently high, and I haven't been able to pinpoint the exact cause of the problem.

At this point, I'm kindly reaching out to the aaPanel community for any suggestions, insights, or potential solutions that could help me resolve this issue. If any of you have encountered a similar problem with PHP-FPM or if you have any expertise in optimizing PHP-FPM for better resource utilization, I would greatly appreciate your input.

Here are some specific questions that come to mind:

  • Are there any specific PHP-FPM configurations that work well for servers with an Intel Core i5 13th Gen 13500 CPU and 64GB RAM?
  • Could there be any specific PHP scripts or applications causing the high CPU usage? How can I identify and address these potential culprits?
  • Are there any tools or methodologies that I can use to further investigate the root cause of the issue?
  • I look forward to your valuable suggestions and assistance. Thank you in advance for your support!

Best regards,

    It is recommended that you check the php slow log and mysql slow log, if there is, please ask relevant personnel to optimize it

    izsurya

      5 days later

      This is the same for me (also with nginx)
      It can't be an attack, it occures ONLY when I make import changes on my WordPress site (as changing theme, or updating templates). Maybe Divi and WP-Rocket are not the best friend ever (?)

        Paulo I’m not using any caching plugin still facing the issues, I give up now, searching for alternative

        I'm not going to declare victory too quickly, but by switching from PHP8.1 to 8.2 I've seen a clear improvement (yet to be confirmed).

        aaPanel_Kern

        [01-Aug-2023 14:34:23] [pool www] pid 924402
        script_filename = /www/wwwroot/abc.net/index.php
        [0x00007fbc7f814ae0] curl_exec() /www/wwwroot/abc.net/wp-content/plugins/api-blueprint/core/includes/classes/class-api-blueprint-run.php:988
        [0x00007fbc7f8148c0] backend_api() /www/wwwroot/abc.net/wp-content/plugins/api-blueprint/core/includes/classes/class-api-blueprint-run.php:1087
        [0x00007fbc7f814520] process_payload() /www/wwwroot/abc.net/wp-content/plugins/api-blueprint/core/includes/classes/class-api-blueprint-run.php:644
        [0x00007fbc7f813ba0] custom_routes_catch() /www/wwwroot/abc.net/wp-includes/class-wp-hook.php:308
        [0x00007fbc7f813810] apply_filters() /www/wwwroot/abc.net/wp-includes/class-wp-hook.php:332
        [0x00007fbc7f813760] do_action() /www/wwwroot/abc.net/wp-includes/plugin.php:517
        [0x00007fbc7f813480] do_action() /www/wwwroot/abc.net/wp-includes/template-loader.php:13
        [0x00007fbc7f813190] INCLUDE_OR_EVAL /www/wwwroot/abc.net/wp-blog-header.php:19
        [0x00007fbc7f813090] INCLUDE_OR_EVAL /www/wwwroot/abc.net/index.php:17

        You can see in the above screenshot the user is the root who taking the resources, not www.

        please let me know how to solve this.

          Hello friend,

          I think you can better understand how php-fpm works with this article
          https://haydenjames.io/php-fpm-tuning-using-pm-static-max-performance/

          maybe you can get an improvement if you perform mysqltunning

          about microcache, have you thought about using redis on the frontend and database?

          can you tell me more details about your project is a virtual store or blog, because there are different optimizations for each scenario..

          7 days later

          I found this in php change log (regarding php 8.2.7)
          Fixed bug GH-10461 (PHP-FPM segfault due to after free usage of child->ev_std(out|err)).
          https://github.com/php/php-src/issues/10461

          As I'm still running php 8.2, I'm wondering if this is supposed to fix the shared situations previously in this post.

            2 months later
            7 days later

            No, even if this is maybe better, I still have 100% CPU around php-fpm
            I noticed that each time this is a root process and not www.

            If none of the sites you are hosting are hacked and the server configuration is right, then the next explanation is that some of your websites are constantly hitting with requests from bot networks.

            I had the same problem on one of my clients. Everything was fine server wise but the php-fpm was 100%. We put his site behind cloudflare, monitor the traffic from which countries and IPs had constantly too many requests to justify as a human being and block these countries and IPs.

            You should check the access logs and see if specific IPs are constantly hitting your server with requests. Then block em.

            I think my problem is different.
            It only happens while I'm working on my websites.
            If there are too many requests, then I'd be the guilty :-/

            3 months later
            Connect with us: 📨 Telegram 💬 Discord Email: support@aapanel.com