The difference between nginx and apache

1. The advantages of nginx over apache:
it is lightweight, also serves as a web service, takes up less memory and resources than apache, and is anti-concurrency. nginx processes requests asynchronously and non-blocking, while apache is blocking. Under nginx, it can maintain a low-resource, low-consumption, high-performance, highly modular design, and it is relatively simple to write modules. The community is active, and various high-performance modules are produced quickly. The advantages of apache over nginx: rewrite, more powerful than nginx's rewrite. Dynamic page
module There are too many, and you can find less bugs basically. nginx has relatively more bugs and super stable existence is the reason. Generally speaking, for web services that require performance, use nginx. If you don't need performance and only want stability, then apache. Various functional modules of the latter are implemented better than the former. For example, the modules of ssl are better than the former, and there are more configurable items. It should be noted here that the network.IO model of epoll (kqueue on freebsd) is the fundamental reason for the high processing performance of nginx, but not all cases are epoll's victory. If they provide static services, only a few For several files, apache's select model may be more performant than epoll. Of course, this is just an assumption based on the principle of the network IO model, and the real application still needs to be measured.
2. As a Web server: Compared with Apache, Nginx uses less resources, supports more concurrent connections, and reflects higher efficiency, which makes Nginx especially popular with virtual host providers. In the case of high connection concurrency, Nginx is a good alternative to the Apache server: Nginx is one of the software platforms often chosen by owners of web hosting businesses in the United States. It can support up to 50,000 concurrent connections. The number of responses, thanks to Nginx for We chose epoll and kqueue as the development model. Nginx as the load balancing server: Nginx can directly support Rails and PHP programs to serve externally, and can also support external services as an HTTP proxy server. Nginx is written in C, whether it is System resource overhead and CPU usage efficiency are much better than Perlbal. As a mail proxy server: Nginx is also a very good mail proxy server (one of the earliest purposes of developing this product is also as a mail proxy server), Last.fm describes the success And a wonderful experience. Nginx is a server with very simple installation, very concise configuration files (also supports perl syntax), and very few bugs: Nginx is very easy to start, and can almost run 7*24 uninterrupted, even if It does not need to be restarted after running for several months. You can also upgrade the software version under the condition of uninterrupted service.
3. Nginx configuration is simple, Apache is complex. Nginx static processing performance is more than 3 times higher than Apache, Apache supports PHP is relatively simple , Nginx needs to cooperate with other backends to use Apache components than Nginx, and now Nginx is the first choice for Web servers
4. The core difference is that apache is a synchronous multi-process model, one connection corresponds to one process; nginx is asynchronous, multiple Connection (10,000 level) can correspond to a process
5. Nginx handles static files well and consumes less memory. But undoubtedly apache is still the mainstream at present and has many rich features. So it needs to be matched. Of course, if it can be determined that nginx is suitable for the needs, then it will be more economical to use nginx Apache has the disadvantage that it does not support multi-core processing load. It is recommended to use nginx for the front end and apache for the back end. Large-scale websites are recommended to use the cluster function of nginx on its own behalf.
6. From the perspective of personal past usage, the load capacity of nginx is much higher than that of apache. The latest server has also switched to nginx. And after nginx has changed the configuration, you can -t test to see if there is any problem with the configuration. When apache restarts, it will be found that the configuration is wrong, and it will crash very carefully. , it fits well.
7. It is tasteless for nginx to handle dynamic requests. Generally, apache does dynamic requests. nginx is only suitable for static and reverse.
8. From my personal experience, nginx is a very good front-end server with good load performance. It is not difficult to open nginx on Laoben and use webbench to simulate 10,000 static file requests. Apache supports php and other languages ​​very well. In addition, apache has a strong support network, and its development time is longer than that of nginx.
9. The main two points of Nginx are better than apache:

  1. Nginx itself is a reverse proxy server

  2. Nginx Supports 7-layer load balancing; Of course, Nginx may support higher concurrency than apache, but according to NetCraft's statistics, in April 2011, Apache still accounted for 62.71%, while Nginx was 7.35%, so the total Said that, Aapche is still the first for most companies, because its mature technology and development community have also been very good performance.
10. Your web server needs 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, maintaining connections, etc. In the Apache+PHP (prefork) mode, if the PHP processing is slow or the front-end pressure is high, the number of Apache processes is likely to soar, resulting in denial of service.
11. You can take a look at the nginx lua module: https://github.com/chaoslaw... apache has more modules than nginx, and it is the most popular to directly use lua to implement apache, why? Most people don't bother to update to nginx or learn new
things Response server
13. Apache has advantages in processing dynamics. Nginx has better concurrency and low CPU and memory usage. If rewrite is frequent, then Apache is the best option.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326505320&siteId=291194637