Php-fpm hangs when playing large video files

Nextcloud version (eg, 18.0.2): 18.0.3
Operating system and version (eg, Ubuntu 20.04): Ubuntu 18.04
Apache or nginx version (eg, Apache 2.4.25): Nginx 1.17.9
PHP version (eg, 7.1): php-fpm 7.2

The issue you are facing: When playing a large mp4/mov/etc., php-fpm hangs (with 10 or so children) with 50% io wait. Video then buffers when skipping/normal playback. However, when downloading the file, it will saturate a 1 gbit line without much/any io wait.

When closing the video, php-fpm continues to hang for about 30 seconds (rendering Nextcloud unusable). This will happen on both SSD and HDD.

Is this the first time you’ve seen this error? (Y/N): Nope, always been this way.

Steps to replicate it: playing a 1gb+ video regardless of format.

I know a few people were having this issue, of which went largely unsolved. Any ideas? Suggestions? Thanks!

Same occurs when using nextcloud snap, which internally also uses php fpm. What I can observe is even more extreme: If you try to jump forward in the video while playing large (and sometimes even small) videos, it can reliably “crash” my mounted hard drive. And by crash I mean the whole /data directory simply vanishes. Once I reboot the server, the dir is back again with all the files still intact.

This does not seem to be an issue with the drive or the OS, as opening and playing the video directly from the hard drive works fine. Also starting a web server and then streaming the video works fine.

There seem to be some serious IO errors being caused by nextcloud trying to stream video content to the browser (or any client).

I have the same issue using docker (Linux server image)

I also always had this same issue. Been using Nextcloud since 2016. First on an x86 linux machine, and now on Arm RPi 4 for the last couple of years. I switched to using Nginx a couple of years ago because I had heard that it was less resource heavy than Apache primarily due to this issue, however it still remains. I’ve always held hope that a PHP or Python or Nginx update might eventually resolve this, but alas it remains.


i have the same problem. There are any new information about this problem?

Nextcloud version: 24.0.6
Operating system and version: Linuxmint 21 Vanessa
Apache or nginx version: apache 2.4.52
PHP version : php 8.1.2

I can confirm that this issue still persist. When playing the video (no matter the size) php-fpm just hangs. After 30-50 seconds, the proccess occupy around 80-100 cpu time.
Any potential fix?

Best regards!

Nextcloud 25.0.2 php-fpm, same problem :frowning:

Can you check if switching php-fpm to ondemand mode fixes this?

I tested with ondemand.

It does prevents php-fpm from running out of threads/processes, however more just get spawned and eventually the CPU usage floods the server. I tested this on a 32core Epyc with 128Gb ram on a 10Gbit network. Video is very large; multi GB high bitrate mov.

I noticed that the WebDav backend is chunking the data to the video player sending HTTP 206, however it’s very slow and cannot keep up with the playback.

Downloading the video file through NC is almost at wire speed with near zero CPU utilization.