Apache Load-Balancer
XAP comes with a built-in utility allowing you to dynamically update an Apache httpd web server load-balancing configuration, based on deployed web applications.
Configuration
Here is an example configuration of the apache httpd to load-balance web requests between the different web servers.
Install apache httpd.
Create a file named HttpSession.conf
located at
Place the following within the HttpSession.conf
file. The BalancerMember
should be mapped to different URLs of your web servers instances. With the example below we have Tomcat using port 8080 and Websphere using port 9080.
<VirtualHost *:8888>
ProxyPass / balancer://HttpSession_cluster/
ProxyPassReverse / balancer://HttpSession_cluster/
<Proxy balancer://HttpSession_cluster>
BalancerMember http://127.0.0.1:8080 route=HttpSession_1
BalancerMember http://127.0.0.1:9080 route=HttpSession_2
</Proxy>
</VirtualHost>
The
127.0.0.1
IP should be replaced with IP addresses of the machine(s)/port(s) of WebSphere/Tomcat instances.Configure the <Apache2.2 HTTPD root>\conf\httpd.conf
to have the following:
Include "/tools/Apache2.2/conf/gigaspaces/*.conf"
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule status_module modules/mod_status.so
Listen 127.0.0.1:8888
ProxyPass /balancer !
<Location /balancer-manager>
SetHandler balancer-manager
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
The
/tools/Apache2.2
folder name should be replaced with your correct Apache httpd location. \ The 127.0.0.1
IP should be replaced with appropriate IP addresses of the machine that is running apache.Once you have the space running, Websphere running, Tomcat running, and Apache httpd configured, restart the Apache http. On windows you can use its service.
Once you performed the above steps, access the following URL:
http://127.0.0.1:8888/HttpSession
You should have the web application running. Any access to the web application will be routed between Websphere and Tomcat. You can check this by accessing the Apache httpd balancer console:
http://127.0.0.1:8888/balancer-manager
You can shutdown Websphere or Tomcat and later restart these. Your web application will not lose its session data.
Multi-Site Deployment
When deploying the multi-site example you should change the shiro.ini
for each site to match the local site Space URL. For example, to connect to the DE space you should have the web application use a shiro.ini
with the following:
connector.url = jini://*/*/wanSpaceDE?groups=DE
To connect to the US space you should have the web application use a shiro.ini
with the following:
connector.url = jini://*/*/wanSpaceUS?groups=US
Library dependencies
Developers should include the following dependencies in pom.xml file.
<repositories>
<repository>
<id>org.openspaces</id>
<name>OpenSpaces</name>
<url>http://maven-repository.openspaces.org</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>
</repositories>
<dependency>
<groupId>com.gigaspaces.httpsession</groupId>
<artifactId>gs-runtime</artifactId>
maven-version
<version>10.1.1-b-12800-RELEASE</version>
</dependency>
<dependency>
<groupId>com.gigaspaces.httpsession</groupId>
<artifactId>gs-session-manager</artifactId>
maven-version
<version>10.1.1-b-12800-RELEASE</version>
</dependency>