User Guide - mod_proxy_balancer


Applicable Plans: All Standard VPS, all Advanced VPS, all Premier VPS plans

Mod Proxy Balancer is an Apache module designed to add load balancing and fail-over functionality to the Apache Mod Proxy module. At present, there are 2 load balancer scheduler algorithms available for use: Request Counting and Weighted Traffic Counting. Mod Proxy Balancer become available with Apache HTTPD 2.2. This User Guide is not intended to be a full explanation of the features of this module. For complete documentation, see the links to other information sources that are provided at the end of the document.

Mod Proxy Balancer is only available in eApps hosting plans that are running the CentOS 5 or greater version of the operating system. To see what version you are running, login to your Control panel, click on My Account tab, then Subscriptions icon, then your Subscription. The Operating System version will be at the top.

Simple examples of using Apache Mod Proxy

This section will explain how to use Apache Mod Proxy in your eApps Hosting environment.

  1. When we should use Apache Mod Proxy

  2. Configuring Apache Mod Proxy

1. When we should use Apache Mod Proxy

There are common situations when we want to expose only some specific parts of a non-Apache Web application (Ruby, Tomcat, Jboss, even another Apache server) to the outside world. With Apache Mod Proxy at reach we can do this quite easily through Apache. Of course, there are several ways to accomplish this, but in this document we will talk about how can this be done with Apache Mod Proxy, and we will also outline the benefits of using it.

2. Configuring Apache Mod Proxy

Apache Mod Proxy is already available in the Apache installation on your VPS, so yo will not need to install anything else. However, there are no default directives added so once you have an application you want to expose through Apache Mod Proxy you will have to add some custom configuration directives to the Apache Web Server running in your VPS.

Let's consider a particular case of a Ruby application we want to make available through Apache Mod Proxy in the following environment:

In this example we will assume that the Ruby application is correctly configured and the Ruby server is running without issues on port 3000 on the same VPS. You will need to specify custom Apache configuration directives to tell the Apache server to feed the content from your Ruby application. The directives should be entered into the Custom Settings tab of the Website settings area on the Site tab of your control panel.  In our example, we would navigate to the Custom Settings tab in the Control panel and enter the following directive:

ProxyPreserveHost on
ProxyPass /my1stapp/ http://localhost:3000/

This will make the content from localhost port 3000 available at http://yourwebsite/my1stapp/. Please note that the ProxyPreserveHost on directive has to be added only once per each web site configuration.

Configuring Mod Proxy Balancer

In this section we will understand the differences between the Mod Proxy configuration directives and the Mod Proxy Balancer configuration directives.

1. What is Apache Mod Proxy Balancer suitable for

There are common situations when we want to expose the same applications as we talked before, but for performance and reliability reasons we run several instances of them, eventually on several application servers. The Apache Mod Proxy balancer sends keep-alives to the application servers it is configured to get the content from and figures out automatically and in a quite reasonable amount of time if one application server is down or stuck. Another benefit is that using multiple instances of the same application you can provide 100% uptime even when upgrading your applications (shutdown one instance, upgrade it, start it back, repeat the maintenance procedure for the second, third, ..., nth one).

2. Differences between Mod Proxy and Mod Proxy Balancer configuration directives

In the following example we aim to provide the same functionality to our Web Server as we did for the my1stapp application in the configuration example above. Again, the directives need to be entered in the Custom Settings tab in the Website settings area on the Site tab for the site you want to configure.

ProxyPreserveHost on
<Proxy balancer://my1stapp>
BalancerMember http://localhost:3000/
</Proxy>
ProxyPass /my1stapp/ balancer://my1stapp/


Again, ProxyPreserveHost on in this directive has to be added only once per each web site configuration

3. Using Mod Proxy Balancer load balancing and fail-over capabilities

In the above example we have configured a Mod Proxy Balancer having just one member, so this configuration provides exactly the same functionality as the previous example. At this point only the configuration directives differ and if we have only one balancer member it doesn't make much sense to use this configuration. But if we add another balancer member we can take advantage of the load balancing and fail-over capabilities of the Apache Mod Proxy Balancer module:

ProxyPreserveHost on
<Proxy balancer://my1stapp>

BalancerMember http://localhost:3000/ loadfactor=100 # Balancer member 1
BalancerMember http://localhost:4000/ loadfactor=80 # Balancer member 2
BalancerMember http://hoststandbyserver:3000/ +H # Balancer member 3
</Proxy>
ProxyPass /my1stapp/ balancer://my1stapp/


Using this configuration, the Apache Mod Proxy balancer will split the requests to http://yourwebsite/my1stapp/ between the first two balancer members based on their load factors (from 180 requests 100 will be sent to the first member and 80 to the second one). If both balancer member 1 and 2 become unavailable the requests will be sent to the 3rd member, which is configured as a hot stand-by member (the +H flag).

Common Issues and Solutions

Please refer to http://httpd.apache.org/docs/2.2/mod/mod_proxy_balancer.html.

If you have any feedback for this document, please send it to support@eapps.com.

Links to other information

Configuration Information - For more details regarding other configuration parameters or for a more detailed description of each configuration parameter/directive for Apache Mod Proxy module you should visit http://httpd.apache.org/docs/2.2/mod/mod_proxy_balancer.html .


Comments

Please login to comment