Loadbalanced apache web server with sticky sessions

Discussion in 'HOWTO-Related Questions' started by jorge.gonzalez, Jun 15, 2007.

  1. jorge.gonzalez

    jorge.gonzalez New Member

    Hi all!

    This is about Howto http://www.howtoforge.com/load_balancing_apache_mod_proxy_balancer

    It is supossed that, in byrequest mode, each request to main apache is switching between the two backend web servers and the session were still alive, isn't it? Then, why I have always been forwarded to the same backend apache? I mean, I tried with firefox, loged in wordpress testing app and, if I refresh page, then I'm again in the same backend web server. If I delete the cookie BALANCEDID then (maybe) the main apache forward me to the second backend server. What if backend apache is down? Does do failover?

    If I try with konqueror (or other PC) then I am able to access to the other backend web server.

    Then, the question is: Is the user always using the same backend web server and only the main apache switch between servers when there are different users?

    Sorry for my bad english ;-)

    thanks in advance
  2. jorge.gonzalez

    jorge.gonzalez New Member

    working 50% ok

    Well, I dont know why but reloading main apache web server it's working. But I see that if I stop one backend web server then all request go to the webserver which is up (failover ok)

    Then if I start the stopped web server, request are not going to this server any more unless main apache web server was reloaded
  3. jorge.gonzalez

    jorge.gonzalez New Member

    Answering myself

    As Apache mod_proxy says:

    retry 60 Connection pool worker retry timeout in seconds. If the connection pool worker to the backend server is in the error state, Apache will not forward any requests to that server until the timeout expires. This enables to shut down the backend server for maintenance, and bring it back online later.

    Then 1 minute without balancing (two servers), after 1 min everything works ok :)
  4. falko

    falko Super Moderator ISPConfig Developer

    No, if the requests were switching between the backend servers, then you'd lose the session. Therefore requests from one client always go to the same backend server (unless you delete the cookie on the client PC or use another browser on the client PC).


  5. jorge.gonzalez

    jorge.gonzalez New Member

    Then, I don't understand

    Falko, I can't realize what is going on. As I said I have 2 wordpress (wp1 & wp2) running on backend servers and one server acting as primary (wp), balancing requests.

    As you know wordpress has a login procedure with session and cookie. My primary server is balancing between backend servers and is keeping the session!!

    Now my browser is logged on wp1. If page is reloaded then I will be in wp2 and also logged. It's easy to see the alive session because I can access to site admin (link) whatever I were wp1 or wp2. If I log out then in both WP's there's no site admin link but login link

    Still more. Let's try
    I'm going to stop wp2 (now I'm on it) server while I'm logged: Ok, wp jumps to wp1 with the session alive because wp2 is down. 1 minute and wp2 will be up, then wp should to jump to wp2 and the session should be there.... Ok, wp2 is up and I wp is switching between wp1 & wp2 with the session.

    Let's try with wp1. Session logged. wp1 down, working with wp2. 1 minute later wp1 is up and wp is switching between 2 backend servers with the session still alive.

    How do you explain that?
  6. falko

    falko Super Moderator ISPConfig Developer

    Does WordPress store the sessions in the MySQL database? If so, and both WP installations use the same database, then you don't lose the session, even if you're switching between the backend servers.
  7. jorge.gonzalez

    jorge.gonzalez New Member

    That is

    Yes, WPs are working with the same DB and stores sessions in DB.
    Thanks Falko :)

Share This Page