You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Karel Kubat <ka...@e-tunity.com> on 2007/06/19 16:56:46 UTC

Mod_proxy / mod_proxy_balancer question: How to take workers gracefully out of service

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

If someone has information on how to take balanced workers gracefully
out of service, please let me know! I've been searching the Apache
docs in vain, and Google doesn't provide an answer either. I've
posted this also to the user list, but no info there, so I'm hoping
to get lucky in the dev list. Thanks in advance!


THE PROBLEM

I am using mod_proxy to balance requests to two workers. The sessions
are made sticky using a cookie CellColor. This works like a charm, so
far no problems.

However, here's the problem. I will occasionally need to take a
worker out of service, but I will need to do so gracefully. The
procedure should be:
* I inform the balancer that the worker will go down eventually
* As for running sessions, the balancer keeps sending them to this
worker
* But new sessions all go to other workers, which are not marked as
"will go down"
* I simply wait for an hour or so, until running sessions to the
target worker die out
* Then I can stop the worker and service it.


THE CONFIGURATION

Here is the balancer configuration in a lab environment. There are
two sample wokers, at localhost:8010 and 8020 (the last two at 8000
and 8001 are hot-standby). Session stickiness is enforced as follows:
* In the webserver at localhost:8010 a cookie is added:
    Header add Set-Cookie CellColor=balancer.red
* And on 8020 it is:
    Header add Set-Cookie CellColor=balancer.blue

Listen                  8030
<VirtualHost            *:8030>
      # All URI's go through red or blue cell, sticky by CellColor
      # except for the purple manager
      ProxyPass           /purple-manager !
      ProxyPass           / balancer://purple/ stickysession=CellColor \
                            maxattempts=3 timeout=5

      # Web interface to the manager
      <Location           /purple-manager>
          SetHandler      balancer-manager
          Order           allow,deny
          Allow           from all
      </Location>

      # Tag for passing requests
      Header              add CellColor purple

      # The workers
      <Proxy              balancer://purple>
          BalancerMember  http://localhost:8010 route=red
          BalancerMember  http://localhost:8020 route=blue
          BalancerMember  http://localhost:8000 status=+H
          BalancerMember  http://localhost:8001 status=+H
      </Proxy>
</VirtualHost>


THE QUESTION

How do I take the worker at http://localhost:8010 gracefully out of
service, without interrupting already running sessions? Given the
above config, I can surf to http://localhost:8030/purple-manager and
set the "red" worker to "disabled", but if I do that, then all
requests will immediately go to the "blue" worker, even if there's a
cookie CellColor=balancer.red in the request. It looks as though
there are only two states ("enabled" or "disabled") while for what I
want there should be one more (something like: "working, but don't
use it").


Thanks in advance..
Karel


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (Darwin)

iD8DBQFGd+6v23FrzRzybNURAru3AKDE+jbSQqu4pQYjDZt+jVqsU5nYwgCgm/3+
x4r2EPDXKlvbrdS0E3wl5sQ=
=liab
-----END PGP SIGNATURE-----

Re: Mod_proxy / mod_proxy_balancer question: How to take workers gracefully out of service

Posted by Plüm, Rüdiger, VF-Group <ru...@vodafone.com>.
> -----Ursprüngliche Nachricht-----
> Von: Karel Kubat
> Gesendet: Dienstag, 19. Juni 2007 16:57
> An: dev@httpd.apache.org
> Betreff: Mod_proxy / mod_proxy_balancer question: How to take 
> workers gracefully out of service
> 
               8030
> <VirtualHost            *:8030>
>       # All URI's go through red or blue cell, sticky by CellColor
>       # except for the purple manager
>       ProxyPass           /purple-manager !
>       ProxyPass           / balancer://purple/ 
> stickysession=CellColor \
>                             maxattempts=3 timeout=5
> 
>       # Web interface to the manager
>       <Location           /purple-manager>
>           SetHandler      balancer-manager
>           Order           allow,deny
>           Allow           from all
>       </Location>
> 
>       # Tag for passing requests
>       Header              add CellColor purple
> 
>       # The workers
>       <Proxy              balancer://purple>
>           BalancerMember  http://localhost:8010 route=red
>           BalancerMember  http://localhost:8020 route=blue
>           BalancerMember  http://localhost:8000 status=+H
>           BalancerMember  http://localhost:8001 status=+H
>       </Proxy>
> </VirtualHost>
> 
> 
> THE QUESTION
> 
> How do I take the worker at http://localhost:8010 gracefully out of
> service, without interrupting already running sessions? Given the
> above config, I can surf to http://localhost:8030/purple-manager and
> set the "red" worker to "disabled", but if I do that, then all
> requests will immediately go to the "blue" worker, even if there's a
> cookie CellColor=balancer.red in the request. It looks as though
> there are only two states ("enabled" or "disabled") while for what I
> want there should be one more (something like: "working, but don't
> use it").
> 

Try

       <Proxy              balancer://purple>
           BalancerMember  http://localhost:8010 route=red lbset=0
           BalancerMember  http://localhost:8020 route=blue lbset=0
           BalancerMember  http://localhost:8000 status=+H lbset=0
           BalancerMember  http://localhost:8001 status=+H lbset=0
       </Proxy>

and then use the balancer manager to set the lbset
for http://localhost:8010 from 0 to 1. After it all sessions for this
worker died, disable it via the balancer manager.
For reactivation just enable it again and set lbset to 0.

Regards

Rüdiger