PHP Fpm process kills my site: process is blocked by D status

After several days of searching the Internet, the stack overflows, Google. Everywhere I can not understand what is happening with PHP-fpm after several hours of work.

Description of the problem:

I have Ubuntu 16.04 VPS where I installed PHP-FPM and Nginx and a small redis server to store sessions. I have 4 websites under PHP-fpm. All sites are good, only one of them has this problem.

PHP-FPM interacts with Nginx using sockets.

After the clock works fine, all of a sudden the PHP-FPM processes did not work and have the D status when I run the htop command. Here is a screenshot of the output of the htop command:

demonstration

After searching the Internet, I got that status D means that the process is waiting for the resource.

I added more memory for MySQL Server, but nothing happens. A MySQL server is great when I execute commands from Workbench or any other application.

Perhaps this is a memory problem?

I added memory for VPS, and now it works with 6 GB of memory (most of the memory is not used). PHP-FPMs continue to have D status after several hours of operation.

Perhaps this is due to open file descriptors?

I changed the number of open file descriptors to 2097152, which is a very large number. I keep getting the same issue.

Perhaps this is a socket problem or a Linux configuration problem?

I have increased most of the Linux configuration options as follows:

# Increase size of file handles and inode cache
fs.file-max = 2097152

# unix sockets accept by default 127 connections.
net.core.somaxconn = 4096

vm.swappiness = 0
vm.vfs_cache_pressure = 50

#Needed by redis
vm.overcommit_memory = 1

#
# 16MB per socket - which sounds like a lot, but will virtually never
# consume that much.
#
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216

# Increase the number of outstanding syn requests allowed.
# c.f. The use of syncookies.
net.ipv4.tcp_max_syn_backlog = 8192

But I have the same problem. This is what I get in the nginx log:

2016/07/17 22:57:30 [alert] 1885#1885: *59394 open socket #156 left in connection 117
2016/07/17 22:57:30 [alert] 1885#1885: *59341 open socket #107 left in connection 118
2016/07/17 22:57:30 [alert] 1885#1885: *59385 open socket #148 left in connection 119
2016/07/17 22:57:30 [alert] 1885#1885: *59392 open socket #154 left in connection 121

I tried most of the recommended solutions found on the Internet, but to no avail.

PHP-fpm.conf.

emergency_restart_threshold = 30
emergency_restart_interval = 180
process_control_timeout = 30

PHP-fpm:

pm = ondemand
pm.max_children = 30
pm.process_idle_timeout = 10s;
pm.max_requests = 500

nginx:

fastcgi_buffers 256 16k;
fastcgi_max_temp_file_size 0;

    location ~ ^/index\.php(/|$) {
        fastcgi_pass unix:/var/run/php5-fpm-mysite.com.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        internal;
    }

Nginx :

worker_processes 2;
worker_rlimit_nofile 100000;

pid /run/nginx.pid;

events {
        worker_connections 1024;
        multi_accept on;
}

. 2 Ubuntu 14.04, Ubuntu 16.04, . , .

Ocache , , , - , .

, .

: 50% . .

, PHP-fpm , , . nginx, . - .

, !

+4
2

Linux inodes, ...

.

Symfony2 Framework, "auto_generate_proxy_classes" true. .

auto_generate_proxy_classes true, Doctrine . , , php-fpm . , , .

:

:

doctrine:
    dbal:
        ....
    orm:
        auto_generate_proxy_classes: true.

Symfony2 :

doctrine:
    dbal:
        ....
    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
0

, . Symfony, PHP 5.6 Ubuntu 16.04 nginx/php-fpm.

, . "open socket #nnn left in connection" /var/log/nginx/error.log "server received pm.max_children" /var/log/php 5.6-fpm.log

Profitbricks AMD. , , Profitbricks, , - . , AMD Intel Xeon.

, XEON, , .

, (, , VPS), , , -.

0

Source: https://habr.com/ru/post/1648181/


All Articles