Server Apache with Tomcat and Nginx understanding and comparative analysis of detailed

  • 2021-01-19 22:36:18
  • OfStack

1 problem

Apache service is used, the background is php language, then the server with the linux C/C + +, will often hear Apache server, and then practice before the company java server, then remember to use the nginx reverse proxy server and tomcat, request after nginx first and then go forward by tomcat request, then understanding and tomcat and nginx Apache server is a bit fuzzy, and access to relevant information to use today and the scene

2 Apache, Tomcat, Nginx nouns interpretation

1 ) Apache

Apache Server HTTP Server is a modular server that can run on almost any widely used computer platform. Linux, Unix, Windows, etc.

ES34en supports more modules, stable performance, ES35en itself is static parsing, suitable for static ES36en, pictures, etc., for example, I used ES37en before, is static, but you can support dynamic pages through extended scripts, modules, etc.

Apache can support PHP, cgi, perl, but to use Java, you need Tomcat to support Apache in the background and forward Java requests from Apache to Tomcat for processing.

Disadvantages: configuration is relatively complex, itself does not support dynamic pages, plug-in extension is needed to support dynamic pages, such as FastCGI, Tomcat, make j2ee friend know what we need to use dynamic pages to jsp, so we need to parse Tomcat dynamic pages, Tomcat is servlet container, of course it can be independent of Apache, tomcat directly as a server

2 ) Tomcat

Tomcat is an application (Java) server, it is just a container of Servlet(JSP also translated into Servlet), can be considered as an extension of Apache, but can run independently of Apache, that is, there is no Apache, only Tomcat can also parse static and dynamic pages (jsp),

3 ) Nginx

Nginx is a high performance HTTP and reverse proxy server. It is also an IMAP/POP3/SMTP proxy server. It is a high performance HTTP and reverse proxy server.

3 comparison

1) Comparison between Apache and Tomcat

Similarities:

Both are developed by the Apache organization, both have the functionality of the HTTP service, and both are open source and free.

Difference:

Tomcat is an JSP server developed by the Apache organization under the JSP and Servlet standards. ES10108EN is designed to provide HTTP services and associated configurations (such as virtual hosting, URL forwarding, etc.)

b) Apache is an Web server environment program. It can be used as Web server, but only supports static web pages such as ASP, PHP, Freemarker. If you want to run java server with dynamic language such as jsp, you need Tomcat interpreter to parse jsp,Apache is not able to parse, remember.

c) Apache focuses on HTTP, Tomcat focuses on Servlet container, support JSP, but for static web pages is not ideal, that is to say Apache and Tomcat this two servers, Apache static file processing ability is stronger than Tomcat,Tomcat is useful for dynamic language (jsp), we can use Apache to process static files, use Tomcat to process dynamic files

d) Apache is an Web server, and Tomcat is an application (Java) server, which can be considered an extension of Apache, but can be run independently of Apache

Practical use:

Apache+Tomcat(if java server)

If the client requests a static page, only the Apache server is required to respond to the request.

The client requests the dynamic page, the Tomcat server responds to the request, and the JSP server interprets the code, so the integration can reduce the service overhead of Tomcat.

It is understood that Tomcat is an extension of Apache.

2) Comparison of Nginx with Apache

1 Nginx advantages

a) is a lightweight web service that uses less memory and resources than apache.

b) is anti-concurrency, nginx handles requests asynchronously and non-blocking, with multiple connections (10,000 level) corresponding to one process, while apache is synchronous blocking, synchronous multi-process model, with one connection for one process

c) is highly modular in design, making it relatively easy to write modules.

d) to provide load balancing

e) simple configuration

Nginx static processing performance is more than 3 times higher than Apache

e) nginx is suitable for static and reverse proxies only

Understanding of reverse proxy:

Reverse proxy (Reverse Proxy) means that the proxy server accepts the connection request on internet and forwards the request to the server on the internal network for processing, but does not process it itself.

The result obtained from the server is returned to the client requesting a connection on internet. At this time, the proxy server behaves as an web server, and actually only does forwarding, but does not do processing.

2 Apache advantages

a) apache's rewrite is more powerful than nginx.

b) supports dynamic pages.

c) supports many modules, basically covering all applications.

d) stable performance.

e) Apache support for PHP is simple

f) compared to nginx, dynamic requests are better done by apache.

3) Comparison between Nginx and Tomcat

We know Nginx1 static processing ability is very strong, but can't parse dynamic languages such as (jsp), we also need to interpret Tomcat jsp, so dynamic processing, we use Tomcat 1, static processing using Nginx, I worked as an intern before the company's web site is Nginx + Tomcat combination, Nginx have the effect of the reverse proxy, if it is a static treatment by Nginx, handling of dynamic Tomcat request to get the background, Nginx is more static than Tomcat, so we need to go through Nginx first, so we don't need to use the Apache server.

4 summary

a) Static processing capability:

[

Nginx(at least 3 times of Apache) > Apache BBB>281EN

]

b) Nginx advantages: load balancing, reverse proxy, static file processing advantages, which is why the java server Tomcat first through the Nginx server to process 1 wave, (only forward the request, do not do other operations, can see the above reverse proxy explanation), Nginx concurrency is better, CPU memory footprint is low

Apache Advantages: It is faster to process static files than Tomcat servers. Apache is static analysis, suitable for static HTML, pictures, of course, reading and writing ability is strong, if rewrite frequent, it is still Apache is more suitable, more stable, dynamic processing has the advantage. The premise is that there is no Tomcat, which means it is not an java server.

d) Tomcat: dynamic parsing container, processing dynamic requests, is compiled JSP, Servlet container, Nginx has dynamic separation mechanism, static requests can be directly processed by Nginx, dynamic requests to forward the request to the background for Tomcat processing.

conclusion


Related articles: