In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shares with you the content of sample analysis of servers Apache and Tomcat and Nginx. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1 problem
The company server uses Apache, and the background is php language, and then the service side uses linux CumberCutter. You will often hear the Apache server, and then the java used by the intern company server, and then vaguely remember to use the nginx reverse proxy server and tomcat. The request goes through nginx and then forwards the request through tomcat, and then the understanding of the Apache server and tomcat and nginx is a little vague. Then consult the relevant materials today to compare the use scenarios and
2 explanation of the nouns of Apache, Tomcat and Nginx
1) Apache
Apache HTTP server is a modular server, which can run on almost all widely used computer platforms, such as Linux, Unix, Windows and so on.
Apache supports many modules, stable performance, Apache itself is static parsing, suitable for static HTML, pictures, etc., for example, I have used freemarker before, is also static, but can support dynamic pages by extending scripts, modules, etc.
Apache can support PHP, cgi and perl, but to use Java, you need Tomcat to support the Apache background and forward the Java request from Apache to Tomcat.
Disadvantages: relatively complex configuration, do not support dynamic pages, need plug-ins to support dynamic page parsing, such as FastCGI, Tomcat, j2ee partners know that our dynamic pages need to use jsp, so we need Tomcat to parse dynamic pages, Tomcat is a servlet container, of course, it can be independent of Apache, directly using tomcat as a server
2) Tomcat
Tomcat is an application (Java) server. It is just a Servlet (JSP also translated into Servlet) container. It can be thought of as an extension of Apache, but it can run independently of Apache, that is to say, without Apache, only Tomcat can parse static and dynamic pages (jsp).
3) Nginx
Nginx is a very lightweight HTTP server written by Russians, a high-performance HTTP and reverse proxy server, as well as an IMAP/POP3/SMTP proxy server.
3 comparison
1) comparison between Apache and Tomcat
Similarities:
Both are developed by the Apache organization, and both have the function of HTTP services, both of which are open source and free.
Differences:
A) Apache is dedicated to providing HTTP services and related configurations (such as virtual hosts, URL forwarding, etc.), while Tomcat is a JSP server developed by Apache organizations in accordance with Java EE's JSP and Servlet standards
B) Apache is a Web server environment program, which can be used as a Web server when enabled, but only static pages such as ASP and PHP,Freemarker are supported. If you want to use a dynamic language such as jsp on the java server, you need the Tomcat interpreter, which is used to parse jsp,Apache, which cannot be parsed.
C) Apache focuses on HTTP Server,Tomcat, focuses on Servlet container, and supports JSP, but it is not ideal for static web pages, that is to say, Apache and Tomcat, two servers, Apache is better than Tomcat,Tomcat in dealing with static files, and is more practical in parsing dynamic language (jsp). We can use Apache to deal with static files and Tomcat to deal with dynamic files.
D) Apache is the Web server, and Tomcat is the Java server, which can be thought of as an extension of Apache, but can be run independently of Apache
Actual use:
Apache+Tomcat (if it is a java server)
If the client requests a static page, only the Apache server is required to respond to the request.
When the client requests a dynamic page, the Tomcat server responds to the request, and the JSP interprets the code on the server side, so the integration can reduce the service overhead of Tomcat.
It can be understood that Tomcat is an extension of Apache.
2) comparison between Nginx and Apache
Advantages of 1 Nginx
A) lightweight, also a web service, takes up less memory and resources than apache.
B) Anti-concurrency, nginx handles requests asynchronously and non-blocking, multiple connections (ten thousand levels) can correspond to one process, while apache is synchronous blocking, synchronous multi-process model, one connection corresponds to one process
C) highly modular design, writing modules is relatively simple.
D) provide load balancing
E) simple configuration
F) static processing performance of Nginx is more than 3 times higher than that of Apache
E) nginx is only suitable for static and reverse proxies
Understanding of reverse proxy:
Reverse proxy (Reverse Proxy) means that the connection request on the internet is accepted by a proxy server and then forwarded to the server on the internal network for processing, which is not processed by itself.
The result obtained from the server is returned to the client requesting a connection on the internet. At this time, the proxy server behaves as a web server, which is actually forwarded and not processed.
2 advantages of Apache
A) apache's rewrite is more powerful than nginx's.
B) support dynamic pages.
C) many modules are supported, covering almost all applications.
D) stable performance.
E) Apache's support for PHP is relatively simple
F) compared to nginx, it is better for apache to do dynamic requests.
3) comparison between Nginx and Tomcat
We know that Nginx generally has a strong ability to handle static processing, but can not parse dynamic languages such as (jsp). We still need Tomcat to interpret jsp, so we usually use Tomcat for dynamic processing and Nginx for static processing. The company website I practiced before is a combination of Nginx+Tomcat, and Nginx acts as a reverse proxy. If static processing is processed through Nginx, dynamic requests are processed in the background Tomcat. This is the dynamic separation mechanism of Nginx, which I didn't quite understand before, but now I finally understand why it should be matched in this way. In the final analysis, the static processing capacity of Nginx is stronger than that of Tomcat, so we need to go through Nginx first, so we don't need to use Apache server here.
4 summary
A) static processing capacity:
Nginx (at least Apache3 times) > Apache > Tomcat
B) Nginx advantages: load balancing, reverse proxy, static file handling advantages, which is why the java server Tomcat is first processed by the Nginx server. (only forward requests and do no other operations, see the explanation of the reverse proxy above), Nginx concurrency is better, CPU memory consumption is low.
C) advantages of Apache: processing static files is its advantage over Tomcat server, and it is fast. Apache is static parsing, suitable for static HTML, pictures, of course, read and write ability is relatively strong, if rewrite is frequent, then Apache is more suitable, more stable, and has advantages in dealing with dynamic. The premise is that there is no Tomcat, which means it is not a java server.
D) Tomcat: dynamic parsing container, handling dynamic requests, is a container for compiling JSP and Servlet. Nginx has a dynamic separation mechanism. Static requests can be processed directly through Nginx, and dynamic requests are forwarded to the backend and handed over to Tomcat for processing.
Thank you for reading! This is the end of this article on "sample analysis of server Apache and Tomcat and Nginx". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.