Load Balancing Alfresco with Apache

October 7, 2011
blog author

jmacinnes

Director of Technology

Alfresco is an Enterprise ready Content Management and Repository system that can support the Document needs of pretty much any organization. A common way of running Alfresco (in fact the default way) is via the Apache Tomcat server. Tomcat has very good load balancing support using an Apache module called mod_jk. This module, in conjunction with Tomcat, supports full system fail-over including failing over session data to an active Tomcat instance. You can use mod_jk with Alfresco to build a very reliable and robust ECM installation. Here are steps to get Alfresco load balancing working under Apache. The instructions here assume a RHEL/CentOS flavour of Linux, but should be applicable to other flavours.

1. Install Apache sudo yum install httpd

2. Install mod_jk from the RPM which can be found at: http://greenmice.info/en/comment/reply/152?quote=1. Mod_jk is an Apache module that provides a number of services to Apache for interacting with a Tomcat server.

sudo rpm -i mod_jk-ap20-1.2.31-2.x86_64

3. Create a "workers.properties" file and store it in/etc/httpd/conf

# Define 2 real worker using ajp13 worker.list=worker1 worker2 router worker.router.type=lb worker.router.balance_workers=worker1, worker2 worker.router.sticky_session=True # Set properties for worker1 (ajp13) # Server 1 worker.worker1.type=ajp13 worker.worker1.host= worker.worker1.port=8009 worker.worker1.lbfactor=1 # Server 2 worker.worker2.type=ajp13 worker.worker2.host= worker.worker2.port=8009 worker.worker2.lbfactor=1

4. Modify httpd.conf and add the following to the end of the file to setup mod_jk:

LoadModule jk_module modules/mod_jk.so JkWorkersFile conf/workers.properties JkLogFile "logs/mod_jk.log" JkLogLevel info JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" JkRequestLogFormat "%w %V %T" JkMount /* router

5. Restart Apache

6. Modify Alfresco's server.xml located in /tomcat/conf/server.xml The value "jvmRoute=worker1" must contain the appropriate name of the worker on each of the Alfresco installs and must match the name values located in the workers.properties file created in step 3 above.

7. Modify alfresco's and share's web.xml files on each node to include the directive. These files are located at: /tomcat/webapps/share/WEB-INF/web.xml /tomcat/webapps/alfresco/WEB-INF/web.xml Should look like this: Alfresco Project Slingshot Alfresco Project Slingshot application

8. Restart Alfresco

9. You should now be able to access: http:///share which will be load balanced over the 2 nodes with full session failover.