Nginx

  1. Lightweight, using C to write, the same web service, will take up less memory and resources

  2. Anti concurrent, Nginx to epoll and kqueue as a development model, the processing request is asynchronous non-blocking load capacity is much higher than apache, and apache type is blocked. In a highly concurrent nginx to maintain high performance low resource consumption, while in the case of large PHP apache process or slow front-end pressure, it is prone to surge in the number of processes, thereby denying the phenomenon services.

  3. nginx to handle static files, static processing performance more than three times higher than the apache

  4. nginx highly modular design, the preparation module is relatively simple

  5. nginx configuration is simple and regular configuration makes a lot of things simple, and complete configuration change can use the -t test configuration has no problem, apache complex configuration, reboot, I noticed something goes wrong, it will collapse

  6. nginx as a load balancing server, support for Layer 7 load balancing

  7. nginx itself is a reverse proxy server, but also as a very good mail proxy server

  8. Upgrade version of the software at startup is particularly easy and can be done almost 7 * 24 uninterrupted operation, even running a few months do not need to restart, can also be uninterrupted service case

  9. Community activists, quickly produced a variety of high-performance modules

Apache

  1. apache's rewrite powerful than nginx, rewrite frequent in the case, the apache

  2. apache development to the present, the module over more basic thought can be found

  3. apache more mature, less bug, nginx relatively large number of bug

  4. apache ultra-stable

  5. apache support for PHP is relatively simple, nginx needs to cooperate with other back-end

  6. apache advantage in handling dynamic requests, nginx is tasteless in this regard, the general dynamic requests to do apache, nginx for static and reverse.

  7. apache is still the mainstream, with a feature-rich, mature technology and community development

to sum up

Both the core difference is that apache is synchronized multi-process model, a connection corresponds to a process, but nginx is asynchronous, multiple connections (million level) may correspond to a process

In general, the required performance of web services, using nginx. If no performance just stable, more consideration apache, which have various functional modules implemented former, e.g. ssl modules to better than the former, multiple items can be configured. epoll (is on freebsd kqueue) network IO model is a high-performance processing nginx fundamental reason, but not all cases are epoll victory, if itself provides static service on only a handful of a few files, apache's select high-performance model may be more than epoll. Of course, this is only based on the principle of network IO model for a hypothetical real applications still need a repeat measurement of.

More general solution is, nginx front-end anti-concurrency, apache back-end cluster, and together will be better.