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:

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:
fs.file-max = 2097152
net.core.somaxconn = 4096
vm.swappiness = 0
vm.vfs_cache_pressure = 50
vm.overcommit_memory = 1
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
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
2016/07/17 22:57:30 [alert] 1885
2016/07/17 22:57:30 [alert] 1885
2016/07/17 22:57:30 [alert] 1885
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, . - .
, !