Home  >  Article  >  Operation and Maintenance  >  What is the difference between Apache and ngin servers?

What is the difference between Apache and ngin servers?

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-11-11 09:52:372857browse

What is the difference between Apache and ngin servers?

Nginx

1. Lightweight, written in C, the same web service will take up more Less memory and resources;

2. 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;

3. nginx handles static files well, and the static processing performance is more than three times higher than that of apache;

4. The design of nginx is highly modular, and writing modules is relatively simple;

5. The nginx configuration is simple, and the 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 complicated. If you find that the configuration is wrong when restarting, it will crash;

6. nginx serves as a load balancing server. Supports 7-layer load balancing;

7. nginx itself is a reverse proxy server and can be used as a very excellent mail proxy server;

8. It is very easy to start and can be almost done 7*24 uninterrupted operation, no need to restart even if it runs for several months, and the software version can be upgraded without interrupting service;

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

apache

1. Apache’s rewrite is more powerful than nginx. If rewrite is frequent, use apache;

2. Apache has developed to the present , there are so many modules, you can find basically everything you can think of;

3. Apache is more mature and has fewer bugs, while nginx has relatively more bugs;

4. Apache is super stable;

5. Apache has relatively simple support for PHP, and nginx needs to be used with other backends;

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

7. Apache is still the current mainstream, with rich features, mature technology and development community.

Summary

The core difference between the two is that apache is a synchronous multi-process model, one connection corresponds to one process, while nginx is asynchronous, multiple connections (ten thousand level) can correspond to a process.

Generally speaking, for 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 than the former. For example, the ssl module is better than the former and has more configurable items. The epoll (kqueue on freebsd) network IO model is the fundamental reason for nginx's high processing performance, but epoll does not win in all cases. If it itself provides static services, there are only a few files, and apache's The 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 in practice.

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.

php Chinese website, a large number of free apache introductory tutorials, welcome to learn online!

The above is the detailed content of What is the difference between Apache and ngin servers?. 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