Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

The frontend of my web application is formed by currently two Apache reverse proxies, using mod_proxy_balancer to distribute traffic over a number of backend application servers. Both frontend reverse proxies, running on separate hosts, are accessible from the internet. DNS round robin distributes traffic over both. In the future, the number of reverse proxies is likely to grow, since the webapplication is very bandwidth-heavy.

My question is: how do I keep the state of both reverse balancers / proxies in sync?

For example, for maintenance purposes, I might want to reduce the load on one of the backend appservers. Currently I can do that by accessing the Balancer-Manager web form on each proxy, and change the distribution rules. But I have to do that on each proxy manually and make sure I enter the same stuff.

Is it possible to "link" multiple instances of mod_proxy_balancer? Or is there a tool out there that connects to a number of instances, and updates all with the same information?

Update: The tool should retrieve the runtime status and make runtime changes, just like the existing Balancer-Manager, only for a number of proxies - not just for one. Modification of configuration files is not what I'm interested in (as there are plenty tools for that).

share|improve this question
1  
I just started a bounty on this question. Anyone know of a better solution than each of us writing our own scripts? –  ConsultUtah Jun 2 '11 at 20:20

3 Answers 3

up vote 2 down vote accepted
+50

There is a ruby module name Amphibian which eases programatic access to the balancer-manager web interface. It may not have all the features you need, but you could add them or use it as an example to write a similar library in another language. Here is an example script that uses it to enable or disable user-specified backend appservers on two proxy balancers.

# amphibian_example.rb
require 'amphibian'

balancer_hosts = ["b1.example.com", "b2.example.com"]

command = ARGV.shift
backend_hosts = ARGV

balancer_hosts.each do |balancer_host|
    balancer_url = "http://#{balancer_host}/balancer-manager"
    balancer = Amphibian::BalancerManager.new(balancer_url)
    backend_hosts.each do |backend_host|
        backend_url = "http://#{backend_host}"
        if command == "enable"
            balancer.enable_host(backend_url)
            puts "Enabled #{backend_host} on #{balancer_host}"
        end
        if command == "disable"
            balancer.disable_host(backend_url)
            puts "Disabled #{backend_host} on #{balancer_host}"
        end
    end
end

This could be run like

$ amphibian_example.rb disable a1.example.com a5.example.com
Disabled a1.example.com on b1.example.com
Disabled a5.example.com on b1.example.com
Disabled a1.example.com on b2.example.com
Disabled a5.example.com on b2.example.com
share|improve this answer
    
Now, this is what I was after! –  Hank Jun 6 '11 at 8:06
    
Thanks sciurus. That is better, though it would be nice to have a web app to work with... –  ConsultUtah Jun 7 '11 at 18:54

I recently wrote a tool to do what you need. If it's too late, I hope it can be useful for somebody else. Project's name is ACM (Apache Cluster Manager) and it is available at : http://code.google.com/p/apache-cluster-manager/

Nicolas Maupu

share|improve this answer
    
+1 Definitely going to look into this! –  Henk Jun 25 '11 at 14:52

As I do not know of any tools allowing you to do this, my approach to this problem would be to create a script that goes on every server via SSH and does the modifications you want it to do.

This could be a very simple Python script but I imagine other scripting languages can do this rather easily as well. I would use tools such as sed to do the text modifications.

A more "rational" approach would be to use tools such as Chef or puppet to manage these configuration files but I have no experience with these (not a good thing !)

share|improve this answer
    
Thanks Antoine. The nodes are already managed by puppet. But for mod_proxy_balancer settings to take effect, an apache restart is necessary, which will impact ongoing long-running transactions. Therefore, modifying the configuration files is unfortunately not an option. I've added a clarification statement in my post. –  Hank Jan 31 '11 at 15:25
    
You have probably already thought of this but have you tried doing a reload or apache2ctl graceful ? –  Antoine Benkemoun Jan 31 '11 at 16:08
    
sorry for the late response. I can now confirm that an apache reload does not take in changes to the proxy config. apache2ctl graceful probably would, but that could take long since some of my users requests run over hours (long-running up/downloads). –  Hank Mar 9 '11 at 15:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.