views:

176

answers:

1

I was wondering if anyone has used HAProxy for sharding. Specifically, I would like to be able use a cookie I define w/a identifier and have any client that presents that cookie/identifier combination be directed to the same server. It seems possible and my preliminary tests seem to work but I am not a sure.

My listen configuration looks like:

listen  appli1-rewrite 0.0.0.0:80
cookie  mysession= prefix
balance roundrobin
server  app1_1 192.168.0.1:80 cookie server01
server  app1_2 192.168.0.2:80 cookie server02

option  httpclose

However, when I look at the request headers using Live Http Headers I don't see the mysession cookie indicating which server it will be going to, which is what I expected based on the prefix operation. I am quite new to HAProxy so any help/guidance would be great!

A: 

According to the HAProxy docs I think you need to tweak your haproxy config a little, to have it insert the cookie:

According to:

http://haproxy.1wt.eu/download/1.2/doc/architecture.txt

You need something like:

cookie SERVERID insert indirect

Cody Caughlan