Home Backend Development PHP Tutorial An in-depth comparison of the advantages and disadvantages of Apache and Nginx_PHP Tutorial

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

Jul 21, 2016 pm 03:05 PM
apache nginx and advantage Advantages and Disadvantages Compare go deep of Detailed explanation lightweight

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the advantages and disadvantages of templating? What are the advantages and disadvantages of templating? May 08, 2024 pm 03:51 PM

Templating: Pros and Cons Templating is a powerful programming technique that allows you to create reusable blocks of code. It offers a range of advantages, but also some disadvantages. Pros: Code Reusability: Templating allows you to create common code that can be reused throughout your application, reducing duplication and maintenance efforts. Consistency: Templating ensures that code snippets are implemented the same way in different locations, improving code consistency and readability. Maintainability: Changes to a template are reflected simultaneously in all code that uses it, simplifying maintenance and updates. Efficiency: Templating saves time and effort because you don't have to write the same code over and over again. Flexibility: Templating allows you to create configurable blocks of code that can be easily adapted to different application needs. shortcoming

Comparison of the advantages and disadvantages of PHP frameworks: Which one is better? Comparison of the advantages and disadvantages of PHP frameworks: Which one is better? Jun 04, 2024 pm 03:36 PM

The choice of PHP framework depends on project needs and developer skills: Laravel: rich in features and active community, but has a steep learning curve and high performance overhead. CodeIgniter: lightweight and easy to extend, but has limited functionality and less documentation. Symfony: Modular, strong community, but complex, performance issues. ZendFramework: enterprise-grade, stable and reliable, but bulky and expensive to license. Slim: micro-framework, fast, but with limited functionality and a steep learning curve.

How to conduct concurrency testing and debugging in Java concurrent programming? How to conduct concurrency testing and debugging in Java concurrent programming? May 09, 2024 am 09:33 AM

Concurrency testing and debugging Concurrency testing and debugging in Java concurrent programming are crucial and the following techniques are available: Concurrency testing: Unit testing: Isolate and test a single concurrent task. Integration testing: testing the interaction between multiple concurrent tasks. Load testing: Evaluate an application's performance and scalability under heavy load. Concurrency Debugging: Breakpoints: Pause thread execution and inspect variables or execute code. Logging: Record thread events and status. Stack trace: Identify the source of the exception. Visualization tools: Monitor thread activity and resource usage.

Application of algorithms in the construction of 58 portrait platform Application of algorithms in the construction of 58 portrait platform May 09, 2024 am 09:01 AM

1. Background of the Construction of 58 Portraits Platform First of all, I would like to share with you the background of the construction of the 58 Portrait Platform. 1. The traditional thinking of the traditional profiling platform is no longer enough. Building a user profiling platform relies on data warehouse modeling capabilities to integrate data from multiple business lines to build accurate user portraits; it also requires data mining to understand user behavior, interests and needs, and provide algorithms. side capabilities; finally, it also needs to have data platform capabilities to efficiently store, query and share user profile data and provide profile services. The main difference between a self-built business profiling platform and a middle-office profiling platform is that the self-built profiling platform serves a single business line and can be customized on demand; the mid-office platform serves multiple business lines, has complex modeling, and provides more general capabilities. 2.58 User portraits of the background of Zhongtai portrait construction

Reasons behind advantages and disadvantages of java framework Reasons behind advantages and disadvantages of java framework Jun 03, 2024 pm 04:50 PM

Java Framework Pros and Cons: Pros: Accelerated development Improved code quality Rich ecosystem Code reuse Cons: Performance overhead Complexity and learning curve Lack of flexibility Maintenance burden

Analysis of the advantages and disadvantages of java framework Analysis of the advantages and disadvantages of java framework Jun 05, 2024 pm 02:48 PM

The Java framework provides predefined components with the following advantages and disadvantages: Advantages: code reusability, modularity, testability, security, and versatility. Disadvantages: Learning curve, performance overhead, limitations, complexity, and vendor lock-in.

What are the advantages and disadvantages of proxy mode in java framework? What are the advantages and disadvantages of proxy mode in java framework? Jun 03, 2024 am 09:34 AM

The proxy pattern is a Java framework design pattern that mediates between the client and the target object by creating a proxy object. Its advantages include: protecting target objects, providing data integrity and security; controlling access to the target, implementing permission control and security measures; enhancing target behavior, adding additional functions such as logging, caching and transaction management; simplifying testing and facilitating mocking and stubbing goals. However, the proxy pattern also has disadvantages: Overhead: Creating and maintaining proxy objects may reduce performance; Complexity: Requires a deep understanding of the design pattern; Restricted access to targets, which may not be appropriate in some cases.

How to compare values ​​of custom types in Golang? How to compare values ​​of custom types in Golang? Jun 05, 2024 pm 01:04 PM

In Golang, values ​​of custom types can be compared by directly using the == operator for types with the same underlying representation. For more complex types, use the reflect.DeepEqual function to recursively compare the entire contents of two values.

See all articles