An in-depth comparison of the advantages and disadvantages of Apache and Nginx_PHP Tutorial

WBOY
Release: 2016-07-21 15:05:54
Original
716 people have browsed it

1、nginx相对于apache的优点: 
轻量级,同样起web 服务,比apache占用更少的内存及资源 
抗并发,nginx 处理请求是异步非阻塞的,而apache 则是阻塞型的,在高并发下nginx 能保持低资源低消耗高性能 
高度模块化的设计,编写模块相对简单 
社区活跃,各种高性能模块出品迅速啊 
apache 相对于nginx 的优点: 
rewrite ,比nginx 的rewrite 强大 
动态页面

模块超多,基本想到的都可以找到 
少bug ,nginx 的bug 相对较多 

超稳定 
存在就是理由,一般来说,需要性能的web 服务,用nginx 。如果不需要性能只求稳定,那就apache 吧。后者的各种功能模块实现得比前者,例如ssl 的模块就比前者好,可配置项多。这里要注意一点,epoll(freebsd 上是 kqueue )网络 IO 模型是nginx 处理性能高的根本理由,但并不是所有的情况下都是epoll 大获全胜的,如果本身提供静态服务的就只有寥寥几个文件,apache 的select 模型或许比epoll 更高性能。当然,这只是根据网络IO 模型的原理作的一个假设,真正的应用还是需要实测了再说的。 

2、作为 Web 服务器:相比 Apache,Nginx 使用更少的资源,支持更多的并发连接,体现更高的效率,这点使 Nginx 尤其受到虚拟主机提供商的欢迎。在高连接并发的情况下,Nginx是Apache服务器不错的替代品: Nginx在美国是做虚拟主机生意的老板们经常选择的软件平台之一. 能够支持高达 50,000 个并发连接数的响应, 感谢Nginx为我们选择了 epoll and kqueue 作为开发模型. 
Nginx 作为负载均衡服务器: Nginx 既可以在内部直接支持 Rails 和 PHP 程序对外进行服务, 也可以支持作为 HTTP代理 服务器对外进行服务. Nginx采用C进行编写, 不论是系统资源开销还是CPU使用效率都比 Perlbal 要好很多. 
作为邮件代理服务器: Nginx 同时也是一个非常优秀的邮件代理服务器(最早开发这个产品的目的之一也是作为邮件代理服务器), Last.fm 描述了成功并且美妙的使用经验. 
Nginx 是一个安装非常的简单 , 配置文件非常简洁(还能够支持perl语法), Bugs 非常少的服务器: Nginx 启动特别容易, 并且几乎可以做到 7*24不间断运行,即使运行数个月也不需要重新启动. 你还能够不间断服务的情况下进行软件版本的升级 . 

3、Nginx 配置简洁, Apache 复杂 
Nginx 静态处理性能比 Apache 高 3倍以上 
Apache 对 PHP 支持比较简单,Nginx 需要配合其他后端用 
Apache 的组件比 Nginx 多 
现在 Nginx 才是 Web 服务器的首选 

4、最核心的区别在于apache是同步多进程模型,一个连接对应一个进程;nginx是异步的,多个连接(万级别)可以对应一个进程 

5、nginx处理静态文件好,耗费内存少.但无疑apache仍然是目前的主流,有很多丰富的特性.所以还需要搭配着来.当然如果能确定nginx就适合需求,那么使用nginx会是更经济的方式. 

apache有先天不支持多核心處理負載雞肋的缺點,建議使用nginx做前端,後端用apache。大型網站建議用nginx自代的集群功能

6. Judging from personal past usage, the load capacity of nginx is much higher than that of apache. The latest server has also switched to nginx. Moreover, after changing the configuration of nginx, you can -t test whether there is any problem with the configuration. When apache restarts, it is found that the configuration is wrong and it will crash. I will be very careful when making changes. Now there are many cluster sites. The front-end nginx is anti-concurrency, and the back-end apache cluster , the cooperation is also good.

7. nginx is useless for handling dynamic requests. Generally, dynamic requests need to be done by apache, and nginx is only suitable for static and reverse.

8. From my personal experience, nginx is a very good front-end server with very good load performance. I opened nginx on Laoben and used webbench to simulate 10,000 servers. Static file requests are effortless. Apache has good support for languages ​​​​such as php. In addition, apache has a strong support network and has a longer development time than nginx.

9. There are two main reasons why Nginx is better than apache: 1 .Nginx itself is a reverse proxy server 2.Nginx supports 7-layer load balancing; others, of course, Nginx may support higher concurrency than apache, but according to NetCraft statistics, April 2011 statistics, Apache still holds the 62.71%, while Nginx is 7.35%, so in general, Aapche is still the first choice for most companies, because its mature technology and development community already have very good performance.

10. Your needs for web server 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 PHP processing is slow or the front-end pressure is high, it is easy for the number of Apache processes to surge, resulting in a denial of service.

11. You can take a look at the nginx lua module: https://github.com/chaoslaw... Apache has more modules than nginx. You can directly use lua to implement apache. The most popular, why? Most people are too lazy to update to nginx or learn new things

12. For nginx, I like that its configuration file is very concise. Regular configuration makes many things simple and efficient. It takes up less resources and has powerful proxy functions. It is very suitable for front-end response servers

13. Apache has advantages in processing dynamics. Nginx has better concurrency and low CPU memory usage. If If rewrite is frequent, then it should be Apache

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327663.htmlTechArticle1. Advantages of nginx over apache: lightweight, can also serve as a web service, and takes up less space than apache Memory and resources are anti-concurrency. nginx handles requests asynchronously and non-blockingly, while apache blocks...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template