Learn how to use mod_jk to forward requests to specific hosts when more than one Tomcat instance is running.

Recently, I was asked to reorganize some of our Web applications to improve their stability. The major push was to get each of our applications running in its own instance of Tomcat. These applications all are in various stages of development, and if a single instance allocates all of the memory available, the entire Tomcat server must be restarted. This, in turn, brings down all of the other applications.

An obstacle to running multiple instances is each instance would have to run on a unique port. Enter Apache’s Web server. With the use of mod_jk, we were able to forward requests to specific hosts and contexts to the respective running instance of Tomcat.

Pulling all of this together was not the hardest thing I’ve done; however, it did prove challenging due to a lack of documentation. By no means, though, is this statement a stab at any of the development teams. In fact, the developers themselves helped me on numerous occasions when I found myself in over my head. When the documentation had me confused or I could not find exactly what I was looking for, I would head over to #tomcat or #apache on irc.freenode.org and pose my question there. Usually, I received a response within minutes.

The following software was used for the purposes of this article. See the resources section at the end of this article for download locations:

  • J2sdk1.4.2_09
  • Tomcat 5.0.28
  • Apache 2.0.54
  • mod_jk 1.2.14

Read More
Source : article by Daniel McCarthy,Linux Journal

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Reddit Post to StumbleUpon

Share or Bookmark This Post With :

6 Comments
Marty McGee Posted On July 24th, 2008

Great article! Just what I’m looking for. Any chance we could get a cleanup of the last bits of code? It seems Wordpress has deleted the line breaks (as previous versions of WP are notorious for). Thanks!

Kor Kiley Posted On April 15th, 2009

The text about the comment syntax above got cut off. If you really want to comment a section out you need to surround it with a comment like so:

Kor Kiley Posted On April 15th, 2009

OK. Try this:

WordPress is apparently interpreting these comments as HTML and not literal text. I’m trying quotes around the comment syntax. If that doesn’t work, I give up. I’m sure anyone reading this article already knows how to comment XML/HTML anyway.

Kor

dammitAdam Posted On April 17th, 2009

Not to spam your site – but this is another place where mod_proxy_ajp in Apache 2.2 would be a real lifesaver:
ProxyPass ajp://localhost:8009/application1/
ProxyPass ajp://localhost:8109/application2/
ProxyPass ajp://localhost:8209/application3/

This avoids all of the workers config, and is much more logical (to me anyways)

dammitAdam Posted On April 17th, 2009

My code got messed up above – I’ve dropped the Apache 2.2 config into my blog here:

http://shatnerandsulu.wikidot.com/blog:apache-tomcat-multiple-servers

[...] post is basically a response to an article that is over @ JavaTechie Its just to show how to send traffic to multiple tomcat servers using mod_proxy_ajp in Apache 2.2. [...]

Leave a Reply

Subscribe to RSS Feeds Follow me on Twitter Add to Favourite
 
Sponsors
 
Tags
 
Network [+]
 
© Copyright 2009 - 2011 TechiePark.com. All Rights Reserved | Powered by WordPress
This work is licensed under a Creative Commons Attribution 3.0 Unported License
Php5 powered    Mysql powered    Apache powered   Best viewed with  Spread Firefox Affiliate Button