Home >Operation and Maintenance >Nginx >The difference between tomcat and nginx
The servers on the web are all called web servers, but everyone has different divisions of labor.
nginx is commonly used as static content service and proxy server (not your FQ proxy), directly forwarding external requests to subsequent application services (tomcat, django or something), tomcat is more used as an application container, allowing java web app to run in it, corresponding to the same level as jboss, jetty and other things.
But nothing is absolute. nginx can also provide application functions through module development, and tomcat can also directly provide http services. It is usually used in intranets and scenarios that do not require small services such as flow control.
Apache is used less and less, and its functions generally overlap more with nginx.
Strictly speaking, Apache/Nginx should be called "HTTP Server"; while Tomcat is an "Application Server", or more accurately, a "Servlet/JSP" "Application container (applications developed in other languages such as Ruby/Python cannot run directly on Tomcat).
An HTTP Server is concerned with transmission and access control at the HTTP protocol level, so on Apache/Nginx you can see functions such as proxy and load balancing. The client accesses resources stored on the server (HTML files, image files, etc.) through HTTP Server. Through CGI technology, the processed content can also be distributed through HTTP Server, but an HTTP Server always only faithfully transmits the files on the server to the client through HTTP protocol.
The application server is a container for application execution. It first needs to support the runtime of the development language (for Tomcat, it is Java) to ensure that the application can run normally on the application server. Secondly, it needs to support application-related specifications, such as class libraries and security features. For Tomcat, it is necessary to provide standard class libraries, Interfaces, etc. required for JSP/Sevlet operation. For convenience, application servers often integrate HTTP Server functions, but they are not as powerful as professional HTTP Servers. Therefore, application servers often run behind HTTP Servers, execute applications, and convert dynamic content into static content through HTTP Server distributes to clients.
For more Nginx related technical articles, please visit the Nginx Tutorial column to learn!
The above is the detailed content of The difference between tomcat and nginx. For more information, please follow other related articles on the PHP Chinese website!