About the advantages and disadvantages of Nginx and Apache

Source: Internet
Author: User
Tags epoll
The content of this section:
The advantages and disadvantages of Nginx and Apache

The advantages of nginx in relation to Apache:
Lightweight, similarly web service, consumes less memory and resources than Apache servers
Anti-concurrency, nginx in processing requests is asynchronous non-blocking, and Apache is blocking type, in high concurrency, nginx can keep low resource consumption and high performance
Highly modular design, relatively simple to write modules
Community active, a variety of high-performance modules produced quickly AH
The advantages of Apache with respect to Nginx:
Rewrite, stronger than Nginx's rewrite
Dynamic pages
The module is too much, the basic thought can be found
Fewer bugs, nginx bugs are relatively large
Ultra-Stable

Existence is the reason, in general, the need for performance of Web services, with Nginx. If you don't need performance for stability, then Apache. The latter's various function modules are implemented better than the former, for example, the SSL module is better than the former,
There are many configurable items. One thing to note here is that the Epoll (FreeBSD is kqueue) network IO Model is the fundamental reason for the high performance of nginx, but not all cases are epoll victory, if they provide static
Only a handful of files, Apache's Select model may be more performant than Epoll. Of course, this is just a hypothesis based on the principle of the network IO model, and the actual application still needs to be measured.

Second, as a WEB server: using less resources than Apache,nginx, supporting more concurrent connections, reflecting higher efficiency, which makes Nginx particularly welcomed by the virtual host provider. 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 our
Epoll and Kqueue were selected 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 by C, regardless
is the system resource overhead or CPU usage efficiency is much better than Perlbal.
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 successful and wonderful use of the
Inspection.
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 number of
Months do not require a reboot. You will also be able to upgrade the software version without interruption of service.

Three, Nginx configuration concise, Apache complex
Nginx static processing Performance 3 times times higher than Apache
Apache support for PHP is relatively simple, Nginx needs to cooperate with other backend
Apache has more components than Nginx
Now Nginx is the preferred WEB server

Four, the core difference is that 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

Five, nginx processing static files good, consumes less memory. But Apache is undoubtedly still the current mainstream, with a lot of rich features. So it needs to be paired. Of course, if you can determine the nginx is suitable for demand, then using nginx will be more economical
The way.
Apache does not support multi-core to download the Chicken rib shortage, recommend using Nginx to do the front end, the back end with Apache. Large Web site suggestions for the use of nginx-generation cluster function

Six, from the personal past use situation, nginx load capacity is much higher than Apache. The newest server also changed to Nginx. And Nginx changed configuration can-T test the configuration is not a problem, the Apache restart when the discovery
Configuration error, it will crash, change the time will be very cautious now see a lot of cluster station, front-end nginx anti-concurrency, back-end Apache cluster, with good.

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

Eight, from my personal experience to see, Nginx is very good front-end service, load performance is excellent, in the old Ben on the Nginx, with Webbench simulation 10,000 static file Please do not have the difficulty. Apache support for languages like PHP is good.
, in addition Apache has a strong support network, the development of the time compared to Nginx longer,

Nine, Nginx is superior to Apache's main two points: 1.Nginx itself is a reverse proxy server 2.Nginx support 7 layer load balancing; Of course, nginx may support higher concurrency than Apache, but according to Netcraft
Statistics, April 2011 of statistics, Apache still occupies 62.71%, and Nginx is 7.35%, so generally speaking, Aapche remains the first of most companies, because its mature technology and development community has also been very
The wrong performance.

Ten, the need for Web server determines your choice. 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 processing is slow or the front-end pressure is very high, it is easy to have the Apache process soared, and thus the phenomenon of denial of service.

Xi. Nginx LUA module: It is most popular to implement Apache directly with Lua.

12, for Nginx, the 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.

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

The above describes the advantages and disadvantages of nginx and Apache, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • 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.