Home  >  Article  >  Operation and Maintenance  >  The difference between apache and nginx

The difference between apache and nginx

(*-*)浩
(*-*)浩Original
2019-10-29 13:56:499411browse

The difference between apache and nginx

Difference

The core difference between the two is that apache is a synchronous multi-process model, and one connection corresponds to one process, while nginx It is asynchronous, and multiple connections (10,000 levels) can correspond to one process (Recommended learning: apache use)

Generally speaking, web services that require performance, Use nginx. If you don't need performance and just want stability, consider apache . The latter's various functional modules are better implemented than the former. For example, the ssl module is better than the former and has more configurable items.

epoll (kqueue on freebsd) The network IO model is the fundamental reason for nginx’s high processing performance, but epoll does not win in all cases. If it provides static services, only a few A few files, apache's select model may be more performant than epoll.

Of course, this is just an assumption based on the principles of the network IO model. The real application still needs to be tested before talking about it.

A more general solution is to use nginx on the front end to resist concurrency and the apache cluster on the back end, which will work better together.

Apache

apache's rewrite is more powerful than nginx. When rewrite is frequent, use apache

apache has developed to the present and has many modules. Basically you can find everything you can think of

apache is more mature and has fewer bugs, nginx has relatively more bugs

apache is super stable

apache has relatively simple support for PHP, and nginx needs Using

apache with other backends has advantages in handling dynamic requests, but nginx is useless in this regard. Generally, dynamic requests need to be done by apache, and nginx is suitable for static and reverse.

apache is still the current mainstream, with rich features, mature technology and development community

Nginx

Lightweight, using C Writing, 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 It is blocking type. 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

nginx's design is highly modular, and writing modules is relatively simple

nginx configuration is simple, and regular configuration makes Many things have become simpler, 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 is a load balancing server and supports 7 layers. 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 run almost 7*24 without interruption, even if it is running There is no need to restart for several months, and the software version can be upgraded without interrupting service

The community is active and various high-performance modules are produced quickly

The above is the detailed content of The difference between apache and nginx. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn