Myth or truth: One should always use Apache httpd in front of Apache Tomcat to improve performance?

posted by mthomas on April 14, 2010 11:14 PM

The short answer is that this is a myth. The longer answer is that back in the days of Tomcat 3 there was some truth to this depending on circumstances. However, for the versions of Tomcat in use today (5.5.x and 6.0.x) then there is no need to use httpd for purely performance reasons. Tomcat now supports the native/APR connector which uses the same native library (the Apache Portable Runtime—APR) as httpd for the low-level I/O and therefore can achieve similar performance to httpd. When serving static content there is ever so slightly more overhead when using Tomcat compared to httpd but the differences are so small they are unlikely to be noticeable in production systems.

If you research the httpd vs Tomcat performance issue, you will find a variety of load and performance benchmarks that show a range of results. An often quoted result shows that Tomcat's pure Java connector is consistently faster than httpd.

This particular result is the opposite of what is expected. httpd should be significantly faster than Tomcat's pure Java connector. This result is probably caused by the size of the file used. Tomcat caches small static files in memory by default and this will provide a significant performance improvement. httpd does not cache files in memory by default. This demonstrates quite nicely how the definition of the benchmark can have a significant impact on the results.

The performance testing performed by Christopher Schultz, a regular on the Tomcat users mailing list, used a wider range of file sizes and provides – in my view – better results. The results of his tests are shown in the graph below.

Click to see larger image

These results are much more in line with what is expected, although there are a few interesting points to note:

  • Apache httpd and Coyote APR/native show similar performance levels.
  • Coyote NIO isn't too far behind httpd and Coyote APR/native.
  • There appears to be a limit on the usefulness of sendfile. This may be a hardware limitation but is worthy of further attention. I've added this to my todo list.
  • For small file sizes (less than ~10KiB) the static file caching in Tomcat provides a significant performance boost.

The detailed results for any performance test will vary with a number of factors such as the hardware used, the number of concurrent requests, the use of keep-alive and the use of caching. These factors can change the results of a particular test but the broad performance results will remain the same:

  • httpd and Coyote APR/native typically have similar performance.
  • Coyote NIO is typically just behind Coyote APR/native (further behind for SSL).
  • Coyote BIO will typically offer the lowest performance.

The settings to achieve the best performance will vary from application to application. The best settings for an application will depend significantly on the size of the resources, the ratio of static to dynamic content, the number of concurrent users, the usage patterns of those users and so on. Generally, performance can be improved by increasing the cacheMaxSize for the context, increasing the number of connector threads (using maxThreads [4]) available to process requests and enabling keep-alive (using maxKeepAliveRequests) but all of these come at the cost of increased resource usage. There is a trade-off to make here between performance and resource usage that will be different for each application.

It should also be noted that there is no magic "make it run faster" option in Tomcat. If your application takes 15s to generate a request, there is nothing that Tomcat can do to improve that. You'll need to profile your application to understand why requests are taking that long and then tune your application code appropriately.

While raw performance for static content may not be a good reason to use httpd, there are a number of good reasons why you might want to use httpd with Tomcat. The most frequent reason is to provide load-balancing to two or more Tomcat instances. httpd isn't the only option to so this - hardware load balancers or other reverse proxies can be used - but it is a popular choice amongst system administrators as many of them are already familiar with httpd. I'll write more on using httpd as a load-balancer in a future article.

httpd is also used with Tomcat when there is a requirement to support technologies other than Java. While Tomcat can support PHP or Perl, the support for these is better in httpd. Therefore, for sites that need a mix of technologies httpd can be used as the front-end web server, directing requests to mod_php, mod_fastcgi, mod_proxy_http (for Tomcat) or any other module as appropriate.

httpd's support for integrated Windows authentication is also a reason for using httpd in front of Tomcat. There are Tomcat based solutions for integrated windows authentication and, as these gain acceptance through wider use, this particular reason for using httpd may become less important. However, at the moment, it remains one of the more frequently cited reasons for using httpd with Tomcat.

In summary, there are good reasons for using httpd with Tomcat but raw performance for static content isn't one of them. If you are using httpd solely to improve static content performance then I recommend taking a look at the Coyote APR/native connector for Apache Tomcat.

Mark Thomas is a Senior Software Engineer for the SpringSource Division of VMware, Inc. (NYSE: VMW). Mark has been using and developing Tomcat for over six years. He first got involved in the development of Tomcat when he needed better control over the SSL configuration than was available at the time. After fixing that first bug, he started working his way through the remaining Tomcat bugs and is still going. Along the way Mark has become a Tomcat committer and PMC member, volunteered to be the Tomcat 4 & 7 release manager, created the Tomcat security pages, become a member of the ASF and joined the Apache Security Committee. He also helps maintain the ASF's Bugzilla instances. Mark has a MEng in Electronic and Electrical Engineering from the University of Birmingham, United Kingdom.


Configuring Response Headers

We're currently using Apache Httpd to handle such things as expires by type and gzip configuration. I wonder if these things can be set up in tomcat, thereby eliminating the httpd layer for us.

CDN & Throughput

I think that it is useful to use the httpd when you are configuring the Content Delivery Network.

IMHO if you use both the httpd and tomcat on different machines, each can fully concentrate only on its work. Tomcat's threads can compute your application's logic and use the whole memory for speed up the application. Whilst httpd's threads can serve the content from the disk. This can improve the throughput.

-- tom

Different Myth(?)

While this post answers the myth question of native HTTP vs Tomcat HTTP, if you are using a native HTTP to do (perhaps) other services, I'm curious about whether it's myth or truth that one should go with AJP or HTTP for the native<->Tomcat communication. The tomcat documentation mostly seems to suggest that this should be AJP rather than HTTP - is this still just a myth?

News Greek

Hi there, I discovered your blog per Google bit searching for such kinda educational advise moreover your inform beholds very remarkable for me.
cyprus news today

cmx videomts

Software avchd converter convert avchd video files to avi, mp4, wmv, mov mod converter free download to convert HD camcorder files. mts to avi mp4 mov mkv iMovie, FCP/FCE with mts converter, so to convert mts files for your PC and mobiles. domate

The Salvation Diet Review

In this article understand the most important thing, the item will give you a keyword rich link a great useful website page:
The Salvation Diet

I would really

I would really want to see this person directly and learn from him how to be such a good man like him. I learned from the story behind the campaign that it was his own personal experience that made him want to give a free hug to just anyone who wants and needs it. Gasverbruik - OptiVolt


The explanation of using httpd in front of Apache Tomcat is very helpful to students like me. The post is so explanatory and it helped me to know more about the latest Apache Tomcat. Keep up the good work guys. port glass

I think this is an

I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.About the salvation diets


8 ball pool hack iphone You possess lifted an essential offspring..Blesss for using..I would want to study better latest transactions from this blog..preserve posting.. astuce clash of clans

contact hotmail

I have bookmarked you to check out new stuff of your blog. A must read!!!! contact hotmail


Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. mobile phone signal boosters

Visit this website

This is a very good post which I really enjoy reading. It is not every day that I have the possibility to see something like this. Visit this website

how to recover iphone contacts

Thank you for all that you have given to me, hopefully all of these are useful for all of us. how to recover iphone contacts


Very nice article, exactly what I needed. Very useful post i really appreciate thanks for sharing such a nice post. I wanna thanks to a great extent for providing such informative and qualitative material therefore often. Web design company

promo codes

Great blog article about this topic,I have been lately in your blog once or twice now.I just wanted to say hi and show my thanks for the information provided. promo codes

Munrrt Great blog article about this topic,I have been lately in your blog once or twice now.I just wanted to say hi and show my thanks for the information provided.

I have been checking out a

I have been checking out a few of your stories and I can state pretty good stuff. I will definitely bookmark your blog. Administration jobs Sydney

fitness center

Excellent posts to read keep it up and keep going on this way. And keep sharing these types of things Thanks and I read your article and I keep reading your content.. It’s very interesting.. fitness center

Writing with style and

Writing with style and getting good compliments on the article is quite hard, to be honest.But you've done it so calmly and with so cool feeling and you've nailed the job. This article is possessed with style and I am giving good compliment. Best! make a youtube video with pictures and music


I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts, have a nice weekend! Glasschiebetüren innenbereich

best wordpress themes 2016

You have raised an important issue..Thanks for sharing..I would like to read more current affairs from this blog..keep posting.. best wordpress themes 2016


Nice informative post..Thanks for sharing ..I have added it to my favorites blog site list and will be checking back soon.

Classic article from your

Classic article from your side once again. You've shown your true skills once again today. This is just the kind of article I wanted to read today. Thank you very much for giving this to me. Cheers! game hacker


Nice article. The information I got from this article was really good for me. I finally completed my project due to this information. Please, continue to give more informative articles like this. lip plumpers that actually work

The official Snapchat app is

The official Snapchat app is available on iOS and Android devices only! To locate the application, launch your device's app store. In the search, you can either snapchat free download

pheromone reviews

Nice one, there's truly some sensible points on this website a number of my readers might realize this useful; i have to send a link, several thanks. pheromone reviews

Our Burlington dental office

Our Burlington dental office is equipped with the latest technology aimed at improving your care. From intraoral cameras, which allow for quick and accurate identification of oral problems, to sedation dentistry, to same day crown service, to sending all insurance claims electronically, we truly aim to improve your dental experience. dentist burlington

Located on O'Connor Drive,

Located on O'Connor Drive, just south of Eglinton, and west of Victoria Park, Rally Sports Bar & Smokehouse brings sports and slow smoked BBQ together. Watching the game is better when there’s slow cooked wood burning BBQ to go along with it. BBQ in Toronto

You have always given your

You have always given your best to us viewers. And I've always enjoyed reading your best articles. I just wish that you will continue to give us your best in the future as well. Cheers! incense store


Thank you for posting such a great article! I found your website perfect for my needs. It contains wonderful and helpful posts. Keep up the good work! Thomas Lenou (

For this web site, you will

For this web site, you will see our account, remember to go through this info. continuing medical education

Hi there, I discovered your

Hi there, I discovered your blog per Google bit searching for such kinda educational advise moreover your inform beholds very remarkable for me. houston bakeries

Excellent article. The

Excellent article. The content of this article is truly top notch. I've not seen a much better article than this one in a long time. Everything here is just top notch. Keep giving stuff like this! How To Make Superstar Cut Outs

It's not easy to calculate

It's not easy to calculate and estimate a website price exactly. We estimate the website market price(not the business price) with using several information with gathering, collecting and analyzing data from internet resources. website traffic estimator

Do you like taking surveys

Do you like taking surveys for Amazon Gift Cards? Look at our list that analyses top 20 popular sites to take online surveys for Amazon gift cards in 2016. Our site is the place you want to be for Amazon Gift cards! Top Paid Survey Sites

The mission of New Image Auto

The mission of New Image Auto Glass is to deliver high quality auto glass products with high speed service to all of our customers. Check out our products here!

This is top notch work from

This is top notch work from you. I really liked the information that you posted here. This is the best information that I could've got on this topic. Thank you very much for publishing this. Keep it up!

Post new comment

This question is for testing whether you are a human visitor and to prevent automated spam submissions.