Comparison of advantages and disadvantages of Apache and Nginx

Source: Internet
Author: User
: This article mainly introduces the advantages and disadvantages of Apache and Nginx. For more information about PHP tutorials, see. Http://blog.csdn.net/xifeijian/article/details/17385741

1. Advantages of nginx over apache:
Lightweight and web services, which consume less memory and resources than apache
Anti-concurrency: nginx processes requests asynchronously and non-blocking, while apache is blocking. in high concurrency, nginx can maintain low resource consumption and high performance.
Highly modular design, relatively simple writing Module
Active Communities, fast production of various high-performance modules


Advantages of apache over nginx: rewrite, which is more powerful than nginx rewrite

Dynamic page

A large number of modules can be found.
Fewer bugs and more nginx bugs

Ultra-stable

This is the reason. generally, nginx is used for web services that require performance. If you do not need stable performance, you can use apache. The various functional modules of the latter are better than those of the former, for example, the ssl module is better than the former, and there are many configuration items. Note that the epoll (kqueue on freebsd) network I/o model is the fundamental reason for the high processing performance of nginx, but not all situations are epoll winning, if only a few files are provided for the static service, the select Model of apache may be higher than epoll. Of course, this is just a hypothesis based on the principles of the network I/O model. the real application still needs to be tested.
2. as a Web server: compared with Apache, Nginx uses less resources and supports more concurrent connections, reflecting higher efficiency. This makes Nginx particularly popular among virtual host providers. In the case of high connection concurrency, Nginx is a good alternative to Apache servers: Nginx is one of the software platforms that are frequently chosen by the owners of virtual host businesses in the United States. it supports responses with up to 50,000 concurrent connections. thanks to Nginx for choosing epoll and kqueue as the development model.
Nginx serves as a server load balancer server. Nginx supports both the external services of Rails and PHP programs and the external services as an HTTP proxy server. nginx is written in C. Both system resource overhead and CPU usage are much more efficient than Perlbal.
As a mail proxy server: Nginx is also a very good mail proxy server (one of the earliest development purposes of this product is also as a mail proxy server), Last. fm describes the success and wonderful use experience.
Nginx is a simple installation, and the configuration file is very simple (it also supports perl syntax). servers with few buckets: Nginx is particularly easy to start, in addition, it can run almost without interruption and does not need to be restarted even if it runs for several months. you can upgrade the software without interruption.
3. simple Nginx configuration and complicated Apache
Nginx static processing performance is more than three times higher than Apache
Apache provides simple support for PHP, and Nginx must be used with other backend servers.
Apache has more components than Nginx.
Nginx is now the first choice for Web servers. many large Internet enterprises have already used nginx.
4. The core difference is that apache is a synchronous multi-process model. one connection corresponds to one process. nginx is asynchronous. multiple connections (tens of thousands of connections) can correspond to one process.

5. nginx processes static files well and consumes less memory. however, apache is undoubtedly the mainstream and has many rich features. so we need to combine them. of course, if you can determine that nginx is suitable for your needs, it will be more economical to use nginx.

Apache does not support multi-core processing load. we recommend that you use nginx as the front-end and apache as the backend. We recommend that you use the nginx cluster function for large websites.

6. from the usage perspective, nginx has a much higher load capacity than apache. In addition, after nginx is changed, you can run the-t command to test whether the configuration is correct. When apache is restarted, it is found that the configuration has an error and will crash. when it is changed, it will be very careful to check that there are many cluster sites, front-end nginx anti-concurrency, backend apache cluster, with good cooperation.


7. nginx processes dynamic requests. generally, dynamic requests must be processed by apache. nginx is only applicable to static and reverse requests.
8. nginx is a very unfriendly front-end server with good load performance. it is not difficult to simulate 10000 static file requests using webbench when running nginx. Apache has good support for php and other languages. In addition, apache has a powerful support network, which takes a longer time than nginx.
9. Nginx is superior to apache in the following two aspects: 1. nginx itself is a reverse proxy server 2. nginx supports layer-7 load balancing. In other cases, Nginx may support higher concurrency than apache.
10. your requirements for web server determine your choice. In most cases nginx is better than APACHE, such as static file processing, PHP-CGI support, reverse proxy function, front-end Cache, maintain the connection and so on. In Apache + PHP (prefork) mode, if PHP processing is slow or the front-end is under heavy pressure, the number of Apache processes may soar, resulting in DOS.
11. check nginx lua Module: deployment? Most people are too lazy to update nginx or learn new things.
12. for nginx, the configuration file is concise and the regular expression configuration makes many things simple and efficient, consumes less resources, and has powerful proxy functions. Therefore, nginx is suitable for front-end response servers.
13. Apache has an advantage in processing dynamic data. Nginx has good concurrency and low CPU memory usage. If rewrite is frequent, Apache is more suitable.

Source: collect and organize data from the internet


The above describes the advantages and disadvantages of Apache and Nginx, including the content, hope to be helpful to friends interested in PHP tutorials.

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.