The core difference between Apache and Nginx is that apache is a synchronous multi-process model, and one connection corresponds to one process; while nginx is asynchronous, and multiple connections (10,000 levels) can correspond to one process. The following article will introduce to you the differences between Apache and Nginx. I hope it will be helpful to you.
The difference between Apache and Nginx:
Apache
● Apache’s rewrite is more powerful than nginx. When rewrite is frequent, use apache
● Apache has developed to the present, and there are so many modules that you can find basically everything you can think of
●apache More Because it is mature and has fewer bugs, nginx has relatively many bugs
● Apache is super stable
● Apache’s support for PHP is relatively simple, nginx needs to be used in conjunction with other backends
● Apache has an advantage in handling dynamic requests, but nginx is useless in this regard. Generally, dynamic requests have to be handled by apache, and nginx is suitable for static and reverse.
● Apache is still the mainstream, with rich features, mature technology and development community
Nginx
● Lightweight, adopted Written in C, the same web service will occupy less memory and resources
● Anti-concurrency, nginx uses epoll and kqueue as the development model, processing requests is asynchronous and non-blocking, and the load capacity is much higher than apache , while apache is blocking. Under high concurrency, nginx can maintain low resource consumption and high performance, while apache is prone to a surge in the number of processes and denial of service when PHP processing is slow or the front-end pressure is high.
● nginx handles static files well, and the static processing performance is more than three times higher than apache
● The design of nginx is highly modular, and writing modules is relatively simple
● nginx configuration is simple, Regular configuration makes many things easier, and after changing the configuration, you can use -t to test whether there are any problems with the configuration. The apache configuration is complex. If you find that the configuration is wrong when restarting, it will crash
● nginx as a load balancing server , supports 7-layer load balancing
● nginx itself is a reverse proxy server, and can be used as a very excellent mail proxy server
● It is particularly easy to start, and can be done almost 7*24 It runs continuously and does not need to be restarted even if it runs for several months. It can also upgrade the software version without interrupting the service.
● The community is active and various high-performance modules are produced quickly
Summary
Generally speaking, for web services that require performance, use nginx. If you don’t need performance and just want stability, consider apache. A more general solution is to use nginx on the front end for anti-concurrency and an apache cluster on the back end, which will work better together.
The above is the detailed content of What is the difference between Apache and Nginx. For more information, please follow other related articles on the PHP Chinese website!