- Assuming Linux unix sockets, the pending connections can seen with ss (package: iproute2) and netstat (package: net-tools).
Using ss;
$ ss -lf unix src /run/php\*
will show output like
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
u_str LISTEN 5 4096 /run/php/php7.4-fpm.sock 7082746 * 0
Netstat, instead, will show a list:
$ netstat -xpa | grep -E "^(Active|Proto)|php"
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 7066676 1021364/php-fpm: ma /run/php/php7.4-fpm.sock
unix 3 [ ] STREAM CONNECTED 7068154 1021391/php-fpm: po /run/php/php7.4-fpm.sock
unix 3 [ ] STREAM CONNECTED 7067205 1021406/php-fpm: po /run/php/php7.4-fpm.sock
unix 3 [ ] STREAM CONNECTED 7067203 1021407/php-fpm: po /run/php/php7.4-fpm.sock
- Latency.
This isn't so straightforward; There are 2 approaches, benchmarking and logging.
Benchmarking can use a wide variety of tools, for example apache bench or siege
Example ab usage:
$ ab -c 50 -n 100 "http://hp/delay.php"
will open 50 simultaneous connections and make 100 requests (2 each).
I produces useful output like:
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 2 1.5 2 4
Processing: 1002 2079 716.5 2010 3130
Waiting: 1002 2079 716.5 2010 3129
Total: 1004 2081 716.9 2011 3133
Percentage of the requests served within a certain time (ms)
50% 2011
66% 2121
75% 2998
80% 3005
90% 3013
95% 3120
98% 3127
99% 3133
100% 3133 (longest request)
Siege is similar:
$ siege -c 200 -r 2 -d 0 --no-parser "http://hp/delay.php"
** SIEGE 4.0.4
** Preparing 200 concurrent users for battle.
The server is now under siege...
Transactions: 400 hits
Availability: 100.00 %
Elapsed time: 10.29 secs
Data transferred: 0.01 MB
Response time: 4.58 secs
Transaction rate: 38.87 trans/sec
Throughput: 0.00 MB/sec
Concurrency: 178.12
Successful transactions: 400
Failed transactions: 0
Longest transaction: 7.27
Shortest transaction: 1.00
Logging, otherwise, records the real delays and latencies for each request.
In Apache 2.4.13 and later Logging, there's a logging directive "%^FB", giving elapsed microseconds between when the request arrived and the first byte or backend output. Another option would be to use "%{begin:msec}t %{end:msec}t" in the custom log string.
Yet another source of information is PHP's fpm_get_status()23.
A simple use of this information would be:
echo '<pre><?php print_r(fpm_get_status());' > /var/www/html/testfpmstatus.php
$ curl http://localhost/testfpmstatus.php
<pre>Array
(
[pool] => www
[process-manager] => dynamic
[start-time] => 1659800269
[start-since] => 72
[accepted-conn] => 2
[listen-queue] => 0
[max-listen-queue] => 0
[listen-queue-len] => 0
[idle-processes] => 9
[active-processes] => 1
[total-processes] => 10
[max-active-processes] => 1
[max-children-reached] => 0
[slow-requests] => 0
[procs] => Array
(
[0] => Array
(
[pid] => 1024097
[state] => Idle
[start-time] => 1659800269
[start-since] => 72
[requests] => 1
[request-duration] => 479
[request-method] => GET
[request-uri] => /testfpmstatus.php
[query-string] =>
[request-length] => 0
[user] => -
[script] => -
[last-request-cpu] => 0
[last-request-memory] => 2097152
)
[1] => Array
See Also: