0
votes

I'm trying to load-balance "2 Web Servers (running Apache/PHP)" by putting Nginx at in front of them. But i need to use Round Robin algorithm but when i do this, i can't manage to have the stable SESSIONS.

(I understand; if i use Round Robin, the SESSION information will be lost once i hit to the another Server on next load)

Is there a proper way to achieve this? Any kind advice for the industrial standards on this please?

FYI, i've already put these 2 Web Servers into GlusterFS as in Cluster. So i have a common storage (if you are going to suggest something based on this)

Thanks in advanced :)

2

2 Answers

1
votes

The nginx manual says that session affinity is in the commercial distribution only ("sticky" directive). If you don't use the commercial distribution, you'll have to grab a third-party "plugin" and rebuild the server with support

("sticky" should help you find the third party addons)

0
votes

If there isn't any specific reason for using Round Robin, you can try to use ip_hash load balancing mechanism.

upstream myapp1 {
    ip_hash;
    server srv1.example.com;
    server srv2.example.com;
    server srv3.example.com;
}

If there is the need to tie a client to a particular application server — in other words, make the client’s session “sticky” or “persistent” in terms of always trying to select a particular server — the ip-hash load balancing mechanism can be used.

Please refer to nginx doc for load_balancing for more information.