<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8633424125069899801</id><updated>2011-10-01T12:33:11.426-07:00</updated><title type='text'>Tomcat clustering and Load-balancing with Apache</title><subtitle type='html'>This article will help you to bring Tomcat servers in cluster and allow Apache 2.X for Load-balancing on WINDOWS.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://isumved.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8633424125069899801/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://isumved.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sumved Shami</name><uri>http://www.blogger.com/profile/16712894803534757178</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://1.bp.blogspot.com/_6xpwbkF9P5I/SexYp2HvCTI/AAAAAAAAClk/FWnWjw9pNJc/S220/Sumved.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8633424125069899801.post-6542988005842043165</id><published>2009-04-15T23:23:00.000-07:00</published><updated>2010-04-02T23:35:48.073-07:00</updated><title type='text'>Tomcat Clustering and Load-balancing with Apache</title><content type='html'>It is quite surprising that I was unable to find a single article for Tomcat 6.0 clustering and Load-balancing with the help of Apache 2.2. I needed it in one of my project to check the performance of the web application. Of course, I got a big help from one of the article on this &lt;a href="http://thought-bytes.blogspot.com/2007/03/how-to-load-balance-tomcat-55-with.html"&gt;link&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;My goal was to put 3 Tomcat servers on cluster with load-balancing by Apache 2.2. So, these are the steps to achieve this goal:&lt;br /&gt;A. Download Apache Tomcat 6.0.18 from &lt;a href="http://tomcat.apache.org/download-60.cgi"&gt;Apache Tomcat Download Page&lt;/a&gt;. Download binary zipped format.&lt;br /&gt;B. Download Apache 2.2 HTTP server from &lt;a href="http://archive.apache.org/dist/httpd/binaries/win32/"&gt;Apache Download Center&lt;/a&gt;.&lt;br /&gt;C.Download &lt;a href="http://archive.apache.org/dist/tomcat/tomcat-connectors/"&gt;Tomcat Connectors&lt;/a&gt;. Click on "JK" --&gt; Binaries --&gt; Win32 --&gt; jk-1.2.21 --&gt; mod_jk-apache-2.2.4.so&lt;br /&gt;D. We will test 2 Tomcat server instances in cluster and 1 Apache HTTP server for load balancing. Assume we have 3 machines on network with IP 172.16.xx.xxx, 172.16.yy.yyy and 172.16.zz.zzz respectively. Let us set-up Apache HTTP Server first on 172.16.zz.zzz.&lt;br /&gt;&lt;br /&gt;1. Install Apache HTTP Server from the setup file you downloaded from Apache Download Center.&lt;br /&gt;2. Start it and test it once. Go to "http://localhost/" in your favorite browser. You will get something like "It works" as result. Stop it and let us setup Connector.&lt;br /&gt;3. Copy the mod_jk-apache-2.2.4.so to the modules directory in modules directory in your Apache installation.&lt;br /&gt;4. Rename it to mod_jk.so&lt;br /&gt;5. Open up httpd.conf in the conf directory of your Apache installation in a text edit, and add the following line at the end of the set of LoadModule statements:&lt;br /&gt;LoadModule jk_module modules/mod_jk.so&lt;br /&gt;6. Create a file called workers.properties in the conf directory. Add these lines to it:&lt;br /&gt;&lt;br /&gt;* workers.java_home=$JAVA_HOME&lt;br /&gt;* worker.list=balancer&lt;br /&gt;* worker.worker1.port=8009&lt;br /&gt;* worker.worker1.host=172.16.xx.xxx&lt;br /&gt;* worker.worker1.type=ajp13&lt;br /&gt;* worker.worker1.lbfactor=1&lt;br /&gt;* worker.worker2.port=8009&lt;br /&gt;* worker.worker2.host=172.16.yy.yyy&lt;br /&gt;* worker.worker2.type=ajp13&lt;br /&gt;* worker.worker2.lbfactor=1&lt;br /&gt;* worker.balancer.type=lb&lt;br /&gt;* worker.balancer.balance_workers=worker1,worker2&lt;br /&gt;* worker.balancer.method=B&lt;br /&gt;&lt;br /&gt;Put your java home directory instead of $JAVA_HOME.&lt;br /&gt;7. Specify the worker properties in httpd.conf:&lt;br /&gt;&lt;br /&gt;Add these lines just after the LoadModule definitions-&lt;br /&gt;&lt;br /&gt;# Path to workers.properties&lt;br /&gt;JkWorkersFile c:/apache2.2/conf/workers.properties&lt;br /&gt;&lt;br /&gt;# Path to jk logs&lt;br /&gt;JkLogFile c:/apache2.2/mod_jk.log&lt;br /&gt;&lt;br /&gt;# Jk log level [debug/error/info]&lt;br /&gt;JkLogLevel info&lt;br /&gt;&lt;br /&gt;# Jk log format&lt;br /&gt;JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "&lt;br /&gt;&lt;br /&gt;# JkOptions for forwarding&lt;br /&gt;JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories&lt;br /&gt;&lt;br /&gt;# JkRequestLogFormat set the request format&lt;br /&gt;JkRequestLogFormat "%w %V %T"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;JkMount /MyApp balancer&lt;br /&gt;JkMount /MyApp/* balancer&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;"MyApp" is your web-application name. And, I installed Apache2.2 directly under C: drive.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;E. Put one Tomcat instance on 172.16.xx.xxx and another on 172.16.yy.yyy. Edit the server.xml for Tomcat and Tomcat's SecondInstance and add a jvmRoute attribute to the Engine element:&lt;br /&gt;(engine name="Catalina" defaulthost="172.16.xx.xxx" jvmroute="worker1")&lt;br /&gt;for 172.16.xx.xxx and&lt;br /&gt;(engine name="Catalina" defaulthost="172.16.yy.yyy" jvmroute="worker2")&lt;br /&gt;for 172.16.yy.yyy.&lt;br /&gt;Also, replace "localhost" words in "server.xml" with "IP" of the machine.&lt;br /&gt;&lt;br /&gt;***Please check you do not have space between the directory names. Ex: "C:\Tomcat Server". There is a space between "Tomcat" and "Server". Your Apache server will not start if you have directory names like this in "httpd.conf" and "worker.properties" files. You better make it "C:\TomcatServer". Tell me if you find a way to rectify this issue.***&lt;br /&gt;&lt;br /&gt;Start Tomcat servers and then start Apache HTTP Server. Now, Your Tomcat servers are in cluster and Apache HTTP server is managing load-balancing.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href='http://lexmarkinkcartridges.net/'&gt;Lexmark Ink Cartridges&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8633424125069899801-6542988005842043165?l=isumved.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://isumved.blogspot.com/feeds/6542988005842043165/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://isumved.blogspot.com/2009/04/tomcat-clustering-and-load-balancing_15.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8633424125069899801/posts/default/6542988005842043165'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8633424125069899801/posts/default/6542988005842043165'/><link rel='alternate' type='text/html' href='http://isumved.blogspot.com/2009/04/tomcat-clustering-and-load-balancing_15.html' title='Tomcat Clustering and Load-balancing with Apache'/><author><name>Sumved Shami</name><uri>http://www.blogger.com/profile/16712894803534757178</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://1.bp.blogspot.com/_6xpwbkF9P5I/SexYp2HvCTI/AAAAAAAAClk/FWnWjw9pNJc/S220/Sumved.jpg'/></author><thr:total>1</thr:total></entry></feed>
