Load balance Transact UI Tomcat servers using Apache
Instructions on setting up Apache to load balance across multiple Transact UI Tomcat servers.
Transact automatically clusters the processing of batches.
If you want to secure your Transact servers behind the DMZ and distribute the UI load across several Transact UI servers while allowing users to access Transact through one URL, you can set up Apache to load balance across multiple Transact Tomcat servers.
-
Install Tomcat instances and Apache HTTPD on a server in the DMZ.
If you haven't already installed them, download and install the latest stable versions of Apache Tomcat and Apache HTTPD from the Apache project sites.
-
Download and install
mod_jk.
The mod_jk module is the Apache HTTPD module used to provide the cluster with load balancing and proxy capabilities. It uses the AJP protocol to facilitate fast communication between Tomcat servers and the Apache web server that receives client requests.
The module is distributed separately from Apache HTTPD as part of the Tomcat project. Binary distributions are available for most major platforms and can be downloaded from the Tomcat website. If the version and platform you need are not available as a binary distribution, you can build the appropriate version from the source.
Once you have downloaded and unzipped or built the module, place it in the 'modules' directory of your Apache HTTPD server.
-
Configure
mod_jk.
Set up the mod_jk module in Apache HTTPD's configuration files. This configuration is a two-step process and may be a little confusing, as mod_jk does not separate its proxy capabilities from its load balancing capabilities.
First, configure the module itself by adding a few lines to the main Apache HTTPD configuration file, apache\conf\httpd.conf. Here is an example configuration:
LoadModule jk_module modules/mod_jk.so JkWorkersFile conf/workers.properties JkLogLevel info #JkShmFile logs/mod_jk.shm JkLogFile logs/mod_jk.log JkMount /* balancer JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories +ForwardSSLCertChain JkRequestLogFormat "%w %V %T" # Should mod_jk send SSL information to Tomcat (default is On) JkExtractSSL On # What is the indicator for SSL (default is HTTPS) JkHTTPSIndicator HTTPS # What is the indicator for SSL session (default is SSL_SESSION_ID) JkSESSIONIndicator SSL_SESSION_ID # What is the indicator for client SSL cipher suite (default is SSL_CIPHER) JkCIPHERIndicator SSL_CIPHER # What is the indicator for the client SSL certificate (default is SSL_CLIENT_CERT) JkCERTSIndicator SSL_CLIENT_CERT # When using mod_jk with Apache & mod_ssl, it is essential to specify "SSLOptions +StdEnvVars +ExportCertData" in the httpd.conf file. SSLOptions +StdEnvVars +ExportCertData <Location /jkmanager/> JkMount jkstatus Order deny,allow Deny from all Allow from 127.0.0.1 </Location>Explanation of the parameters configured:
- LoadModule
- Makes the mod_jk module available for use. The extension of the module varies by operating system.
- JkWorkersFile
- Sets the path to the worker configuration file, which will be created in the next step.
- JkShmFile
- Sets the path to the shared memory files for the module. Generally, keep this with the logs.
- JkLogFile
- Sets the path to the module log file.
- JkLogLevel
- Sets the level of logging for the module. Valid values are "debug", "error", or "info".
- JkMount
- Maps a URL pattern to a specific worker configured in the worker configuration file.
- Location
- This is a security constraint. The settings included allow access to the jkmanager only from the localhost.
-
Configure the cluster workers.
Configure the workers, which refer to both real Tomcat servers that will process requests and virtual servers included in the module to handle load balancing and monitoring.
Create or modify the apache\conf\workers.properties file with the following configuration:
# Create a list of Tomcat servers worker.list=balancer # Initialize with Tomcat Server 1 configuration worker.worker1.port=8009 worker.worker1.host=10.1.0.180 worker.worker1.type=ajp13 worker.worker1.lbfactor=1 # Initialize with Tomcat Server 2 configuration worker.worker2.port=8009 worker.worker2.host=10.1.0.190 worker.worker2.type=ajp13 worker.worker2.lbfactor=1 # Set the balance type and the servers to be used worker.balancer.type=lb worker.balancer.balance_workers=worker1, worker2 worker.loadbalancer.sticky_session=1 worker.list=jkstatus worker.jkstatus.type=statusSticky sessions must be enabled. -
Configure the
Transact
cluster workers.
For each server, edit the following files:
-
Transact
Installation Directory\Application\WEB-INF\classes\META-INF\dcma-batch\dcma-batch.properties
Locate the line:
batch.base_http_url=http\://computername\:8080/dcma-batchesChange computername to the Apache server's resolvable DNS name or IP address. Remove the port number part "\:8080", and save the file.
-
Transact
Installation Directory\JavaAppServer\conf\server.xml
Locate the line:
<Engine name="Catalina" defaultHost="localhost" jvmRoute="worker1">Change worker1 to match the correct worker number defined in workers.properties.
-
Transact
Installation Directory\Application\WEB-INF\classes\META-INF\dcma-batch\dcma-batch.properties
-
Start Apache and
Transact
Tomcat servers.
You can check the status of load balancing by navigating to http://127.0.0.1/jkmanager/ on the Apache server.