You can configure a vFabric Web Server instance to perform simple load balancing between two or more tc Runtime instances.
In the procedure that follows, you configure a vFabric Web Server instance to run in front of the tc Runtime instances; this vFabric Web Server instance receives all requests from users, and then passes them back to the tc Runtime instances using a specified load-balancing algorithm. Responses from the tc Runtime instances are then routed back through this same vFabric Web Server instance. For this reason, the vFabric Web Server instance acts like a proxy (both reverse and forward) so that the users never know the URLs of the backend tc Runtime instance that are actually doing all the work. Additionally, the vFabric Web Server instance ensures that the load on each tc Runtime instance is balanced. You can specify that each tc Runtime instance take on an equal work load, or you can specify that one instance work twice as hard as the others.
In the procedure, the following scenario pertains. These assumptions are not requirements; your environment might be very different. The assumptions are listed only to make the procedure easier to understand.
Two tc Runtime instances are running at the following two hosts and port numbers:
The two tc Runtime instances are running on the same computer,
are part of the same installation and their respective
CATALINA_BASE variables are as follows:
Each tc Runtime instance is configured exactly the same (other than the value of the various ports).
You have deployed the same application to both tc Runtime
instances and the URL context is the same in both instances:
You want all users of the application to first go through the front-end vFabric Web Server instance, and any evidence of the backend tc Runtime instances upon which the application is actually deployed should be hidden from the user.
vFabric Web Server is installed on a different computer than
vFabric tc Server. The name of the particular vFabric Web Server
lb-server and its home directory is
You want to configure sticky sessions, which means that the vFabric Web Server instance always routes the requests for a particular session to the same tc Runtime instance that serviced the first request for that session.
You want to use the HTTP protocol for all communication between the vFabric Web Server and the tc Runtime instances.
The load balancing described in this procedure is very simple, although you have many options available to further customize it. At appropriate locations in the procedure, links to the Apache HTTP Server documentation are provided for additional configuration options not covered by this specific scenario. Adapt the procedure for your particular environment.
As part of the procedure, you update the configuration files of both the vFabric Web Server instance and the two tc Runtime instances.
Install vFabric tc Server on the same or different computer as vFabric Web Server, and create two more instances. Make note of the host and port numbers of the two instances. See the vFabric tc Server documentation for details.
Deploy the same application to the two tc Runtime instances.
To configure load balancing for the scenario described in the introduction to this section, follow these steps:
On the computer on which vFabric Web Server is installed, stop the instance, if it is currently running. Following the example and assumptions:
prompt# cd /opt/vmware/vfabric-web-server/lb-server prompt# bin/httpdctl stop
httpd.conf configuration file of the
vFabric Web Server instance and ensure that the three required
mod_proxy_http, are present and enabled (in other words,
are not commented out):
LoadModule proxy_balancer_module "VFWS-INSTALL/httpd-2.2/modules/mod_proxy_balancer.so" LoadModule proxy_module "VFWS-INSTALL/httpd-2.2/modules/mod_proxy.so" LoadModule proxy_http_module "VFWS-INSTALL/httpd-2.2/modules/mod_proxy_http.so"
refers to the directory in which you installed vFabric Web Server. If
they are not in the file, add them in the same location as the other
Following our example, the directive configurations would be:
LoadModule proxy_balancer_module "/opt/vmware/vfabric-web-server/httpd-2.2/modules/mod_proxy_balancer.so" LoadModule proxy_module "/opt/vmware/vfabric-web-server/httpd-2.2/modules/mod_proxy.so" LoadModule proxy_http_module "/opt/vmware/vfabric-web-server/httpd-2.2/modules/mod_proxy_http.so"
The vFabric Web Server configuration file is located in the
conf directory of your vFabric Web Server instance
/opt/vmware/vfabric-web-server/lb-server/conf in our
<Proxy> element to specify the list
of tc Runtime instances and the method of load balancing you want to
use. Then use the
ProxyPassReverse directives to specify the URLs that will
use this proxy and load-balancing (both for requests and responses.)
<Proxy balancer://my-balancer> BalancerMember http://192.168.0.203:8081 route=instanceOne loadfactor=1 BalancerMember http://192.168.0.203:8082 route=instanceTwo loadfactor=1 ProxySet lbmethod=byrequests </Proxy> ProxyPass /my-app balancer://my-balancer/my-app ProxyPassReverse /my-app http://192.168.0.203:8081/my-app ProxyPassReverse /my-app http://192.168.0.203:8082/my-app
In the preceding example:
balancer parameter of the
<Proxy> element specifies a unique identifier
for this load balancer configuration.
Each tc Runtime instance that is serviced by this load
balancer must have its own
BalancerMember; the first
parameter of this directive specifies the full IP address
(including port number) of the tc Runtime instance.
route parameter contains session ID
information. You later use the value of this parameter in the tc
Runtime configuration file to configure sticky sessions; for now,
just ensure that the values are unique for each
loadfactor parameter specifies how much
load a particular member carries. If you want each member to carry
the same load, set the numbers equal to each other (as in the
example above). If, however, you want one member to work three
times harder than the other, set the load factors to 3 and
lbmethod parameter of the
ProxySet directive to specify the load balancing
algorithm. The possible values are as follows:
byrequests: performs weighted request
counting. This is the default value.
bytraffic: performs weighted traffic byte
bybusyness: performs pending request
ProxyPassReverse to specify the context URLs of the
application that will be routed to the tc Runtime instances that
you have configured in the load balancing scheme.
ProxyPass specifies that when the vFabric Web Server
instance receives a request at the
/my-app URL, it
routes the request to the load balancer that will in turn route it
to the tc Runtime instance.
ProxyPassReverse does the
reverse: when the tc Runtime instance sends a response to a user
who is using
/my-app, the response appears to come
from the vFabric Web Server instance, and not the tc Runtime
instance. Thus the details of the tc Runtime instance are
hidden from the user.
Optional. If you want to enable
the balancer manager Web application to watch the load balancing
activity and control the behavior, add the following to the
httpd.conf configuration file of your vFabric Web Server
<Location /balancer-manager> SetHandler balancer-manager Order Deny,Allow Deny from all # BE VERY RESTRICTIVE with YOUR ALLOW STATEMENT Allow from 127.0.0.1 </Location>
Optional. If you want to enable sticky sessions, follow these steps:
httpd.conf file of the vFabric Web
Server instance, update the
ProxySet directive of the
<Proxy> element you configured in a preceding
step by adding
This parameter configures the cookie/path that will be used for
stickiness. For example (update shown in bold):
<Proxy balancer://my-balancer> BalancerMember http://192.168.0.203:8081 route=instanceOne loadfactor=1 BalancerMember http://192.168.0.203:8082 route=instanceTwo loadfactor=1 ProxySet lbmethod=byrequests stickysession=JSESSIONID|jsessionid </Proxy>
Go to the computer on which vFabric tc Server is running and
server.xml configuration file of both tc
Runtime instances by adding the
to the Catalina
<Engine> element. Set the value
of this attribute equal to the value you specified (in a preceding
step) for the
route parameter of the
directive in the vFabric Web Server
that describes the tc Runtime instance.
Following our example, the updated
<Engine> entry for the
tc Runtime instance (that uses port
8081) would be as
follows (new attribute in bold):
<Engine name="Catalina" defaultHost="localhost" jvmRoute="instanceOne">
If you configure sticky sessions, VMware recommends that you also configure session replication for the tc Runtime instances. For details, see the section titled Enabling Clustering for High Availability in the vFabric tc Server documentation.
Start the vFabric Web Server instance. Following our example:
prompt# cd /opt/vmware/vfabric-web-server/lb-server prompt# bin/httpdctl start
Start (or restart) the two tc Runtime instances for the configuration changes to take effect. Following our example:
prompt$ cd /home/tcserver/vfabric-tc-server-standard prompt$ ./tcruntime-ctl.sh instanceOne restart prompt$ ./tcruntime-ctl.sh instanceTwo restart
You have now configured load balancing for the two tc Runtime instance using the front-end vFabric Web Server.
For full reference documentation on the directives described in step 3, along with additional parameters you can use, see Apache Module mod_proxy on the Apache Software Foundation Web site.
Ensure that you can access your application through the vFabric
Web Server instance, which in turn routes the request to one of the tc
Runtime instances. Do this by invoking your application in a browser,
but specify the vFabric Web Server instance rather than the tc Runtime
instance. For example, if the URL to access the vFabric Web Server is
http://www.myhost.com, invoke the
application using the following URL in your browser:
If you see your application, then you have correctly set up the
vFabric Web Server instance to route requests to the
/my-app application to one of the two tc Runtime
instances. The vFabric Web Server instance will also balance the load
between the two instances.
If you enabled the balancer manager Web application, use it to watch and control load-balancing activity. Access the balancer manager application by navigating to the following URL in your browser:
is the port
number of the vFabric Web Server instance (
default.) For security, the balancer manager configuration allows
access only to users who navigate to the application using a browser
installed on the same computer on which the vFabric Web Server
instance is actually running.