HAProxy connection pooling & timeouts

After looking through the documentation and testing I’m confused regarding how HAProxy is supposed to work and need some help. I will describe the issue as simple as possible:

haproxy -v
HA-Proxy version 2.0.2 2019/07/16 - https://haproxy.org/

This article HAProxy 1.9 Has Arrived

States the following:

In addition, HAProxy now provides connection pooling. Idle connections between HAProxy and the server are no longer closed immediately if the frontend connection vanishes.

In testing (using http-reuse always) and HTTP/1.1 I find that HAProxy keeps “IDLE” connections in the connection pool only for the timeout configured for “timeout client”. After the “timeout client” HAProxy waits 5 more seconds and then closes the connection with the backend server.

Questions

  • Is the above analysis correct and that is how HAProxy connection pooling works using “http-reuse always” and HTTP/1.1?
  • Is it possible to specify a timeout other than “timeout client” that controls how long “IDLE” connections are kept in the connection pool?

I specifically called out “timeout client” because using the following configuration only it kept the connection to the backend server alive for the specified duration.

global
        user haproxy
        group haproxy
        daemon
        nbproc 1
defaults
        mode http
        timeout connect 5s
        timeout client 20s
        timeout server 35s
        timeout http-request 50s
        timeout http-keep-alive 300s

frontend myfrontend
        bind 192.168.1.20:80
        default_backend mybackend

backend mybackend
        http-reuse always
        server Server1 192.168.1.30:5003

Using the above configuration use a client that makes a HTTP/1.1 call and keeps the connection “IDLE” and you will find that HAProxy closes the connection after “25 seconds”.