Thanks, that does work! To me, it seems like the documentation is saying this should be the default behavior just by having http-keep-alive. But if it works, it works. Thanks!
On Tue, Feb 2, 2016 at 5:45 PM, Cyril Bonté <[email protected]> wrote: > Hi, > > > Le 02/02/2016 23:32, Nick Ramirez a écrit : > >> Greetings, >> >> I am trying to figure out why, in roundrobin mode, with http-keep-alive >> set (which should be the deafult anyway), the connection doesn't seem to >> be kept open to the backend server. >> >> Here is my HAproxy config where I've set the keep-alive timeout to 5 >> seconds: >> >> defaults >> timeout connect 5s >> timeout client 120s >> timeout server 120s >> timeout http-request 5s >> timeout http-keep-alive 5s >> option http-keep-alive >> >> frontend http >> mode http >> bind *:80 >> default_backend servers1 >> >> backend servers1 >> mode http >> balance roundrobin >> server web1 web1:80 check >> server web2 web2:80 check >> server web3 web3:80 check >> >> >> Using Wireshark, it looks like, from the client perspective, the client >> is reusing the same socket connection to HAProxy's frontend until the >> timeout expires. At least, I think so. Source port reports as "port 80" >> and destination port reports as some high numbered port, say 58000. And >> over subsequent refreshes during the timeout period, it keeps using >> those same ports. >> >> So the keep-alive appears to be working between client and frontend. >> >> However, I added an image to the Web page to see which backend server >> would serve it (my little test to make sure the connection to the server >> on the backend was being kept the same), and to see if it would be a >> different server than the one that served the HTML...and it was >> different. In roundrobin mode, two different backend servers served up >> content to the same client, even though I had keep-alive enabled. I >> changed the timeout period to be 25 seconds and, same behavior. >> > > As you don't use any persistance (cookie, stick tables, source balancing, > ...), it is a valid scenario : the connection is reused only if the > roundrobin algorithm choose the same server for the next request (which can > randomly happen depending on the traffic). > But, there is an option to tell haproxy should try to reuse the previous > server connection : option prefer-last-server > > > http://cbonte.github.io/haproxy-dconv/configuration-1.6.html#option%20prefer-last-server > > >> This all seems to me like keep-alive is not working between frontend and >> backend. Like, it keeps the connection between client and frontend, but >> not between frontend and backend. This is the behavior I would expect if >> I had set option http-server-close, but not when using option http-keep- >> alive which should keep the connection to the server open. >> > > > -- > Cyril Bonté >

