I'm trying to set up HAProxy to send all .php pages to a linux server, and
all .aspx pages to a Windows server, for a single website. I've been trying
this with Pound, nginx, etc just to try and chose a new load balancer
software to go with. So far I'm really impressed with the depth of HAProxy's
configuration options, and the httpchk health check is very cool compared to
just a dumb connection check which Pound and Nginx are stuck with, but I'm
having trouble figuring something out.
With the config below if I go to /test.php it sends it to the Linux server just fine. If I wait a while and go to /test.aspx it sends it to the Windows server just fine. But if I try both of them back to back, some sort of persistence is messing up the 2nd request... i.e. I go to /test.php and hit the Linux box, then if I go to /test.aspx immediately it still sends me to the Linux box instead of the Windows one.
I tried commenting out the defaults option persist and redispatch but that didn't help, maybe I need to do no persist / no redispatch I guess? I tried using separate cookie names instead of just using SERVERID in all the backends but that didn't really help.
The thing is I don't want to disable persistence completely, i.e. if this setup had 10 backend windows servers and 10 linux servers, I'd like each backend section to keep track of its own persistence separately... So if you hit /test.php and /test.aspx back to back repeatedly you'd keep going to the same Linux and Windows server.
I tried setting up the 'stats' option as well and it had similar issues. If I set up a stats backend, and hit /stats right off the bat they'd show up ok, but as soon as I went to another test page and got sent to a linux or windows server the /stats page would then break.
Thanks, and my apologies if this has been asked a million times!
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 4096
chroot /usr/share/haproxy
user nobody
group nobody
daemon
#debug
#quiet
defaults
log global
mode http
option httplog
option dontlognull
option persist
option redispatch
retries 3
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000
backend Site01-windows
mode http
balance leastconn
cookie WINID insert indirect
option httpchk HEAD /index.html HTTP/1.0
server TestWin01 10.99.99.125:80 cookie Win01 check fall 2
backend Site01-linux
mode http
balance leastconn
cookie LINID insert indirect
option httpchk HEAD /index.html HTTP/1.0
server TestLin01 10.99.99.100:80 cookie Lin01 check fall 2
backend Site01-both
mode http
balance roundrobin
cookie SRVID insert indirect
option httpchk HEAD /index.html HTTP/1.0
server TestWin01 10.99.99.125:80 check fall 2
server TestLin01 10.99.99.100:80 check fall 2
listen Site1HTTP 10.99.99.200:80
mode http
acl url_aspx path_end .aspx .asp .asmx
acl url_php path_end .php .phps
use_backend Site01-windows if url_aspx
use_backend Site01-linux if url_php
default_backend Site01-both
Received on 2009/04/28 00:11
This archive was generated by hypermail 2.2.0 : 2009/04/28 00:15 CEST