Thanks for the replies ;) @Malcom : As for the SPOF, my http traffic is routed to a Virtual IP, which point on one of two servers that have HAProxy configured, and HAProxy do some LB on two other webservers. So if one HAProxy fails, I can change my VIP to point on the other HAProxy server. (Also it's not a true vip and a manual operation is required, but considering what it actually cost, it's not bad)
@Guillaume : Thanks for the explanation, I didn't get the fact that HAProxy inserted one cookie ! I agree, I don't trust the application either ;) Thomas. On Fri, Mar 11, 2011 at 18:14, Guillaume Bourque < [email protected]> wrote: > Thomas, > > I'm no expert here and In our case we don't truss the application ;-) > > So the proposed config will insert a cookie base on the name of the web > server for us (put anything you want) and a returning visitor will end on > the same backend base on the haproxy cookie previously inserted. > > Now I'm sure haproxy can intercept the application cookie and send it to > the same server, but you will have to test that and look at the doc ;-) > > Also in haproxy log you will have all the info for each session, where it > was balance and if a cookie was present or inserted ... > > From the doc in the log section search for this: > > the third character tells whether the persistence cookie was provided > by the client (only in HTTP mode) > > > Good luck > > > > 2011/3/11 Manson Thomas <[email protected]> > >> Ok that's exactly what I wanted to do. >> >> >> The default cookie name in PHP is >> session.name = PHPSESSID >> >> Is it this cookie name that I should set in HAProxy config ? >> >> Thomas. >> >> On Fri, Mar 11, 2011 at 4:55 PM, Guillaume Bourque < >> [email protected]> wrote: >> >>> Hi Thomas, >>> >>> We do it like this, haproxy add a cookie, and base on the cookie it will >>> send it to teh same web server >>> >>> I'm no haproxy expert but it work for us with a very basic php >>> application. >>> >>> here are the related config in our haproxy >>> >>> >>> backend bk-prod >>> balance roundrobin >>> cookie SERVERID insert indirect nocache >>> server lb10-3w-101 172.21.11.101:80 cookie lb11-3w-101 >>> check inter 5s fall 3 maxconn 200 weight 20 >>> server lb10-3w-102 172.21.11.102:80 cookie lb11-3w-102 >>> check inter 5s fall 3 maxconn 200 weight 20 >>> >>> >>> This will load balance in a round robin way but a second pass from the >>> same visitor will end up on the same server which will do what you want. >>> >>> Good luck ! >>> >>> >>> >>> 2011/3/11 Thomas Manson <[email protected]> >>> >>> Hi Gabriel, >>>> >>>> I've read that HAProxy is capable of keeping a set of http request >>>> directed to the same webserver. (I think the feature is called 'Sticky >>>> Session' on Websphere Cluster) >>>> >>>> I've seen this in the documentation : >>>> >>>> appsession <cookie> len <length> timeout <holdtime> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> [request-learn] [prefix] [mode <path-parameters|query-string>] >>>>> * Define session stickiness on an existing application cookie.* >>>>> >>>>> >>>> I'm just looking for some howto/best practices on this subject. >>>> >>>> Also the shared session with memcache can be a valid option. (I've to >>>> dig this subject). >>>> >>>> So, can anyone confirm that it's possible or not possible to have a >>>> "sticky session" feature with HAProxy ? >>>> If possible : howto/best practice? >>>> If not : well I'll try the memcache solution ;) >>>> >>>> Thanks for your help, >>>> Regards, >>>> Thomas. >>>> >>>> >>>> >>>> >>>> On Fri, Mar 11, 2011 at 16:19, Gabriel Sosa <[email protected]>wrote: >>>> >>>>> this is not an HAProxy related problem >>>>> >>>>> What you need is to share the session across all webservers. You have >>>>> several ways to do it: memcache, redis, db, filesystem. >>>>> >>>>> We currently are using memcache for this >>>>> >>>>> check your php.ini for "session.save_handler" >>>>> >>>>> we have something like: >>>>> >>>>> session.save_handler = memcache >>>>> session.save_path = >>>>> "tcp://mmc-server-01:11211,tcp://mmc-server-02:11211" >>>>> >>>>> some more info: http://php.net/manual/en/session.configuration.php >>>>> >>>>> Once you do this, haproxy will keep using the same algorithm to >>>>> balance but webservers will be able to find/reuse the session users were >>>>> on. >>>>> >>>>> Saludos >>>>> >>>>> >>>>> >>>>> On Fri, Mar 11, 2011 at 11:37 AM, Thomas Manson < >>>>> [email protected]> wrote: >>>>> >>>>>> Hi, >>>>>> >>>>>> I've setup HAProxy to loadbalance the traffic across two web servers >>>>>> that runs some PHP website (based on JOOMLA, OSCommerce and some other >>>>>> solution) >>>>>> >>>>>> However I've noticed that the session affinity is not working Out Of >>>>>> The BOX (which after 2sec of think is quite logical ;)) >>>>>> >>>>>> Does anybody have some pointers to configure HAProxy (and if >>>>>> necessary PHP) to make this work ? >>>>>> >>>>>> Thanks, >>>>>> Thomas. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Gabriel Sosa >>>>> Si buscas resultados distintos, no hagas siempre lo mismo. - Einstein >>>>> >>>> >>>> >>> >>> >>> -- >>> Guillaume Bourque, B.Sc., >>> consultant, infrastructures technologiques libres >>> Logisoft Technologies inc. http://www.logisoftech.com >>> <514%20576-7638>514 576-7638, >>> http://ca.linkedin.com/in/GuillaumeBourque/fr >>> >>> >> > > > -- > Guillaume Bourque, B.Sc., > consultant, infrastructures technologiques libres > Logisoft Technologies inc. http://www.logisoftech.com > 514 576-7638, http://ca.linkedin.com/in/GuillaumeBourque/fr > >

