nginx taking too long to respond

mrgonza78 nginx-forum at
Fri Jul 16 18:54:29 UTC 2021

I have an nginx used mainly as a reverse proxy for a couple of upstream
services. This nginx has a simple endpoint used for health checks:

    location /ping { return 200 '{"ping":"successful"}'; }

The problem I'm having is that this ping takes too long to be responded:

    $ cat /proc/loadavg; date ; httpstat localhost/ping?foo=bar
    2.93 1.98 1.94 8/433 16725
    Thu Jul 15 15:25:08 UTC 2021
    Connected to from

    HTTP/1.1 200 OK
    Date: Thu, 15 Jul 2021 15:26:24 GMT
    X-Request-ID: b8d276b0b3828113cfee3bf2daa01293

      DNS Lookup   TCP Connection   Server Processing   Content Transfer
    [     4ms    |       0ms      |      76032ms      |        0ms       ]

That ^ is telling me that the average load is low at the time of the request
(2.93 the 1m average load for an 8-core server is ok)

Curl/httpstat initiated the request at 15:25:08 and response was obtained
15:26:24. Connection was stablished fast, request sent, then it took 76s for
the server to respond.

If I look at the access log for this ping I see "req_time":"0.000" (this is
the $request_time variable).


This is the access log format in case anybody wonders what are the rest of
the values:


My question is: where could nginx have spent these 76s if the request just
took 0s to be processed and responded?

Something special to mention is that the server is timing out a lof of
connections with the upstreams at that moment as well: we see a lot of
upstream timed out (110: Connection timed out) while reading response header
from upstream and upstream server temporarily disabled while reading
response header from upstream.

So, these two are related, what I can't see is why upstream timeouts would
lead to a /ping taking 76s to be attended and responded when both cpu and
load are low/acceptable.

Any idea?

Posted at Nginx Forum:,292073,292073#msg-292073

More information about the nginx mailing list