-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Description
Description
Hi,
we have long standing problem with php-fpm 8.2 which forces us to stay on php8.1.
We experience random lockups of php-fpm daemon, which is caused by all child processes staying in D or R state and not finishing.
Our production machine was running Debian 11, which we updated to Debian 12 recently. It's amd64 architecture, running VM in vmware esxi 6.7 on Dell Poweredge servers. We use php packages from deb.sury.org repository.
Our test machine is Debian 11 with same settings, running on same server.
We are testing it on php 8.2.11 , but when we tried to switch to php8.2 initialy, it was version 8.2.3 , i believe.
I can reproduce it by running concurent load on 3 php-fpm pools under single master process:
- user1 (user1) - i run
ab -c 2 -t 1800 url1
, url1 has phpinfo() function in index.php - user2 (user2) - i run
ab -c 2 -t 1800 url2
, url2 has phpinfo() function in index.php - user3 (user3) - customer provided application written in Nette. It's used to upload image galleries. You select multiple images on your disk and it uploads them using separate ajax requests per image, resizes them using GD library and moves the images to final destionation on disk (i select around 20 images for upload)
When i start to upload the images while ab
processes are hitting the other users, our php-fpm locks up, here is process list from one of the test runs:
root 2605722 0.2 0.1 125060 6540 ? Ds 11:32 0:11 php-fpm: master process (/etc/php/8.2/fpm/php-fpm.conf)
www-data 2605723 0.0 0.1 125320 5896 ? S 11:32 0:00 \_ php-fpm: pool www
www-data 2605724 0.0 0.1 125320 5896 ? S 11:32 0:00 \_ php-fpm: pool www
user3+ 2605796 0.2 3.8 272720 153200 ? D 11:32 0:13 \_ php-fpm: pool user3
user3+ 2605797 0.2 3.8 272720 153988 ? D 11:32 0:13 \_ php-fpm: pool user3
user3+ 2605798 0.2 0.0 270648 3436 ? D 11:32 0:13 \_ php-fpm: pool user3
user3+ 2605799 0.2 3.5 270648 144800 ? D 11:32 0:13 \_ php-fpm: pool user3
user3+ 2605800 0.2 3.6 270648 147576 ? D 11:32 0:14 \_ php-fpm: pool user3
user3+ 2605801 0.2 3.4 270648 139888 ? D 11:32 0:13 \_ php-fpm: pool user3
user3+ 2605802 0.2 1.3 270648 55772 ? D 11:32 0:13 \_ php-fpm: pool user3
user3+ 2605807 0.0 0.5 270648 23072 ? S 11:32 0:01 \_ php-fpm: pool user3
user3+ 2605810 0.2 0.0 138032 3440 ? D 11:32 0:12 \_ php-fpm: pool user3
user3+ 2605814 0.2 0.1 140920 5064 ? D 11:32 0:12 \_ php-fpm: pool user3
user3+ 2605819 0.2 3.7 270672 151336 ? D 11:32 0:13 \_ php-fpm: pool user3
user3+ 2605822 0.2 0.0 268600 3864 ? D 11:32 0:13 \_ php-fpm: pool user3
user3+ 2605835 0.2 0.4 268600 18640 ? D 11:32 0:13 \_ php-fpm: pool user3
user3+ 2605841 0.2 3.4 268600 140204 ? D 11:32 0:13 \_ php-fpm: pool user3
user3+ 2605853 0.2 3.6 268600 147264 ? D 11:32 0:13 \_ php-fpm: pool user3
user3+ 2605861 0.2 3.6 268604 146504 ? D 11:32 0:13 \_ php-fpm: pool user3
user3+ 2605868 0.2 3.7 268600 149392 ? D 11:32 0:13 \_ php-fpm: pool user3
user3+ 2605871 0.0 0.4 138032 18000 ? S 11:32 0:00 \_ php-fpm: pool user3
user3+ 2605872 0.2 3.7 268600 150344 ? D 11:32 0:13 \_ php-fpm: pool user3
user3+ 2605875 0.2 0.0 133800 3628 ? D 11:32 0:12 \_ php-fpm: pool user3
user3+ 2605876 0.2 0.1 133800 4500 ? D 11:32 0:12 \_ php-fpm: pool user3
user3+ 2606291 0.3 7.0 402592 283984 ? D 11:34 0:16 \_ php-fpm: pool user3
user3+ 2606292 0.2 3.6 264536 146268 ? D 11:34 0:10 \_ php-fpm: pool user3
user3+ 2606891 0.2 0.1 125352 7100 ? D 11:35 0:11 \_ php-fpm: pool user3
user1 2607258 0.2 0.1 125352 6380 ? D 11:37 0:11 \_ php-fpm: pool user1
user2 2607261 0.2 0.1 125352 6696 ? D 11:37 0:11 \_ php-fpm: pool user2
user2 2607270 0.2 0.1 125352 7340 ? D 11:37 0:11 \_ php-fpm: pool user2
user2 2607287 0.2 0.1 125352 6092 ? D 11:37 0:11 \_ php-fpm: pool user2
user1 2607292 0.2 0.1 125352 6124 ? D 11:37 0:11 \_ php-fpm: pool user1
user2 2607294 0.2 0.1 125352 7336 ? D 11:37 0:11 \_ php-fpm: pool user2
root 2625624 0.2 0.2 125252 10548 ? D 12:43 0:02 \_ php-fpm: master process (/etc/php/8.2/fpm/php-fpm.conf)
You can see, there is some new child in the end unable to switch to it's final user.
When opcache is enabled , i can see this locks
lslocks | grep php
php-fpm8.2 2649780 POSIX READ 0 1 1 /tmp/.ZendSem.Rpie5w (deleted)
php-fpm8.2 2650194 POSIX READ 0 1 1 /tmp/.ZendSem.Rpie5w (deleted)
php-fpm8.2 2650192 POSIX READ 0 1 1 /tmp/.ZendSem.Rpie5w (deleted)
php-fpm8.2 2650212 POSIX READ 0 1 1 /tmp/.ZendSem.Rpie5w (deleted)
php-fpm8.2 2650213 POSIX READ 0 1 1 /tmp/.ZendSem.Rpie5w (deleted)
php-fpm8.2 2649782 POSIX READ 0 1 1 /tmp/.ZendSem.Rpie5w (deleted)
php-fpm8.2 2650238 POSIX READ 0 1 1 /tmp/.ZendSem.Rpie5w (deleted)
php-fpm8.2 2650267 POSIX READ 0 1 1 /tmp/.ZendSem.Rpie5w (deleted)
php-fpm8.2 2650195 POSIX READ 0 1 1 /tmp/.ZendSem.Rpie5w (deleted)
These locks are not there with opcache disabled.
When i try to run whole php-fpm inside strace, running the upload does not block the whole php-fpm, but child processes of user user3 slowly die out and no new processes are spawn.
When we use php8.1, with the same settings as in php8.2, we cannot lock it, it runs ok.
I tried to
- set
opcache.jit=0
, as suggested in JIT tracing - thundering herd causes lockup after opcache reset #11609 - set
opcache.enable=0
as second step - set
kernel.randomize_va_space=0
, as suggested in php-fpm master processes runs 100% CPU and keeps spawning new ones #12157 - set
pm=dynamic
instead ofpm=ondemand
No success with any of that, lock still occurs.
Our php ini modification is
[PHP]
short_open_tag = On
max_input_vars = 3000
max_input_time = 180
memory_limit = 256M
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE
post_max_size = 256M
upload_max_filesize = 256M
[mail function]
mail.add_x_header = On
[Session]
;session.use_strict_mode = 0
session.use_cookies = 1
;session.cookie_secure = 1
session.use_only_cookies = 1
session.cookie_httponly = 1
[opcache]
opcache.memory_consumption=512
opcache.interned_strings_buffer=64
opcache.max_accelerated_files=10000
;opcache.revalidate_freq=2
our fpm pool config is the same for all users (only socket path changes)
[user1]
user = user1
group = user1
listen = /var/run/php8.2-fpm-user1.sock
listen.owner = www-data
listen.group = www-data
pm = ondemand
pm.max_children = 30
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.process_idle_timeout = 60s;
pm.max_requests = 100
pm.status_path = /status
ping.path = /ping
chdir = /
security.limit_extensions = .php .phtml
I can add more information when asked.
Thanks
PHP Version
PHP 8.2.11
Operating System
Debian 11