17

So, I have a webapp with a fair amount of JSPs, servlets, alot of which are using IceFaces. Obviously, most of this will have to stay in Tomcat.

However, I've been told that static content (HTML, Images, etc.) is slower on Tomcat than a pure webserver like Apache. My understanding is that when you're using Tomcat as a stand-alone webserver, it's using a version of Apache in the first place. I may be mistaken on this, of course.

But what is the penalty for serving static images or files from Tomcat? Is it worth breaking out into its own webserver for a low volume site?

Jonik
  • 80,077
  • 70
  • 264
  • 372
Drew
  • 15,158
  • 17
  • 68
  • 77
  • 3
    Clarification: You are not automatically using the Apache web server when running Tomcat. The problem is the word "Apache" is overloaded. When people talk about Apache, they are really saying Apache web server. Of course, Tomcat is part of the Apache project. Clear as mud? ;-) – Julien Chastang Mar 17 '09 at 17:58
  • 1
    Exactly, Apache HTTPD (the web server) and Apache Tomcat are two completely different technologies that have nothing to do with each other. Both HTTPD and Tomcat are projects from "Apache" the organization. – Luke Mar 17 '09 at 21:14
  • Fair enough. I had just figured that the actual receiving requests and sending response would've been the same code. I dunno WHY I thought that because Apache is written in C while Tomcat is written in Java. I guess I thought it might drop to C to get the speed. Oh well. – Drew Mar 18 '09 at 13:30

2 Answers2

13

See the Tomcat Connector FAQ for some information. For modern versions of Tomcat, the performance difference is much smaller than it used to be. For a low volume site, there is no reason that you cannot supply all content with Tomcat.

Eddie
  • 53,828
  • 22
  • 125
  • 145
  • +1 Moreover, this solution may simplify your configuration / deployment. I have had problems with Apache mucking with my Tomcat HTTP headers that I have never been able to figure out. – Julien Chastang Mar 17 '09 at 17:15
5

I agree except in two circumstances

  1. Tomcat's SSL using JSSE is noticeably slower. There are native versions that can be plugged in, but that tends to be more painful. In general the SSL is a bit less straightforward than the well-understand Apache Httpd server

  2. Fronting with an HTTpd server gives more flexibility re virtual web hosts etc. Tomcat is not as flexible in this regard. Unsurprisingly it lacks all the options in Apache :). An obvious nice one is built in compression of static files is very easy to add in Apache. It's not hard in tomcat extra, but it's more work.

  3. You are mistaken. Apache Httpd Server is a totally different beast and has no code shared with Tomcat.

If neither is an issue, than yeah use tomcat by itself

Eric Wilson
  • 57,719
  • 77
  • 200
  • 270
  • Any benchmarks or the like of the Tomcat SSL thing? That may, in fact, be something to consider. I'm not sure the volume will make it a priority but if our performance starts to hurt too bad, that might be a tipping point. – Drew Mar 20 '09 at 21:00