# High php-fpm cpu, slow response after upgrade

**URL:** <https://help.nextcloud.com/t/high-php-fpm-cpu-slow-response-after-upgrade/64670>\
**Category:** ℹ️ Support\
**Tags:** nc15, php\
**Created:** [November 21, 2019, 8:38am UTC](https://help.nextcloud.com/t/high-php-fpm-cpu-slow-response-after-upgrade/64670 "2019-11-21T08:38:34Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreas](https://help.nextcloud.com/letter_avatar/andreas/32/5_5575768a8748004e209b776fc1b2916d.png) [@andreas](https://help.nextcloud.com/u/andreas)\
**Post date:** [November 21, 2019, 8:38am UTC](https://help.nextcloud.com/t/high-php-fpm-cpu-slow-response-after-upgrade/64670/1 "2019-11-21T08:38:34Z")

</div>

I’ve been running NC15 on Debian9 with PHP7.0-fpm and Apache with HTTP/2, working fine. Two weeks ago, I upgraded the machine to Debian10 with PHP7.3-fpm and NC17, and since then everything takes a lot longer. I’ve got some long-term monitoring, so I can tell that the usual cpu usage on the web server (4 cores) was 1.5% avg before the update, and is up to 20% now (including night time). Simple changing directory in the files app will take about 1 second now, htop shows php-fpm processes creating high cpu usage.  
settings/admin/overview shows no problems, memcache.local is APCu, Redis for memcache.locking, no fancy add-ons, nothing in the logs.  
Any hints what to inspect next?

Regards,  
Andreas

---

<div class="post-metadata">

**Author:** ![trendzetter](https://help.nextcloud.com/user_avatar/help.nextcloud.com/trendzetter/32/6860_2.png) [@trendzetter](https://help.nextcloud.com/u/trendzetter)\
**Post date:** [November 21, 2019, 10:37am UTC](https://help.nextcloud.com/t/high-php-fpm-cpu-slow-response-after-upgrade/64670/2 "2019-11-21T10:37:24Z")

</div>

You should probably check if the opcache is active. It could be down to tuning the opcache.

---

<div class="post-metadata">

**Author:** ![kesselb](https://help.nextcloud.com/user_avatar/help.nextcloud.com/kesselb/32/74519_2.png) [@kesselb](https://help.nextcloud.com/u/kesselb)\
**Post date:** [November 21, 2019, 11:23am UTC](https://help.nextcloud.com/t/high-php-fpm-cpu-slow-response-after-upgrade/64670/3 "2019-11-21T11:23:15Z")

</div>

Probably [https://github.com/nextcloud/server/issues/17447](https://github.com/nextcloud/server/issues/17447) (infinite loop with searchdav requests)

Also good to read: [https://github.com/nextcloud/server/issues/17241](https://github.com/nextcloud/server/issues/17241)

I would try to patch the instance like in the first issue and check the monitoring. Feel free to join the other issue if that does not work.

---

<div class="post-metadata">

**Author:** ![andreas](https://help.nextcloud.com/letter_avatar/andreas/32/5_5575768a8748004e209b776fc1b2916d.png) [@andreas](https://help.nextcloud.com/u/andreas)\
**Post date:** [November 21, 2019, 12:04pm UTC](https://help.nextcloud.com/t/high-php-fpm-cpu-slow-response-after-upgrade/64670/4 "2019-11-21T12:04:25Z")

</div>

Probably not a dav problem, because all requests that don’t involve dav are slow as well.  
opcache is enabled and configured as recommended.

Checked: the searchdav-fix doesn’t fix this issue.

---

<div class="post-metadata">

**Author:** ![andreas](https://help.nextcloud.com/letter_avatar/andreas/32/5_5575768a8748004e209b776fc1b2916d.png) [@andreas](https://help.nextcloud.com/u/andreas)\
**Post date:** [November 21, 2019, 4:52pm UTC](https://help.nextcloud.com/t/high-php-fpm-cpu-slow-response-after-upgrade/64670/5 "2019-11-21T16:52:29Z")

</div>

One more observation:  
The memory usage was around 600MB for php-fpm processes, and is now down to 300MB. Total cpu around 100-200% (but not a single process at 100% stuck, load is coming and going), while it was avg 50% when users are busy.

A test file with phpinfo() shows me healtly opcache values (up&running, very few cache misses, 30% memory used).

---

<div class="post-metadata">

**Author:** ![TP75](https://help.nextcloud.com/user_avatar/help.nextcloud.com/tp75/32/12565_2.png) [@TP75](https://help.nextcloud.com/u/TP75)\
**Post date:** [November 21, 2019, 5:56pm UTC](https://help.nextcloud.com/t/high-php-fpm-cpu-slow-response-after-upgrade/64670/6 "2019-11-21T17:56:23Z")

</div>

> [@andreas](#):
>
> Debian10 with PHP7.3-fpm and NC17

Why do you stick to `php-fpm` and could you provide a rationale for this, if I may?

Please choose [libapache2-mod-php7.3](https://packages.debian.org/buster/libapache2-mod-php7.3) over _php-fpm_ as a home user certainly.

Happy hacking.  
🌻

---

<div class="post-metadata">

**Author:** ![andreas](https://help.nextcloud.com/letter_avatar/andreas/32/5_5575768a8748004e209b776fc1b2916d.png) [@andreas](https://help.nextcloud.com/u/andreas)\
**Post date:** [November 22, 2019, 7:17am UTC](https://help.nextcloud.com/t/high-php-fpm-cpu-slow-response-after-upgrade/64670/7 "2019-11-22T07:17:40Z")

</div>

mod-php is supported by mpm-prefork only. mpm-worker is required to support http/2

---

<div class="post-metadata">

**Author:** ![anon9582441](https://help.nextcloud.com/letter_avatar/anon9582441/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon9582441](https://help.nextcloud.com/u/anon9582441)\
**Post date:** [November 22, 2019, 10:57am UTC](https://help.nextcloud.com/t/high-php-fpm-cpu-slow-response-after-upgrade/64670/8 "2019-11-22T10:57:24Z")

</div>

Php-fpm is normally much faster than mod\_php/cgi versions because the PHP engine remains loaded between each request.

---

<div class="post-metadata">

**Author:** ![TP75](https://help.nextcloud.com/user_avatar/help.nextcloud.com/tp75/32/12565_2.png) [@TP75](https://help.nextcloud.com/u/TP75)\
**Post date:** [November 22, 2019, 1:32pm UTC](https://help.nextcloud.com/t/high-php-fpm-cpu-slow-response-after-upgrade/64670/9 "2019-11-22T13:32:38Z")

</div>

IMHO one could do some more thorough research and I posted some links to more background info in this forum already.  
🥼

However, you are correct and this is a free world.  
😄

* * *

> [@anon9582441](#):
>
> Php-fpm is normally much faster than mod\_php/cgi versions because **the PHP engine remains loaded** between each request.

> [@andreas](#):
>
> htop shows php-fpm processes **creating high cpu usage**.

One could make a connection, I presume.  
🤓

Furthermore, one could reconsider if:

1. the “much faster” is a requirement worth the apparent CPU load
2. the apparent “easy to set up, requires less config” is a positive or a negative

BTW keep it safe, keep it simple is an accepted requirement for a stable system setup, I presume.  
🥼

* * *

Some background info and discussion was provided in two post of same thread:

> [@Urgent security issue in NGINX/php-fpm](https://help.nextcloud.com/t/urgent-security-issue-in-nginx-php-fpm/62665/52):
>
> IMHO installing a sustainable and efficient server is not a simple endeavour. This may not matter most in small scaled service groups and for home users. “Too many cooks spoil the [broth](https://dict.leo.org/englisch-deutsch/viel%20k%C3%B6che%20verderben%20den%20brei).” & Beware of “quick and dirty.” smirk First, keep it small and keep it simple. Consider if your Nextcloud installation actualy needs the ‘php-fm’ module as this is the NC home user forum, if I may recall. Trust the true experts in the background and there is good reason for an advice like "Note that most Ap…

> [@Urgent security issue in NGINX/php-fpm](https://help.nextcloud.com/t/urgent-security-issue-in-nginx-php-fpm/62665/55):
>
> Please be aware I have no expertise of my own with NextcloudPi, unfortunately. However, some general advice in the following. Your system may be without the nginx server and happily away from the a.m. ‘NGINX/php-fpm’ issue. Check for your active webserver with: sudo systemctl status apache2 This should show your Apache 2.4 on the job or some other info. You may consult the below article for background information. [Why NextCloudPi uses Apache and not Nginx](https://ownyourbits.com/2017/06/12/why-nextcloudpi-uses-apache-and-not-nginx/) Consult the NCP docs on the proje…

Hope this helps.  
🤓

* * *

Happy hacking.  
🌻

---

<div class="post-metadata">

**Author:** ![trendzetter](https://help.nextcloud.com/user_avatar/help.nextcloud.com/trendzetter/32/6860_2.png) [@trendzetter](https://help.nextcloud.com/u/trendzetter)\
**Post date:** [November 22, 2019, 1:58pm UTC](https://help.nextcloud.com/t/high-php-fpm-cpu-slow-response-after-upgrade/64670/10 "2019-11-22T13:58:54Z")

</div>

> [@TP75](#):
>
> Why do you stick to `php-fpm` and could you provide a rationale for this, if I may?
> 
> Please choose [libapache2-mod-php7.3](https://packages.debian.org/buster/libapache2-mod-php7.3) over _php-fpm_ as a home user certainly.
> 
> Happy hacking.

Please provide your rationale. php-fpm is more flexible, the only reason to use mod php is because it’s easy to set up, requires less config.

---

<div class="post-metadata">

**Author:** ![andreas](https://help.nextcloud.com/letter_avatar/andreas/32/5_5575768a8748004e209b776fc1b2916d.png) [@andreas](https://help.nextcloud.com/u/andreas)\
**Post date:** [November 22, 2019, 4:35pm UTC](https://help.nextcloud.com/t/high-php-fpm-cpu-slow-response-after-upgrade/64670/11 "2019-11-22T16:35:42Z")

</div>

This thread has somewhat diverged from the original topic…  
I’d still appreciate hints on how to trace down the problem of the NC installation/code.

---

<div class="post-metadata">

**Author:** ![kesselb](https://help.nextcloud.com/user_avatar/help.nextcloud.com/kesselb/32/74519_2.png) [@kesselb](https://help.nextcloud.com/u/kesselb)\
**Post date:** [November 22, 2019, 4:42pm UTC](https://help.nextcloud.com/t/high-php-fpm-cpu-slow-response-after-upgrade/64670/12 "2019-11-22T16:42:31Z")

</div>

Have you tried to debug php-fpm with gdb/strace? Check [https://github.com/nextcloud/server/issues/17241](https://github.com/nextcloud/server/issues/17241) for some advice.

---

<div class="post-metadata">

**Author:** ![andreas](https://help.nextcloud.com/letter_avatar/andreas/32/5_5575768a8748004e209b776fc1b2916d.png) [@andreas](https://help.nextcloud.com/u/andreas)\
**Post date:** [November 22, 2019, 5:26pm UTC](https://help.nextcloud.com/t/high-php-fpm-cpu-slow-response-after-upgrade/64670/13 "2019-11-22T17:26:14Z")

</div>

Didn’t try gdb/strace so far, but just tried the slowdebug with request\_slowlog\_timeout=1, and getting a lot of hits. Quite often:

password\_verify() /var/www/nextcloud/lib/private/Security/Hasher.php:156

which is seems to be the same issue as [https://github.com/nextcloud/server/issues/17241](https://github.com/nextcloud/server/issues/17241) , so I’ll close this and continue there.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 4, 2024, 10:45am UTC](https://help.nextcloud.com/t/high-php-fpm-cpu-slow-response-after-upgrade/64670/14 "2024-12-04T10:45:29Z")

</div>



---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 11, 2024, 4:00pm UTC](https://help.nextcloud.com/t/high-php-fpm-cpu-slow-response-after-upgrade/64670/15 "2024-12-11T16:00:58Z")

</div>


