Hot opensource news

Apache BalancerMember mod_proxy, try to be smooth

In my devops life, one of my customer ask to have the possibility to update one by one his java workers but without interuption. They are java workers behind an apache. Apache load balance request between the workers with mod proxy ajp.

The goal was to :

  1. Remove one of both tomcat server from the apache balancer proxy.
  2. Do whatever on this tomcat (upgrade code, change parameter, …)
  3. Add again the tomcat

How can we remove/add a worker in the apache proxy mod ? The first ideas was :

  • Stop worker (service tomcat stop) ?
  • Add iptables rules to  ?
  • Edit vhost configuration, remove membre, reload ?

But it is difficult to never interupt a request. So I want share a tip about BalancerMember from apache mod_proxy (and proxy_balancer).

I wrote a little python script to do remove a balancer member from the apache proxy without requetes interruption.

You can find my script here

How to

To run that script you need to setup standard python-argparse arg parse package :

apt-get install python-argparse

And then, if you need a specific servername (host) or ip to manage your apache mod proxy, you should edit following lines

#vhost name / header
headers = {"Host": '' }
#ip to reach apache
That it’s : 
usage: [-h] [-l] [-a ACTION] [-w WORKER]

optional arguments:
  -h, --help            show this help message and exit
  -l, --list            List Worker member and status
  -a ACTION, --action ACTION
                        "enable" or "disable" the specified Worker
  -w WORKER, --worker WORKER
                        Worker name : example ajp://
Now we will look how use it in a real usecase.


Context : We need update an application on each webserver without interuption


We currently have Apache proxy with 2 members. Each members are running the old version of our customer application.


 ./ -l
    Worker                                   | Status     | Elected   
    ajp://                   | Ok         | 1        
    ajp://                   | Ok         | 2
balancer members list

We removed the first web to perform an update of the application



./ -w ajp:// -a disable
    Worker                                   | Status     | Elected   
    ajp://                   | Dis        | 0         
    ajp://                   | Ok         | 0 
Disable web1

Enable the first web At this state we have removed web1 from the balancer and our customer have upgraded his application. Next step : Re enable web1 in the load balancer.



./ -w ajp:// -a enable
    Worker                                   | Status     | Elected   
    ajp://                   | Ok         | 0         
    ajp://                   | Ok         | 0
enable web1

We now balance between an old version of the application and new at the same time. We have proceed an upgrade on one tomcat without interrupt the service. Next step do the same thing on web2. Remove the second web and upgrade the application


./ -w ajp:// -a disable
    Worker                                   | Status     | Elected   
    ajp://                   | Ok         | 0         
    ajp://                   | Dis        | 0
disable web2

The two webs are upgraded, But web2 still remove from the loadbalancer. So finally add the last member into the apache proxy.


./ -w ajp:// -a enable
    Worker                                   | Status     | Elected   
    ajp://                   | Ok         | 0         
    ajp://                   | Ok         | 0
enable web2

We just upgraded 2 webs without request interuption. Smooth upgrade 😉



talset on Githubtalset on Linkedin

, , , , ,

3 thoughts on “Apache BalancerMember mod_proxy, try to be smooth

  • DeetSl says:

    Hi there! I simply wish to give a huge thumbs up for the great data you will have right here on this post. I might be coming again to your blog for extra soon.

  • rok says:

    Hello big thank you for posting this content ! moreover i would like to know which tool do you use to create all the illustration and image ? i realy like the way it look , i hope you can help . Thanks


    • gaelL says:


      Sorry for this verrrrrry late answer. But we are using inkscape for all schema.

      It’s kind of manual draw based on quite lot of free svg images that you can find for example here :

      We change little bit colors and sometime add sofrware logo on it.

Leave a Reply

Your email address will not be published. Required fields are marked *