What is the difference between Tomcat and Nginx,apache?
Answer one:
The master said Apache, referring to the Apache Software Foundation under a project--apache HTTP server Project;nginx is also an open source HTTP Server Software (of course, it can also be used as a mail proxy server, A generic TCP proxy server).
An HTTP server is essentially an application-it usually runs on the server, binds the server's IP address and listens on a TCP port to receive and process HTTP requests, so the client (ie, Firefox, generally A browser such as chrome can get the Web page (HTML format), the document (PDF format), audio (MP4 format), video (mov format) and other resources on the server via the HTTP protocol. This process is described:
Not only Apache HTTP server and Nginx, the majority of programming languages contained in the class library also implemented a simple HTTP server to facilitate the use of developers:
- Httpserver (Java HTTP Server)
- Python Simplehttpserver
Using these class libraries makes it very easy to run an HTTP server that can provide HTTP services by binding IP addresses and listening to TCP ports.
Apache Tomcat is another project under the Apache Foundation that, compared to Apache HTTP server, Tomcat can
DynamicThe build resource and return to the client. Apache HTTP server and Nginx are able to return the content of a text file to the client through the HTTP protocol, but the content of the text file is fixed-that is, whenever and whenever anyone accesses it, the content is exactly the same, such resources we call
StaticResources. Dynamic resources, on the other hand, have different content at different times and different client access, for example:
- Contains the page that displays the current time
- Page showing the current IP address
Apache HTTP Server and Nginx natively do not support generating dynamic pages, but they can be supported by other modules (e.g., dynamically generated content through shell, PHP, Python scripts).
This type of HTTP server is difficult to use if you want to use Java programs to dynamically generate resource content. Java servlet Technology and the derived Java Server pages technology allow Java programs to also have the ability to handle HTTP requests and return content (dynamically controlled by the program), which Tomcat supports to run servlet/ A container for JSP applications (Container):
Tomcat runs on top of the JVM, which, like an HTTP server, binds IP addresses and listens to TCP ports, along with the following accusations:
- Managing the life cycle of a servlet program
- Map URLs to the specified servlet for processing
- Working with the Servlet program to process HTTP requests-generating HttpServletResponse objects based on HTTP requests and passing them to the servlet for processing. Returns the content generated by the HttpServletResponse object in the servlet to the browser
Although Tomcat can also be considered an HTTP server, it is usually used in conjunction with Nginx:
- Static and dynamic resource separation--using Nginx's reverse proxy function to distribute requests: All dynamic resource requests are given to Tomcat, while requests for static resources (e.g., video, CSS, JavaScript files, etc.) are returned directly from Nginx to the browser. This can greatly reduce the pressure on Tomcat.
- Load balancing, when the business pressure increases, perhaps a tomcat instance is not enough to handle, then you can start multiple Tomcat instances to scale horizontally, and nginx load balancing function can distribute the request through the algorithm to different instances for processing
Answer two:
The concept of Web Server is too broad.
Strictly speaking, Apache/nginx should be called "http server", while Tomcat is a "application server", or, more precisely, a "servlet/jsp" application container (Ruby/python Applications that are developed in other languages cannot be run directly on Tomcat).
An HTTP Server is concerned with the transmission and access control at the HTTP protocol level, so you can see functions such as proxies, load balancing, and so on Apache/nginx. The client accesses the resources stored on the server (HTML files, picture files, and so on) through HTTP server. With CGI, the processed content can also be distributed over an HTTP server, but an HTTP server always simply transmits the files on the server to the client through the HTTP protocol.
The application server is a container for application execution. It needs to support the runtime of the development language (in the case of Tomcat, Java) to ensure that the application works properly on the application server. Second, you need to support application-related specifications, such as class libraries, security features. For Tomcat, it is necessary to provide a standard class library, Interface, and so on that Jsp/sevlet needs to run. For convenience, the application server often integrates the functionality of the HTTP server, but is not as powerful as a professional HTTP server, so the application server is often running behind the HTTP server, executing the application, converting the dynamic content into static content, and passing the HTTP Ser Ver is distributed to the client. Answer three:
Apache and Nginx can be categorized as belonging to a static page server. Tomcat belongs to the Java servlet container, which is used to generate dynamic pages.
Apache is a relatively old static page server, comparing many existing plug-ins, including proxy, SSL support, dynamic programming language processing and so on.
Nginx and Apache almost, there are plug-ins support dynamic programming language processing, but Nginx IO model is more suitable for running agents than Apache. Therefore, it is generally used as a front-end buffer agent.
Tomcat is the Java servlet container, which is used primarily to run Java Web functions and, of course, provides a simple static page conversion.
Answer four: 1. That's not the exact thing to say. Tomcat/jetty and so on. This category is called Web Container, which is the Web container, the so-called container, is and he is responsible for the management of the entire life cycle. So Web container manages the life cycle of the entire servlet. A similar spring IOC container manages the lifetime of the entire bean. The Glassfish/weblogic-Application server will manage more, including named Servers, EJBS, and other resources. 2. Nginx/apache can be said to be Web server. That is, they can deal with static resources, such as HTML, images, etc., but not if the servlet is handed to it. Therefore, the nginx is generally placed on the front-end processing of static resources, if there is a corresponding servlet request, through the AJP to the back of the Tomcat, jetty for processing.
Answer five: Tomcat is miss, Nginx is mother sang, APPACHE+JK can also play the role of Mother Mulberry.
The difference between Tomcat and Nginx,apache