Disabling keepalive

Maxim Dounin mdounin at mdounin.ru
Sun Oct 30 04:24:43 UTC 2022


Hello!

On Fri, Oct 28, 2022 at 09:01:27AM -0400, libresco_27 wrote:

> Thanks for your answer!
> I have another query if we can actually see that keepalive is being disabled
> in nginx logs. 
> Is it possible to confirm that if we run nginx in debug mode and if so, what
> kind of logs should I look for?

When keepalive with upstream servers is enabled, in the debug logs 
there will be "get keepalive peer", "get keepalive peer: using 
connection ...", "free keepalive peer", and "free keepalive peer: 
saving connection ..." messages when selecting a peer and 
finalizing upstream request.  For example, a connection attempt 
without a cached connection but with keepalive enabled will look 
like:

2022/10/30 07:18:31 [debug] 13406#100156: *1 http init upstream, client timer: 0
2022/10/30 07:18:31 [debug] 13406#100156: *1 kevent set event: 11: ft:-2 fl:0025
2022/10/30 07:18:31 [debug] 13406#100156: *1 http script copy: "Host"
2022/10/30 07:18:31 [debug] 13406#100156: *1 http script var: "u"
2022/10/30 07:18:31 [debug] 13406#100156: *1 http script copy: "Connection"
2022/10/30 07:18:31 [debug] 13406#100156: *1 http script copy: "close"
2022/10/30 07:18:31 [debug] 13406#100156: *1 http script copy: ""
2022/10/30 07:18:31 [debug] 13406#100156: *1 http script copy: ""
2022/10/30 07:18:31 [debug] 13406#100156: *1 http proxy header:
"GET / HTTP/1.0
Host: u
Connection: close

"
2022/10/30 07:18:31 [debug] 13406#100156: *1 http cleanup add: 21982D88
2022/10/30 07:18:31 [debug] 13406#100156: *1 init keepalive peer
2022/10/30 07:18:31 [debug] 13406#100156: *1 get keepalive peer
2022/10/30 07:18:31 [debug] 13406#100156: *1 get rr peer, try: 1
2022/10/30 07:18:31 [debug] 13406#100156: *1 stream socket 12
2022/10/30 07:18:31 [debug] 13406#100156: *1 connect to 127.0.0.1:8081, fd:12 #2
2022/10/30 07:18:31 [debug] 13406#100156: *1 kevent set event: 12: ft:-1 fl:0025
2022/10/30 07:18:31 [debug] 13406#100156: *1 connected

Without keepalive enabled there will be no "init keepalive peer" 
and "get keepalive peer" messages:

2022/10/30 07:21:36 [debug] 13416#100132: *1 http init upstream, client timer: 0
2022/10/30 07:21:36 [debug] 13416#100132: *1 kevent set event: 11: ft:-2 fl:0025
2022/10/30 07:21:36 [debug] 13416#100132: *1 http script copy: "Host"
2022/10/30 07:21:36 [debug] 13416#100132: *1 http script var: "u"
2022/10/30 07:21:36 [debug] 13416#100132: *1 http script copy: "Connection"
2022/10/30 07:21:36 [debug] 13416#100132: *1 http script copy: "close"
2022/10/30 07:21:36 [debug] 13416#100132: *1 http script copy: ""
2022/10/30 07:21:36 [debug] 13416#100132: *1 http script copy: ""
2022/10/30 07:21:36 [debug] 13416#100132: *1 http proxy header:
"GET / HTTP/1.0
Host: u
Connection: close

"
2022/10/30 07:21:36 [debug] 13416#100132: *1 http cleanup add: 21982D88
2022/10/30 07:21:36 [debug] 13416#100132: *1 get rr peer, try: 1
2022/10/30 07:21:36 [debug] 13416#100132: *1 stream socket 12
2022/10/30 07:21:36 [debug] 13416#100132: *1 connect to 127.0.0.1:8081, fd:12 #2
2022/10/30 07:21:36 [debug] 13416#100132: *1 kevent set event: 12: ft:-1 fl:0025
2022/10/30 07:21:36 [debug] 13416#100132: *1 connected

Hope this helps.

-- 
Maxim Dounin
http://mdounin.ru/



More information about the nginx mailing list