I have an application depending on BlazeDS and Oracle Application Express, which both require the use of Tomcat or equivalent. I have the following two Linux servers:

(1) Oracle database 11G

(2) Apache Webserver

Also, my application requires Java and C programs mainly for a lot of number crunching.

My first question is which server to put the Java and C application logic? Should it be the database server or the webserver? Or, does it depend...?

My second question is which server to place Tomcat on (does it always go on the webserver, or does it depend on the answer to the first question)?

Would appreciate pros and cons if there's more than one possibility.

3 Answers 3


Tomcat can go on either server (or an entirely different one). I would tend toward putting Tomcat and the C stuff on the web server, and give the database server all the memory and CPU for it's use. If the Java and C code are a bottle neck, then add a third server for Tomcat. I don't like to use database servers as multi-function servers unless there is no choice. As long as the incoming traffic and the number crunching can be handled by the web server, let it be the 'application' server.

  • 1
    We typically use mod_proxy_ajp to connect Apache HTTPD to Tomcat. We have used Tomcat directly in place of Apache. It works, put presents issues if you are using SSL and multiple virtual hosts. mod_proxy_ajp setup is much cleaner and virtual host and SSL host management is much smoother. It also makes it easy to move Tomcat to it's own server, when needed.
    – Craig
    Jan 27, 2012 at 22:25
  • Thanks Craig. See Doug's answers comments section (e.g. any adv/disadv to using mod_jk compared with mod_proxy_ajp?)
    – gkdsp
    Jan 27, 2012 at 22:29
  • mod_jk is deprecated, so stay away unless you have no choice. mod_proxy_ajp is easy to set up, no source to compile.
    – Craig
    Jan 30, 2012 at 20:55

It generally goes on the third Application Server.

For Tomcat, in a typical enterprise environment, it'd be: Apache Reverse Proxy -> Tomcat Application Server <-> Database Server

If you are lightweight and don't need a lot of restrictions on the Web layer, you can always just front end directly with an HTTP or HTTPS connector on Tomcat (using APR or the built-in Coyote connector).

  • Thanks Doug. By "front end directly..." do you mean using Tomcat for serving static pages and simply avoid using Apache webserver? I need PhP for my website, but only for a tiny part of it.
    – gkdsp
    Jan 27, 2012 at 21:49
  • You can run PHP directly on Tomcat (wiki.apache.org/tomcat/UsingPhp), or via jsvc. However, typically I'd go with proper Apache (though APR might have a solution for doing PHP a bit better, haven't investigated it in any environment yet). In this case, if you only have two servers, toss Apache w/ PHP on the same server as Tomcat and use mod_proxy_ajp (mod_jk is deprecated) to proxy from Apache to to an AJP connector on the Tomcat instance. Go ahead and disable the HTTP connector on 8080 on the Tomcat instance that is enabled in the default config as well.
    – Doug
    Jan 27, 2012 at 21:54
  • It's getting clearer now, thanks Doug. Did you mean mod_jk2 is deprecated? According to: wiki.apache.org/tomcat/FAQ/Connectors#Q2 they say mod_jk is under active development. If so, would mod_proxy_ajp offer any advantage (or disadvantage) over mod_jk?
    – gkdsp
    Jan 27, 2012 at 22:27
  • Sorry, yes, mod_jk2 is deprecated. I personally prefer mod_proxy_ajp these days for performance and security, but you can always test both and see what works best for you.
    – Doug
    Jan 27, 2012 at 22:30

I'm against putting anything you don't have to on a datbase server. Put it in the web server, unless you have another server yet.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.