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.

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.


Reply via email to