• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

difference between Apache HTTP server and Tomcat?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
S Rani
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
S Rani
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Hey, check out my mega multi devastator cannon. It's wicked. It makes this tiny ad look weak:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic