Nginx or Apache as web server in front of Tomcat (Java app)?

9,377

First of all: Tomcat is faster to run standalone (logically, as there is no need for proxying). It's probably not the most secure solution, but it is faster. :)

Apache can use the mod_jk connector wich utilizes AJP13, wich gives you a vast performance boost compared to regular HTTP proxying. If you really need to use a frontend then go for Apache+mod_jk.

Share:
9,377

Related videos on Youtube

sebarmeli
Author by

sebarmeli

I'm a software engineer specialized in web development. I like blogging on web technologies here http://blog.sebarmeli.com

Updated on September 18, 2022

Comments

  • sebarmeli
    sebarmeli over 1 year

    just wondering which web server between Apache and Nginx is better supported from Tomcat? I'm attracted in using Nginx for the single-threaded feature. I want to deploy a Java app running on HTTPS.

    Cheers

    • Admin
      Admin almost 13 years
      And you don't want to run Tomcat in stand-alone mode?
    • Admin
      Admin almost 13 years
      I thought using a web server in front of Tomcat in production was a better practice.
  • J. Singh
    J. Singh almost 13 years
    In our load testing of a very large application, AJP13 versus straight HTTP proxying didn't make any difference. In fact, using nginx to proxy to Tomcat via HTTP actually resulted in higher overall scalability with the same hardware at hand (probably because nginx is event-based, and Apache was managing a whole OS thread for each connection). We had 1 dual-core proxy server (running nginx 0.7.65 or Apache 2.2.x depending on the test) and six servers running a monster Tomcat/JBoss application for this test. Tomcat also sucks at serving static files compared to a Apache/nginx.
  • pauska
    pauska almost 13 years
    @rmalayter: Sorry if I wasn't clear about the static bit, what I really ment was "Tomcat serves applications faster standalone". How were apache configured for your test enviroment? Was it stripped down?
  • J. Singh
    J. Singh over 12 years
    We used the default Apache and nginx packages on Ubuntu 10.04, with only essential modules enabled. As far as Tomcat being faster "standalone", that really isn't an option for most production applications, as Tomcat doesn't support a whole lot of critical web server features without writing custom servlets or filters. And it is very slow for static file serving, which is also critical for many applications.