php / php/php-src

FPM improve listen queue status info

Open
#9,943 3 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature SAPI: fpm
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

Currently tcp_info structure is used to get information about listen queue that is then shown in FPM status. It uses tcpi_unacked (or __tcpi_unacked on FreeBSD or NetBSD) for current listen queue status value and tcpi_sacked (or __tcpi_sacked on FreeBSD or NetBSD) which is used for max listen queue and listen queue length. The queue length is however just approximation (at least on Linux) expecting that maximum is reached which is often not the case on modern Linux kernl (one of the example is a bug #76323). In addition this works only for inet socket but doesn't work for unix domain socket as mentioned in bug #80739.

The solution for this on Linux is to use netlink with sock_diag. It brings some challenges (like keeping inode number for the socket) but provides the required info and more. We could consider using libnl but that might not be a good idea as it would require an explicit non default dependency so it might not be always available (e.g. when FPM is compiled without it).

The FreeBSD should probably prefer the SO_LISTENQLIMIT, SO_LISTENQLEN and SO_LISTENINCQLEN (for UDS) to get the required info as those options are specifically meant to be used for this and tcp_info is quite undocumented there. It also can provide the info for unix domain socket as mentioned.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how FPM status currently obtains listen queue values through tcp_info, then compare the Linux netlink sock_diag approach with FreeBSD's SO_LISTENQLIMIT, SO_LISTENQLEN, and SO_LISTENINCQLEN options. Done means accurate listen queue status for inet and Unix domain sockets without requiring a mandatory libnl dependency.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.