How to work with PHP-FPM finalization state?

I have a website using NGINX and PHP-FPM. As you know, PHP-FPM has a status page for its pools with detailed information about these processes. My problem is that over time, many processes become “terminating” and do not change their “finish” state until I restart PHP-FPM.

The bad news is that the “finish” processes are considered active processes, and the number of active processes exceeds pm.max_children. Bad things are happening on my site.

I know some parameters of the php-fpm pool to kill idle processes, but I cannot find parameters to kill terminating processes after a certain time.

How to work with PHP-FPM finalization state? Is there a configuration option to kill these “finishing” processes after a while? Could this be the wrong configuration between NGINX and PHP-FPM? What are the reasons for the "completion" of states?

Here is a php-fpm status image. Reds end states, and this is what I'm trying to fix. The URI request is a different page on my site.

enter image description here

Thank you for your knowledge.

PD1: Now I reload PHP-FPM every 15 minutes, and it "fixes" a more or less clean state ... but I think this can be an important performance problem with a lot of traffic.

PD2: , , , , php-fpm, pid, .

+4
4

. :

PHP :

<?php
fastcgi_finish_request();
?>

php.ini:

auto_append_file = /path/to/your/file.php
0

. PD2 :

<?php

while (true) {
    $data_json = file_get_contents("http://localhost/fpmstatus?json&full");
    $data = json_decode($data_json, true);

    foreach ($data['processes'] as $proc) {
            if ($proc['state'] === "Finishing") {
                    $pid = $proc['pid'];
                    $duration = $proc['request duration'] / 1000000.0;
                    echo json_encode(compact("pid", "duration"));
                    if ($duration > 60) {
                            passthru("kill -9 " . $pid);
                            echo " KILLED\n";
                    } else {
                            echo "\n";
                    }
            }
    }
    echo count($data['processes']);
    echo "\n";
    sleep(30);
}

, error.log :

2017/08/06 13:46:42 [error] 20 # 20: * 9161 recv() failed (104: Connection reset by peer) , : 77.88.5.19, : hostname1, request: "GET/? p = 9247 HTTP/1.1", : "fastcgi://uni x:/run/php/php7.0-fpm.sock:", host: "hostname2"

, "hostname1", "hostname2" (). , . "" server_name _;, , , .

0

My server had the enablereuse = on parameter in the apache proxy setting. Removing this issue resolves the Completion issue.

Also indicated in the question: https://serverfault.com/questions/626904/php-fpm-state-finishing-but-never-completes

0
source

All Articles