Hi Gabriel, Balance source won't work, since you'll see a single IP address: nginx's one. Well, as far as I understand, the chain is as below: user => nginx => HAProxy => php-fpm servers
I can see a couple of ways to achieve this: 1. using proxy protocol between nginx and haproxy, then you can use balance source (or better round robin + stick table based on src) 2. using a memcached or redis database where you can store your session information and share them between all your PHP-fpm servers. No more session persistence are required any more since any server would access any session information stored in the database at any time. That way you would be scalable. Note: you can load-balance memcached and redis with HAProxy as well (this is the purpose of my next blog article on Exceliance blog). Note: I would prefer the second option cheers On Mon, Oct 1, 2012 at 4:57 PM, Gabriel Sosa <[email protected]> wrote: > check http://haproxy.1wt.eu/download/1.4/doc/configuration.txt > > the "balance" directive. In your case I would use "balance source" > > source The source IP address is hashed and divided by the total > weight of the running servers to designate which server will > receive the request. This ensures that the same client IP > address will always reach the same server as long as no > server goes down or up. If the hash result changes due to > the > number of running servers changing, many clients will be > directed to a different server. This algorithm is generally > used in TCP mode where no cookie may be inserted. It may > also > be used on the Internet to provide a best-effort stickyness > to clients which refuse session cookies. This algorithm is > static, which means that changing a server's weight on the > fly will have no effect. > > hope helps. > > On Mon, Oct 1, 2012 at 10:27 AM, Fred Leeflang <[email protected]> wrote: >> Hi list, >> >> Our setup has only one (nginx) HTTP server which appears to be so fast >> that... we only need one :) >> >> We have some more php-fpm servers which are L4 monitored on port 9000 by >> haproxy. PHP FPM uses the fastcgi protocol so not HTTP. The browser does not >> get connected to php-fpm by haproxy, only nginx. >> >> How do I make sure that the browser ends up on the same php-fpm node (as I >> assume I cannot use 'cookie' here) >> >> Regards, >> Fred Leeflang >> > > > > -- > Gabriel Sosa > Sometimes the questions are complicated and the answers are simple. -- Dr. > Seuss >

