A routine audit of Nginx error logs across a cluster of frontend nodes revealed an intermittent pattern of HTTP 502 Bad Gateway responses. The logs specifically recorded a resource temporarily unavailable error when connecting to the upstream socket. This generic message points towards a local network stack limitation rather than a PHP fatal error or execution timeout. These errors occurred precisely at midnight UTC daily. CPU load was nominal. Memory utilization was perfectly stable.
The application runsEros - Sex Shop & Lingerie Store WordPress Theme, utilizing PHP-FPM 8.2 and Nginx via UNIX domain sockets. The midnight UTC timestamp correlated exactly with the execution of the system logrotate daemon.
When logrotate triggers, it sends a USR1 signal to Nginx and a USR2 signal to PHP-FPM. PHP-FPM reloads its configuration and gracefully restarts its active worker pool. During this reload window, incoming requests are queued in the listening socket backlog. If the queue fills up, the kernel silently drops new connections, resulting in Nginx immediately returning a 502 error to the client.
I examined the current socket queue state using the ss utility.
ss -xlq | grep php-fpmThe output showed a Send-Q backlog limit of exactly 128.
This queue depth is dictated by two completely separate system parameters. First, the PHP-FPM pool configuration directive known as listen.backlog. Second, the operating system kernel network limit defined by net.core.somaxconn. The effective backlog size is always strictly the lesser of these two numerical values.
Checking the currently active kernel parameter:
sysctl net.core.somaxconnThe system returned 128. This is the default queue limit inherited directly from the base Linux distribution.
Unlike a standard Free Download WooCommerce Theme which might rely on an external managed database connection pool, this specific application stack processes complex product variation queries locally. The worker process startup time requires approximately 150 milliseconds. During a reload, if 150 requests arrive within that 150 millisecond window, the 128 slot queue is instantly exhausted.
The kernel network stack processes UNIX domain sockets quite differently than standard TCP sockets. There is no SYN retry mechanism present at this layer. When the socket backlog overflows, the connection is instantly rejected. Standard utilities will not increment TCP drop counters, completely masking the issue from basic monitoring tools. You must query the kernel directly to observe these hidden connection drops.
To quantify the exact number of rejected socket connections, we read the drops column from the raw proc filesystem interface.
cat /proc/net/unix | grep php-fpmThe non zero drop counter directly confirmed the socket overflow condition occurring exactly during the configuration reload phase.
To resolve this bottleneck permanently, both the kernel limit and the PHP-FPM configuration must be aligned to a much higher threshold to easily absorb the restart traffic spike. Apply the sysctl configuration file to the system.
# /etc/sysctl.d/99-network.conf
net.core.somaxconn = 4096Then update the FPM pool configuration.
; /etc/php/8.2/fpm/pool.d/www.conf
listen.backlog = 4096