Why use Apache Web Server before Glassfish or Tomcat?

Is it good to use Apache Webserver before GF or Tomcat? Does performance / security improve?

Or is there no reason to use the Apache web server with GF?

+52
tomcat apache glassfish
Feb 25 '11 at 20:38
source share
5 answers

Taken from http://wiki.apache.org/tomcat/FAQ/Connectors#Q3

  • clustering. Using Apache HTTP as an interface, you can let Apache HTTP act as the front door to your content on multiple instances of Apache Tomcat. If one of your Apache Tomcats fails, Apache HTTP ignores it and your Sysadmin can sleep all night. This point can be ignored if you use a hardware loadbalancer and Apache Tomcat clustering capabilities.
  • Clusters / Security. You can also use Apache as the front door for different Apache Tomcats for different URL namespaces (/ app1 /, / app2 /, / app3 / or virtual hosts). Then Tomcats Apache can be in a secure area and from a security point of view, you only need to worry about the Apache HTTP server. In essence, Apache is becoming an intelligent proxy server.
  • Security. This topic can affect everything anyway. Java has a security manager, while Apache has more intelligence and more security tricks. I will not go into this in more detail, but let Google become your friend. Depending on your scenario, it may be better than the other. But also keep in mind if you run Apache with Tomcat - you have two systems to protect, not one.
  • Additions. Adding to CGI, perl, PHP is very natural for Apache. Its a slower and bigger shred for Tomcat. Apache HTTP also contains hundreds of modules that can be connected as desired. Apache Tomcat may have this feature, but the code has not yet been written.
  • Decorators! With Apache HTTP before Apache Tomcat, you can execute any number of decorators that Apache Tomcat does not support or does not support direct code support. For example, mod_headers, mod_rewrite and mod_alias can be written for Apache Tomcat, but why reinvent the wheel when Apache HTTP did it so well?
  • Speed. Apache HTTP serves static content faster than Apache Tomcat. But if you do not have a site with high traffic, this moment is useless. But in some Apache scripts, Tomcat might be faster than Apache httpd. So mark your site. Apache Tomcat can run at httpd speed by using the appropriate connector (APR with sendFile enabled). Speed โ€‹โ€‹should not be considered a factor when choosing between Apache httpd and Tomcat
  • Socket compatibility / system stability. Apache HTTP has better socket handling regarding error conditions than Apache Tomcat. The main reason is because Apache Tomcat has to do all its socket processing through the JVM, which should be cross platform. The problem with optimizing sockets is a specific platform test. In most cases, java code is fine, but when you are also exposed to dropped connections, invalid packets, invalid requests from invalid IP addresses, Apache HTTP is better at dropping these error conditions than a JVM based program. (YMMV)
+61
Feb 25 '11 at 20:57
source share
โ€” -

Since everyone gave you reasons why Apache before Tomcat let me give you some reasons why not :

  • AJP connector does not support and does not support advanced IO , which means Comet , Websockets , etc.
  • If you are not using AJP, I noticed that when using mod_proxy for Apache there is a rather large overhead proxy. Therefore, if you are looking for low latency, Apache at the front will not be good.
  • Apache has a rather large footprint compared to Nginx or Lighttpd, etc.

Putting Apache in front NOT :

What Apache gives you more plugins and allows you to run various web technologies.

If you only need Tomcat, you are best off using HAProxy or Nginx as your load balancer.

+44
Sep 11 '11 at 12:23
source share
  • Scalability . As Amir and user384706 pointed out, you can download the balance of multiple instances of your application for Apache. This will allow you to handle more volume and increase stability in case one of your instances does not work.

  • Safety Apache, Tomcat and Glassfish support SSL, but if you decide to use Apache, most likely where you should configure it. If you need additional protection against attacks (DoS, XSS, SQL injection, etc.), you can set the mod_security web application firewall.

  • Additional features . Apache has tons of good modules available for rewriting URLs, interacting with other programming languages, authentication, and tons of other stuff.

  • Performance . If you have a lot of static content, serving it with Apache will improve your performance. If most of your content is dynamic, then using Tomcat or Glassfish will be just as fast (maybe faster). (as indicated in the answers to this question , this is no longer the case.)

+8
Feb 25 2018-11-21T00:
source share

One reason for placing Apache in front of Tomcat will be to balance the load.
Requests go to the front of the Apache server and propagate to Tomcat server containers depending on load and availability.
Clients know only one IP (Apache), but requests are distributed across several containers.
So this happens when you deploy a kind of distributed web application, and you need it. If your question is about a simple web application, then see dbyrne's answer

+1
Feb 25 '11 at 20:50
source share

If you use the LAMP stack, you can run PHP / Ruby stuff with apache and send the java file to tomcat using mod_jk.

0
Feb 25 2018-11-21T00:
source share



All Articles