EJB design: Apache Versus Tomcat
Why is apache used in front of tomcat, even though TomCat is much faster ? Could someone give some explanation on both. Thanks.
Most of the time, Apache is put in front of Tomcat for one of the following reasons:
1/ Apache can server static content (HTML, images, CSS, PDFs, etc...) a lot faster than Tomcat can.
Your perception of Tomcat being faster than Apache is not correct in my opinion.
2/ Apache has the capability of reverse proxying, allowing you to 'plug in' one or more web applications running on one or more Tomcat instances in one URL space.
3/ A stripped down box with only Apache running on it can be put in the DMZ, and the Tomcat server can be put in the internal network (behind a second firewall) for security reasons.
4/ Apache can be used as a load balancer over multiple tomcat instances
I personally like this approach for projects of a certain size. For smaller, less demanding applications the Tomcat-only solution may be easier to maintain.
Günther Van Roey.
One additional reason one might have to put Apache Webserver in front of a Tomcat server:
Apache has a large amount of interesting plugins that might be useful for your website (eg: mod_rewrite, ...)
By using Apache as the main webserver, and tomcat only for serving dynamic web content, you can combine the best of both worlds in one (or virtually one) site.
Günther Van Roey.
moreover Configuration can be done using mod_jk .
Apart from loadbalancing, Two apache on two diff boxes can be used so that if one of the box/apache fails/crashes than the session and user state can be maintained on the other.
so a FAILOVER can be implemented.
So clustering apache is the best solution for loadbalancing,static response and failover..