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:
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!
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:
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.
Not to spam your site – but this is another place where mod_proxy_ajp in Apache 2.2 would be a real lifesaver:
This avoids all of the workers config, and is much more logical (to me anyways)
My code got messed up above – I’ve dropped the Apache 2.2 config into my blog here:
[…] 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. […]
Comments are closed.