max listen queue listen queue len 区别

PHP-FPM connections are via a socket (TCP or file based). As such, PHP-FPM must ‘listen‘ on that socket, and then ‘accept’ connections.

Since there is a finite rate at which the connections can be accepted, it is possible, under high load for there to be a delay between the time a connection is initiated and the time it is accepted. Connections in that state are ‘queued’.

listen queue len: This defines the maximum number of connections that will be queued. Once this limit is reached, subsequent connections will either be refused, or ignored. As connections are accepted, the queue length will be reduced.

  • This value is set by the php-fpm per pool configuration option ‘listen.backlog’ (default: -1=unlimited).
  • Since sockets are being used, this value is also limited by the system value ‘net.core.somaxconn’ (default: 128 on most Linux systems).

Given the above, it stands to reason that:

  • listen queue: is the number of connections that have been initiated by not yet accepted
  • max listen queue: is the maximum value the listen queue has reached while php-fpm has been running.