aspose file tools*
The moose likes Tomcat and the fly likes difference between Apache HTTP server and Tomcat? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "difference between Apache HTTP server and Tomcat?" Watch "difference between Apache HTTP server and Tomcat?" New topic
Author

difference between Apache HTTP server and Tomcat?

S Rani
Greenhorn

Joined: Jul 10, 2005
Posts: 5
Hi All,

I am new to this subject and am really confused. I would like know the difference between Apache HTTP server and Tomcat? Also difference between Web Server and Application Server?

Thank you
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Hi,

Welcome to JavaRanch!
"Apache" is the name of a foundation that write open-source software. Apache HTTPD is a web server written in portable C (when people say "Apache", they usually mean Apache HTTPD.) It mostly serves static content by itself, but there are many add-on modules (some of which come with Apache itself) that let it modify the content and also serve dynamic content written in Perl, PHP, Python, Ruby, or other languages.

Tomcat is primarily a servlet/JSP container. It's written in Java. It can serve static content, too, but its main purpose is to host servlets and JSPs. Although it's possible to get Tomcat to run Perl scripts and the like, you wouldn't use Tomcat unless most of your content was Java.

It's actually possible to use both Apache and Tomcat together, so that Apache serves the static content, and Tomcat the Servlets and JSPs. Depending on various factors, this may or may not be a good idea.

An "application server" is a fuzzy concept. Really, it just means software that hosts pluggable application code. You could call Apache and Tomcat application servers and not really be wrong. But usually when you say "application server" you mean more than that. For example, a Java application server usually hosts EJBs as well as servlets and JSPs, and it usually has fancy tools for deploying and configuring applications that go way beyond what Apache or Tomcat have.


[Jess in Action][AskingGoodQuestions]
S Rani
Greenhorn

Joined: Jul 10, 2005
Posts: 5
Thanks for your reply. But I still have some questions
So you mean to say that I cannot run my JSP/servlets with Apache?

Should Web Servers contain any specific functionalities so that it can be called a Web Server? or how can you call something as a web server?

what are the other most commonly used web servers?

Thanks
SR
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

You can't run servlets/JSPs with Apache HTTPD, no. Probably someone, somewhere, has written a module that lets you do this, but I'm not aware of one, and even if it exists, it's not widely used. That's what Tomcat is for -- or another servlet container.

A "Web server" is anything that serves files via the HTTP protocol. You can write a very simple one in Java in a dozen lines of code (a server that serves a single fixed file, for example.) It's very easy to write one, so there are many thousands in existence.

What are other commonly used ones? There are many. After Apache, I think the next most "popular" is IIS, Microsoft's Internet Information Server, just because it's the default on that platform. Then there are hundreds more.

The folks at Netcraft keep track of this stuff. You can see that after Apache and IIS, everything else is pretty much in the noise.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Ernest Friedman-Hill:
You can't run servlets/JSPs with Apache HTTPD, no. Probably someone, somewhere, has written a module that lets you do this, but I'm not aware of one, and even if it exists, it's not widely used. That's what Tomcat is for -- or another servlet container.


The predecessor to Tomcat was called "JServ" and was a module for Apache HTTPD. The project is, for the most part, dead. You can integrate Tomcat with HTTPD if you really need to.

A lot of us are just using Tomcat as a standalone server.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
S Rani
Greenhorn

Joined: Jul 10, 2005
Posts: 5
Thank you very much for clarifying my doubts. I am really glad that I found JavaRanch forums.

what does 'D' stand for in HTTPD? is it daemon? but why are you calling it HTTPD instead of HTTP server as listed on the Apache website?

Thanks
SR
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

what does 'D' stand for in HTTPD?

Daemon (the Unix version of a windows service)

but why are you calling it HTTPD instead of HTTP server as listed on the Apache website?

HTTP Server. Is that what they call it now?
If I had to guess, I'd figure they changed it from daemon to server to make it more attractive to Windows users.





.
[ July 11, 2005: Message edited by: Ben Souther ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by Ben Souther:

The predecessor to Tomcat was called "JServ" and was a module for Apache HTTPD.


Shudder I must have blocked that out. Used to use it myself. Not entirely sure which was more frustrating, Apache JServ or... shudder... JWS 1.0 . It's a wonder anyone ever started using servlets at all...



A lot of us are just using Tomcat as a standalone server.


Including me -- I made the switch from JK2 to standalone Tomcat last week! So far, system load has stayed lower than the old average, and response times are down too.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61768
    
  67

Not entirely sure which was more frustrating, Apache JServ or... shudder... JWS 1.0


Nothing like drudging up unpleasant memories from the past!

And, like Ben and Ernest, I've found stand-alone Tomcat to be more than adequate.

P.S. I think I still have some old JWS disks lying around... maybe I should microwave them just for fun!


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Bear Bibeault:
P.S. I think I still have some old JWS disks lying around... maybe I should microwave them just for fun!


They make good coasters -- once all the AOL and .Net Framework disks are gone.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61768
    
  67

Yeah, but how many coasters can one use in a lifetime?

I somehow managed to stay off the .NET mailing list, but AOL certainly provides me with enough plastic to last through eternity!
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
I have a few questions for those who are using tomcat as a stand-alone server or for those who have used the Apache-Tomcat collaboration in the past or current.

On under what circumstances would you recommend to someone on using Apache and Tomcat together as opposed to just Tomcat?


Can Tomcat do just about everything Apache does?

I hear alot of responses from people just using Tomcat as their stand-alone web server, and moving away from Apache.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

If your primary business was running Perl CGIs, or PHP, or Ruby on Rails, or basically anything other than Servlets/JSPs, then using Apache is definitely preferable. Tomcat can do these things (or some of them, with a little work) but with Apache it'll be easier to set up and much more efficient.

Apache can do all sorts of fabulous stuff with URL rewriting, and proxying, and other industrial-strength stuff that Tomcat has, so if you're an ISP hosting lots of sites on one box, Apache is definitely going to make your life easier.

When does it make sense to use them both? Well, if you need to run Servlets, but need some of these other things, too. But my primary web site is fairly modest, with moderate traffic, and all JSP/Servlet/static HTML, and Tomcat works great for it.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If you have a real lot of static content. Apache HTTP (which I'll refer to as Apache) can serve it up quicker than Tomcat. Also, Tomcat has a CGI servlet but you're better off using Apache if you have to integrate with anything but a trivial amount of Perl or PHP. I've also seen articles that show how to use Apache as a load balancer for several Tomcat instances.
Tomcat, on it's own can't bind to ports below 1024 on Unix systems unless it's run as root. Apache binds to ports 80 and 443 as root and then downgrades itself to a user with lesser privileges. A lot of people have integrated the two just so they could run on port 80 without Tomcat running as root.
There are other options now (such as http://jakarta.apache.org/commons/daemon).

A couple things to keep in mind:
Several years ago the performance difference between Apache and Tomcat significantly greater than it was now. Both Tomcat and the Java JVM have come a long way and the gap has narrowed quite a bit. However there are still a lot of links out there to articles that (rightly at the time) stated that Tomcat alone wasn't sufficient for a real production app. Consider the date of the article if you run across one of these.

When looking at your costs, don't marginalize maintenance. Apache is written in C. Tomcat is written in Java. The connectors are written with a combination of the two. The people writing the connectors generally have to play catch up whenever either Tomcat or Apache roll out new releases. Keeping all three up to date can involve a lot of work and headaches. Figure that cost in up front and decide if the performance increase (if there is one at all for your app) that you get by connecting the two is worth the extra effort.

Consider your application. If the majority of pages are dynamically built Servlets or JSP pages then the overhead involved with passing the requests to and from Apache could actually cost you more in performance that you'll gain by having Apache serve up your static resources or by having Apache handle all of your SSL encryption. On the other hand if you only have a handful of dynamic pages and lots of static ones, having Apache do the lion share of the work may be more efficient.

I would start out developing with Tomcat as a standalone. When you get to the point in your project where you can load test and profile the app to find it's bottlenecks, THEN look at all of your options for improving performance (if it's even necessary). Fronting the app with Apache is one, better hardware is another, clustering, more DB licenses, etc....
Don't just assume that your app will run faster with Tocmat running behind Apache. Also, don't assume the benefits (if any) will outweigh the maintenance costs.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by Ben Souther:

Tomcat, on it's own can't bind to ports below 1024 on Unix systems unless it's run as root. Apache binds to ports 80 and 443 as root and then downgrades itself to a user with lesser privileges. A lot of people have integrated the two just so they could run on port 80 without Tomcat running as root.
There are other options now (such as http://jakarta.apache.org/commons/daemon).

One really clever option -- which I'm using, but didn't invent -- is to run Tomcat on a non-privileged port as an ordinary user, but use iptables to forward port 80 traffic to that non-privileged port inside the kernel. It's easy to set up and works like a champ!

[ EFH: Fixed formatting. ]
[ July 12, 2005: Message edited by: Ernest Friedman-Hill ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

That was one I've had in mind but have never tried.
If you know of a HOWTO link.....
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by Ben Souther:
That was one I've had in mind but have never tried.
If you know of a HOWTO link.....


Yes I do, actually! Because I just set this up last week, I was able to find the link to the reference I used in my browser history. Here it is:

http://www.klawitter.de/tomcat80.html
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Ernest Friedman-Hill:


Yes I do, actually! Because I just set this up last week, I was able to find the link to the reference I used in my browser history. Here it is:

http://www.klawitter.de/tomcat80.html


Thank you Ernest, that's exactly the type of link I was hoping for.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: difference between Apache HTTP server and Tomcat?