Scaling with sMash
We look at scaling in 2 ways.
Scaling number of applications
The user wants to deploy several tens of sMash applications on the same box and needs the ability to route to them.
The applications are deployed on a single box with distinct context roots. The
zero modproxy generate command is used to generate mod_proxy configuration for all those apps. The configuration is used with Apache mod_proxy to route to all applications on the box.
Use Case
A step by step example describing how to configure a system with multiple zero applications and apache's mod_proxy.
Set-up
- Within a single host, HostA the following software is installed:
- Apache's HTTP Server whose configuration resides at: /etc/apache2
- WebSphere sMash 1.1 (silverstone) driver M1 installed into: ~/zero
- Two Zero Applications in the following directories:
Configuration Steps
The steps necessary to configure the system for proxying
Update Zero Applications to be proxyable
- Add a unique context root to each application
- Run each application on its own port
cd ~/zero/appA echo '/config/contextRoot="/appA"'>> config/zero.config ../zero start cd ~/zero/appB echo '/config/contextRoot="/appB"'>> config/zero.config sed -i 's/8080/8081/g' config/zero.config ../zero start
- Generate mod_proxy configurations for each application
cd ~/zero/appA ../zero modproxy generate -o=appA.conf cd ~/zero/appB ../zero modproxy generate -o=appB.conf
- Merge the mod_proxy configurations
cd ~/zero/appA ../zero modproxy merge -balancer -o=~/zero/zeroApps.conf ~/zero/appA/appA.conf ~/zero/appB/appB.conf
Update the Apache HTTP Server Configuration
After the zero applications have been updated to each have a context root and reside on unique ports, the apache server must be configured to proxy to those applications. The enablement of the http server consists of the loading and optional configured of four modules: proxy,proxy_http, rewrite, and proxy_balancer.
Apache modules are loaded by adding the -LoadModule- line to the server's httpd.conf. The LoadModule command always takes the following form: LoadModule $moduleName $pathToModule. In the target system all the apache modules reside in the -/usr/lib/apache2/modules- directory, so enable the loading of the desired modules the following lines should be added to the httpd.conf file if they do not exist already
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
LoadModule proxy_balancer_module /usr/lib/apache2/modules/mod_proxy_balancer.so
Two out of the four modules loaded: proxy and rewrite need configuration beyond what exits in the generated zeroApp.conf file. Those modules are: proxy and rewrite.
To configure the apache proxy module add the following lines to the httpd.conf
ProxyRequests Off
<Proxy>
Order deny,allow
Allow from all
</Proxy>
To enable the apache rewrite engine add the line
RewriteEngine On
Sample httpd.conf snippet
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
LoadModule proxy_balancer_module /usr/lib/apache2/modules/mod_proxy_balancer.so
RewriteEngine On
ProxyRequests Off
<Proxy>
Order deny,allow
Allow from all
</Proxy>
Include /home/trgissel/zero/zeroApps.conf
Sample zeroApps.conf
RewriteRule ^/appA$ /appA/ [R]
<Proxy balancer://appACluster>
BalancerMember http://trgissel-ubuntu-vm:8080/appA route=mem0
</Proxy>
<LocationMatch "/appA" >
Order allow,deny
Allow from all
ProxyPass balancer://appACluster stickysession=zsessionid nofailover=Off
ProxyPassReverse balancer://appACluster
</LocationMatch>
RewriteRule ^/appB$ /appB/ [R]
<Proxy balancer://appBCluster>
BalancerMember http://trgissel-ubuntu-vm:8081/appB route=mem0
</Proxy>
<LocationMatch "/appB" >
Order allow,deny
Allow from all
ProxyPass balancer://appBCluster stickysession=zsessionid nofailover=Off
ProxyPassReverse balancer://appBCluster
</LocationMatch>
Scaling a single application
The user wants to scale a single application from a one box deployment to a multiple box deployment.
An application is deployed on multiple boxes (a.k.a
Horizontal Clustering ) for several reasons.
- If a single instance of an application cannot meet performance requirements
- If an application is to be made highly available. Simple HA solution for sMash