Web Server-Apache & nginx & Tomact

Source: Internet
Author: User
Tags xml stylesheet hosting url forwarding

Web Server-Apache & nginx & Tomact

HTTP server is essentially a couple of things:

    1. Listening port
    2. Receive (accept) socket connection
    3. Parsing HTTP Requests
    4. Distributing requests using a common or private protocol
    5. Run results from requests that receive a distribution
    6. Format the result as an HTTP response and write it into the socket
    7. Close the connection or keep-alive

The difference is in what language to implement (Tomcat with Java), on the one hand is the specific protocol supported at the time of distribution, Tomcat only supports the servlet interface, Apache and Nginx support CGI, FastCGI, Reverse proxies (which can be thought of as HTTP request distribution with HTTP protocol), static resources (which can be thought of as distributed to disk Read and write), and other distribution methods (such as WSGI) that can be supported with extension modules

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. 512431261. Apache

Apache HTTP Server is a modular server that can run on almost any widely used computer platform. It belongs to the application server. Apache supports many modules, stable performance, Apache itself is static parsing, suitable for static HTML, pictures, etc., but can be extended scripts, modules and other support dynamic pages.

(Apche can support Phpcgiperl, but to use Java, you need Tomcat to support Apache in the background, and Java requests are forwarded to Tomcat for processing by Apache.) )

Cons: The configuration is relatively complex and does not support dynamic pages on its own.

2. Tomcat:

Tomcat is an application (Java) server, which is just a servlet (JSP also translated into a servlet) container that can be considered an Apache extension, but can be run independently of Apache.

3. Nginx

Nginx is a very lightweight HTTP server written by the Russians, Nginx, which is pronounced "engine X", is a high-performance HTTP and reverse proxy server, but also a IMAP/POP3/SMTP proxy server.

Second, compare 1. Comparison of Apache and Tomcat

Same point:

L both are developed by Apache organizations.

L Both have the function of HTTP service

L both are free.

Different points:

Apache is dedicated to providing HTTP services and related configurations (such as virtual hosting, URL forwarding, etc.), while Tomcat is a JSP server developed by Apache in Java EE-compliant JSP and servlet standards.

Apache is a Web server environment program that enables him to be used as a Web server, but only supports static web pages such as Dynamic Web pages (asp,php,cgi,jsp). If you want to run the JSP in the Apache environment, you need an interpreter to execute the JSP Web page, and this JSP interpreter is Tomcat.

Apache: Focus on Httpserver, Tomcat: Focus on the servlet engine, if run in standalone mode, functionally equivalent to Apache, support JSP, but not ideal for static web pages;

Apache is a Web server, Tomcat is an application (Java) server, it is just a servlet (JSP also translated into a servlet) container, can be considered an Apache extension, but can be run independently of Apache.

The actual use of Apache and Tomcat is often integrated using:

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

If the client requests a dynamic page, the Tomcat server responds to the request.

Because JSP is the server-side interpretation code, this consolidation reduces the service overhead of Tomcat.

An extension of Tomcat to Apache can be understood.

2. Nginx vs. Apache 1) The advantages of nginx versus Apache

L Lightweight, same Web service, consumes less memory and resources than Apache

L Anti-concurrency, Nginx processing request is asynchronous non-blocking, and Apache is blocking type, in high concurrency, nginx can keep low resource consumption and high performance

L highly modular design, relatively simple to write modules

L Provide load balancing

L Community Active, various high-performance modules produced quickly

2) The advantages of Apache with respect to Nginx

L Apache rewrite is stronger than nginx;

L support dynamic pages;

L support a large number of modules, covering almost all applications;

L stable performance, and nginx relative bugs more.

3) comparison between the pros and cons

L Nginx Configuration concise, Apache complex;

L Nginx static processing performance than Apache 3 times times higher than;

Apache support for PHP is relatively simple, Nginx needs to cooperate with other backend;

L Apache has more components than Nginx;

Apache is a synchronous multi-process model, a connection corresponding to a process; Nginx is asynchronous, multiple connections (million levels) can correspond to a process;

L Nginx handles static files well, consumes less memory;

L dynamic request by Apache to do, nginx only suitable for static and reverse;

L Nginx suitable for front-end server, load performance is very good;

Nginx itself is a reverse proxy server, and supports load balancing

3. Summary

L NGINX Advantages: Load Balancing, reverse proxy, processing the advantages of static files. Nginx handles static requests faster than Apache;

Apache Advantage: Handling static files is its advantage over the Tomcat server and is fast. Apache is static parsing, suitable for static HTML, pictures and so on.

L Tomcat: Dynamic parsing of containers, processing dynamic requests, is compiled Jsp\servlet container, Nginx has a dynamic separation mechanism, static request can be directly through nginx processing, dynamic request forwarding request to the background by Tomcat processing.

Apache in the processing of dynamic has advantages, nginx concurrency is better, CPU memory consumption is low, if rewrite frequent, it is more suitable for Apache.

Understanding of Reverse proxies:

The reverse proxy is a proxy server that accepts connection requests on the Internet and then forwards the requests to the servers on the internal network (Reverse proxies).

and returns the results from the server to the client requesting a connection on the Internet, when the proxy server appears as a server externally

One, Apache and Nginx difference: 1, the most important difference between the two is that Apache is a synchronous multi-process model, a connection corresponding to a process; Nginx is asynchronous, and multiple connections (million levels) can correspond to a process. Nginx handles static files well and consumes less memory. But Apache is undoubtedly still the mainstream, with a lot of rich features. So it needs to be paired. Of course, if you can be sure that Nginx is suitable for your needs, then using Nginx will be a more economical approach.

2, Nginx load capacity is much higher than Apache. The newest server also changed to Nginx. And Nginx changed configuration can be-t test the configuration has no problem.

3, Apache Restart when found that the configuration error, it will crash, change will be very cautious now see a lot of cluster station, front-end nginx anti-concurrency, back-end Apache cluster, with good.

4, Nginx processing dynamic request is chicken, general dynamic request to Apache to do, nginx only suitable for static and reverse.

5, from experience, Nginx is very good front-end server, load performance is very good, nginx, with Webbench simulation 10,000 static file request without difficulty. Apache support for languages such as PHP is very good, in addition to Apache has a strong support network, the development time is more than nginx longer, bug less but Apache does not support multi-core processing load chicken shortcomings, we recommend using Nginx to do the front end, the back end with Apache. Large web site is recommended to use Nginx self-generation cluster function.

6, in most cases, Nginx is superior to Apache, such as static file processing, php-cgi support, reverse proxy function, front-end Cache, maintenance connection and so on. In apache+php (prefork) mode, if the PHP process is slow or the front-end pressure is very high, it is easy to get a spike in the number of Apache processes, thereby denying service.

7, Apache in the processing of dynamic has advantages, nginx concurrency is better, CPU memory consumption is low, if rewrite frequent, it is Apache it!

8, in general, the need for performance of Web services, with Nginx. If you don't need performance for stability, then Apache.

Second, the advantages and disadvantages of Apache and Nginx comparison

1, the advantages of nginx with respect to Apache:

Lightweight, same Web service, consumes less memory and resources than Apache;
Anti-concurrency, Nginx processing requests are asynchronous non-blocking, and Apache is blocking type, in high concurrency, nginx can keep low resource consumption and high performance;
Highly modular design, the writing module is relatively simple;
Community active, a variety of high-performance modules produced quickly AH;
Nginx itself is a reverse proxy server, Nginx support 7 layer Load balancer, Nginx may be more than Apache support for higher concurrency,
Nginx configuration file is very concise, regular configuration makes a lot of things easy to run high efficiency, the use of less resources, powerful proxy, very suitable for the front-end response server!

2, Apache with respect to the advantages of Nginx:

Rewrite, stronger than Nginx's rewrite;
The module is super many, the basic thought can be found;
Fewer bugs, nginx bugs relatively more;
Ultra-Stable, Aapche remains the first of most companies because its mature technology and development community has also been a very good performance.

Third, why now Nginx is the preferred WEB server

As a WEB server: using fewer resources compared to Apache,nginx, supporting more concurrent connections and increasing efficiency, this makes Nginx particularly popular with virtual hosting providers. In the case of high connection concurrency, Nginx is a good alternative to Apache server: Nginx in the United States is a virtual hosting business owners often choose one of the software platform. Capable of supporting up to 50,000 concurrent connections, thanks to Nginx for choosing Epoll and Kqueue as the development model.
Nginx as a Load Balancer server: Nginx can either directly support the internal Rails and PHP programs outside the service, also can support as an HTTP proxy server external services. Nginx is written in C, which is much better than Perlbal, both in terms of system resource overhead and CPU efficiency.

As a mail proxy: Nginx is also a very good mail proxy server (one of the first to develop this product is also as a mail proxy server), Last.fm describes the success and wonderful use of experience.

Nginx is a very simple installation, the configuration file is very concise (also can support Perl syntax), Bugs very few servers: Nginx boot is particularly easy, and can be almost uninterrupted operation, even if the run for several months do not need to restart. You will also be able to upgrade the software version without interruption of service.

Nginx configuration Concise, Apache complex, Nginx static processing performance 3 times times higher than Apache, Apache support for PHP is relatively simple, Nginx need to cooperate with other backend, Apache more than Nginx components. Now Nginx is the Web server's preferred Web server software collation

(1) Apacheapache is the first Web server software in the world to use. It can run on almost all of the widely used computer platforms. Apache originates from the NCSAHTTPD server and has been modified many times to become one of the most popular Web server software in the world. Apache is taken from the "a patchy server" pronunciation, meaning is full of patches of the server, because it is free software, so constantly someone to develop new features, new features, modify the original flaw. Apache is characterized by simple, fast, stable performance, and can be used as a proxy server.

(2) IIS is an abbreviation for English Internet Information Server, which translates into Chinese as "Internet Information Service". It is Microsoft's main push server, the latest version is Windows2008 included in the IIS 7,iis and Window server fully integrated, so users can take advantage of Windows Server and NTFS (NT File System, NT File System) built-in security features to build powerful, flexible and secure Internet and intranet sites.

(3) Gfegoogle Web server, the number of users soared. Currently pressing IIS.

(4) Nginx is not only a small and efficient HTTP server, but also can make an efficient load balancing reverse proxy, it can greatly improve the concurrency capability of rails application by accepting user's request and distributing to multiple mongrel processes.

(5) LIGHTTPD is a BSD-licensed open source Web server software developed by the German leader Jan Kneschke, whose fundamental purpose is to provide a secure, fast, compatible and flexible Web server environment dedicated to high-performance websites. It has very low memory overhead, low CPU usage, good performance, and rich module features. LIGHTTPD is one of the best in many opensource lightweight Web servers. Support FastCGI, CGI, Auth, output compression (outputs compress), URL rewriting, alias and other important functions.

(6) Zeus is a very good Web server running under UNIX and is said to be one of the most efficient Web servers with performance exceeding Apache.

(7) Sun's Java System Web server is the previous Sun one Web servers. are primarily on mission-critical Web servers that run Sun's Solaris operating system. Its latest version number is 6.1 and can support x86 version solaris,red Hat linux,hp-ux 11i, IBM AIX, and even windows, but most of its users have selected the SPARC version of the Solaris operating system.

(8) Resin provides the fastest jsp/servlets operating platform. With the support of Java and JavaScript, resin can flexibly select the appropriate development language for the task. Resin's Advanced language xsl (XML stylesheet language) allows the separation of form and content.

(9) Jetty is an open-source servlet container that provides a running environment for Java-based Web content, such as JSPs and Servlets. Jetty is written in the Java language, and its APIs are published as a set of jar packages. Developers can instantiate a jetty container as an object that can quickly provide network and web connectivity for some Java applications that run independently (stand-alone).

BEA WebLogic is a Java application server for the development, integration, deployment, and management of large distributed Web applications, Web applications, and database applications. Introduce the dynamic capabilities of Java and the security of Java Enterprise standards into the development, integration, deployment, and management of large-scale network applications. BEA WebLogic Server has the performance, scalability, and high availability required to handle critical Web application issues.

Tomcat is a core project of the Apache Software Foundation (Apache Software Foundation) Jakarta Project, developed by Apache, Sun, and other companies and individuals. With Sun's involvement and support, the latest servlet and JSP specifications are always reflected in Tomcat. Because of the advanced Tomcat technology, stable performance, and free, so deeply loved by Java enthusiasts and have been recognized by some software developers, become the most popular Web application server.

node. js is a JavaScript runtime environment (runtime). It actually encapsulates the chrome V8 engine. The V8 engine executes JavaScript very fast and performs very well. node. JS optimizes some of the special use cases, providing an alternative API that allows V8 to run better in a non-browser environment. node. JS is a platform built on the chrome JavaScript runtime to easily build responsive, easy-to-scale Web applications. node. js is lightweight and efficient with event-driven, non-blocking I/O models, making it ideal for running data-intensive real-time applications on distributed devices.

Web Server-Apache & nginx & Tomact

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.