In-depth comparison of the advantages and disadvantages of Apache and Nginx _php skills

Source: Internet
Author: User
Tags epoll lua

1, Nginx relative to the advantages of Apache:
Lightweight, same Web service that consumes less memory and resources than Apache
anti-concurrency, Nginx processing requests are asynchronous and non-blocking, while Apache is blocking , Nginx can maintain low consumption and high performance under high concurrent conditions
highly modular design, relatively simple to write modules
community Active, a variety of high-performance modules produced quickly ah
The advantages of Apache relative to Nginx:
rewrite, stronger than Nginx's rewrite.
Dynamic Page

A large number of modules, the basic thought can be found
fewer bugs, nginx more bugs

Super Stable
existence is the reason, generally speaking, Web services that require performance, with Nginx. If the performance is not required to stabilize, then Apache it. The latter of the various functional modules to achieve than the former, such as the SSL module is better than the former, configurable items more. It should be noted here that Epoll (FreeBSD is kqueue) network IO model is the root cause of high performance nginx processing, but not all cases are epoll swept, if the static service itself provides only a few files, Apache Select The model may be more high-performance than Epoll. Of course, this is only based on the network IO Model of the principle of a hypothesis, the real application still need to be measured.

2, as a WEB server: compared to apache,nginx use less resources, support more concurrent connections, reflect higher efficiency, this makes Nginx especially by the virtual host provider welcome. In the case of high connectivity concurrency, Nginx is a good alternative to Apache servers: Nginx is one of the most frequently chosen software platforms for owners of virtual hosting businesses in the United States. can support up to 50,000 concurrent connections in response to a number ofthank Nginx for choosing Epoll and Kqueue as the development model.
Nginx as a load balancing server: Nginx can directly support Rails and PHP programs externally, and can support external services as an HTTP proxy server. Nginx use C to write, whether it is the system resource cost or CPU efficiency is much better than Perlbal.
as a mail proxy server: 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 experience.
Nginx is a very simple installation, the configuration file is very concise (also able to support Perl syntax), Bugs very few servers: Nginx startup is particularly easy, and can almost do 7*24 non-stop operation, even if run for several months does not require a reboot. You are also able to upgrade the software version without interruption of service.

3, Nginx configuration concise, Apache complex
Nginx Static processing performance is 3 times times higher than Apache
Apache support for PHP is relatively simple, Nginx need to match other backend
Apache has more components than Nginx
now Nginx is the WEB server's first choice.

4, the most important difference is that Apache is a synchronous multi-process model , one connection corresponds to a process; Nginx is asynchronous, multiple connections (million levels) can correspond to a process

5, Nginx processing of static files good, less memory consumption. But there is no doubt that Apache is still the mainstream, there are a lot of rich features. So you need to go with it. Of course, it would be more economical to use nginx if it is certain that nginx is suitable for demand.

Apache does not support multiple core processing of the missing points of the chicken ribs, recommend using Nginx to do the front end, with Apache. Large-scale Web site recommendations with Nginx-generation cluster functions

6, from the personal past use situation, nginx load capacity than Apache much higher. The newest server has also switched to Nginx. And Nginx changed configuration can-t test configuration has no problem, the Apache reboot when found that the configuration error, will be very crash, change will be very cautious now look at a lot of cluster station, front-end nginx against concurrency, back-end Apache cluster, with a good match.

7, nginx Processing dynamic request is chicken, general dynamic request to Apache to do, Nginx only for static and reverse.  

8, from my personal experience, Nginx is a very good front-end service, the load performance is excellent, in the old run on the Nginx, with webbench simulation of 10,000 of the meditation file please do not have the difficulty. Apache's support for languages such as PHP is good, and Apache has a strong network of support, and it's been nginx longer,

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

10, your demand for Web server determines your choice. In most cases, Nginx is superior to Apache, such as static file processing, php-cgi support, reverse proxy, front-end cache, maintenance connections, and so on. In apache+php (prefork) mode, if the PHP process is slow or the front pressure is very high, it is easy to have the number of Apache processes soar, thereby denying service.

11, you can look at the Nginx Lua module: Https://github.com/chaoslaw...apache than Nginx modules, can be directly implemented with LUA Apache is the most popular, why? Most people are too lazy to update to nginx or learn new things .

12, for Nginx, I like it to write a very concise configuration file, regular configuration so many things become simple to run high efficiency, less resources, powerful agent, very suitable for front-end response server

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

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.