nginx, tomcat, apache difference

server Apache Nginx Tomcat
Types of Http Server HTTP Server Http Server HTTP Server Application Server Application Server
Resources Static resources? Static resources Dynamic Resource

Glossary:

1, Runtime operating environment

2, Interface Interface

3, JVM is an acronym for Java Virtual Machine (Java virtual machine)

1, Servlet is a small service program

2, JSP, Java Server Pages, the Java server pages, dynamic pages

3, an HTTP server is essentially an application, by binding the IP address of the server and one tcp port monitor receives and processes the HTTP request, so that the client (generally is IE, Firefox, Chrome this browser) You will be able to get the web page (HTML format), document (PDF format), audio (MP4 format), video (MOV format) and so resources on the server via HTTP protocol. The following diagram describes this process is:

 

 

 

 

The Apache / Nginx (  / əpætʃɪ /) should be called HTTP Server, which generated httpd service after installation.

Tomcat  (/ tɒmkæt /) is a Application Server, or, more accurately, it is a "Servlet / JSP" container application (Ruby / Python language development and other applications can not be run directly on Tomcat)

Static and dynamic understanding:

(1) Tomcat can be dynamically generated and returned to the client resource. Because if you want to use a Java program to dynamically generate content resources, the use of this type of HTTP server hard to do. Java Servlet technology and derivative of Java Server Pages technology allows a Java program also has the ability to handle the HTTP request and returns the content (dynamically controlled by the program) is, Tomcat is the support vessel to run Servlet / JSP applications (Container)

 

 

 

(2) Apache HTTP Server and Nginx can be the contents of a text file is returned to the client through the HTTP protocol, but the contents of the text file is fixed - content that is whenever anyone to access it gets They are identical, so the resources we call static resources.

(3) Dynamic resource is the opposite, at different times, different clients to access content get is different. Such as the display page that contains the current time, the IP address of the current page display

(4) Apache HTTP Server and Nginx itself does not support the generation of dynamic pages, but they can be supported (for example, to dynamically generate content by Shell, PHP, Python script) by other modules.

 

Tomcat runs on the JVM, and it is the same as the HTTP server, the binding of IP address and TCP port to listen, but also contains the following accusations:

  • Servlet life cycle management program
  • The URL mapped to a specific Servlet for processing
  • Servlet cooperation with the program processing the HTTP request - HTTP request generated and passed to the Servlet HttpServletResponse object for processing, the Servlet HttpServletResponse object in the generated content back to the browser


Although Tomcat HTTP server can also be considered, but usually it will still fit together and use Nginx:

  • Dynamic and static resources isolated - use Nginx reverse proxy function to distribute requests: All requests dynamic resources to Tomcat, and requests for static resources (such as images, videos, CSS, JavaScript files, etc.) directly to the browser returned by Nginx , this can greatly reduce the pressure on Tomcat.
  • Load balancing, traffic when the pressure increases, may be insufficient to handle a Tomcat instance, then the time can start multiple instances of Tomcat extended horizontally, and the load balancing function Nginx can distribute requests to the various instances by the algorithm deal with
  • Analogy:

        nginx / apache a truck, it can be installed on top of something, such as html, etc. (static). But can not hold water (dynamic), must be filled with water to the bucket (container), Tomcat is a bucket (like Java installed water), and this bucket can be placed on the car, it may not be placed on trucks .

    The client (browser): people;

        nginx / apache: Trucks;

    Static page: Towels;

    tomcat: bucket;

    Dynamic page: water.

    People bring a towel, you can pick up directly from the truck;

        People bring water, you need to find the car barrel by truck, in order to achieve (a barrel can not be placed in the car, put the barrel somewhere else who alone can take to the water);

The difference between nginx and apache

Apache Nginx relative advantages:
lightweight, from the same web service, use less memory than apache and resources;
anti concurrent, non-blocking Nginx processing request is asynchronous to support more simultaneous connections, but it is obstructive apache in a highly concurrent nginx
to maintain high performance low resource consumption;

(The core difference is that apache is synchronized multi-process model, a process corresponding to a connection; nginx is asynchronous, multiple connections (million level) may correspond to a process)
simple configuration;
highly modular design, the preparation module is relatively simple;
community activists.
The relative merits of Apache Nginx:
rewrite, rewrite nginx powerful than the;
module over more basic thought can be found;
little bug, nginx relatively large number of bug;
ultra-stable.

 

Link: https: //www.zhihu.com/question/32212996/answer/87524617

 


 

Guess you like

Origin www.cnblogs.com/dashu123/p/11653515.html