search
HomeBackend DevelopmentPHP TutorialComparison between Apache and ngnix

1. PHP operating mode under Apache and ngnix.

1) There are three operating modes under Apache: CGI mode, modular mode, and FastCGI mode.

CGI mode is a relatively primitive way. Every time it receives a request, it will call php.exe, parse php.ini, load DLL, etc., which is naturally slow.

Modular mode, Apache runs php in this way by default. This is to compile php into its own module. There is no need to call the php.exe program when processing php scripts. The entire process is processed only by the Apache process, which is relatively stable.

FastCGI mode is an upgraded version of CGI mode. implements technical features similar to the connection pool, maintains the connection to the background, can be used when the request comes, and is ready to be disconnected when it ends. The next request is connected, unlike the original CGI mode that needs to be called every time .

Blocking type, a process will be created for each request, unlike Nginx which can use the same process to handle multiple requests.

2), CGI is not supported under the Nginx server, and it runs in FastCGI mode by default, and because it is asynchronous and non-blocking, it supports high concurrency scenarios.

2. Advantages of nginx over apache : 1. Lightweight, same as web service, better than apache Occupies less memory and resources 2. Anti-concurrency, nginx processes requests asynchronously and non-blockingly, while apache is blocking (synchronous multi-process) , nginx can maintain low resources under high concurrency Low consumption and high performance 3. Highly modular design, writing modules is relatively simple 4. The community is active and various high-performance modules are produced quickly

Three , The advantages of apache over nginx:

1. rewrite, more powerful than nginx’s rewrite

2. The processing performance of dynamic pages is better than nginx inx is good

3. There are so many modules that you can basically find everything you can think of

4. Few bugs, nginx has relatively many bugs

5、 Super stable

Existence is the reason. Generally speaking, web services that require performance use nginx. If you don’t need performance and just want stability, then use apache . The various functional modules of the latter are implemented better than the former. For example, the ssl module is better than the former and has more configurable items. One thing to note here is that the epoll (kqueue on freebsd) network IO model is the fundamental reason for nginx's high processing performance, but not all situations are epoll's winner. If it provides static services, only a few file, 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.


4. As a Web server: Compared to Apache, Nginx uses less Resources , support more concurrency Connection reflects higher efficiency, this This makes Nginx especially popular with web hosting providers. In the case of high connection concurrency, Nginx is a good alternative to the Apache server: Nginx is one of the software platforms often chosen by virtual host business owners in the United States. It can support responses of up to 50,000 concurrent connections, Thank you Nginx chose epoll and kqueue as the development model for us. Nginx as a load balancing server: Nginx can not only directly support Rails and PHP programs internally to provide external services, but also support external services as an HTTP proxy server. Nginx is written in C, and its system resource overhead and CPU usage efficiency are much better than Perlbal. As a mail proxy server: Nginx is also a very excellent mail proxy server (one of the earliest purposes for developing this product First, as a mail proxy server), Last.fm describes a successful and wonderful experience. Nginx is a server that is very simple to install, has a very concise configuration file (it can also support perl syntax), and has very few bugs: Nginx It is particularly easy to start, and it can run almost 24/7, without restarting even if it runs for several months. You can also upgrade the software version without interrupting the service.


5. Nginx configuration is simple, Apache is complex Nginx static processing performance is more than 3 times higher than Apache Apache’s support for PHP is relatively simple, Nginx needs to cooperate with other backends Use Apache has more components than Nginx Now Nginx is the first choice for web servers


Six , the core difference is that apache is a synchronous multi-process model , one connection corresponds to one process; nginx is asynchronous , multiple connections (10,000 levels) can correspond to one process


7. nginx handles static files well and consumes less memory .But there is no doubt that apache is still the mainstream at present, with many rich features. So it still needs to be matched. Of course, if it is determined that nginx suits the needs, then using nginx will be a more economical way. apache has inherent disadvantages The disadvantage of supporting multi-core processing load is that it is useless. It is recommended to use nginx as the front end and apache as the back end. It is recommended that large websites use the cluster function of nginx. For how to configure LNMPA, you can check http://www.freehao123.com/lnmpa/ 8. Judging from personal past usage, the load capacity of nginx is much higher than that of apache. The latest server also uses nginx. Moreover, after changing the configuration of nginx, you can -t test whether the configuration is correct. There is a problem. When apache is restarted, 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, front-end nginx anti-concurrency, back-end apache cluster, The cooperation is also good.

9. 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 . 10. From my personal experience, nginx is a very good front-end server with very good load performance. It is effortless to open nginx on Laoben and use webbench to simulate 10,000 static file requests. Apache has good support for languages ​​​​such as php. In addition, apache has a strong support network and has been developed for a longer period of time than nginx. Reverse proxy server 2. Nginx supports 7-layer load balancing; of course, Nginx may be better than other Apache supports higher concurrency, but according to NetCraft statistics, in April 2011, Apache still accounted for 62.71%, while Nginx was 7.35%. Therefore, in general, Aapche is still the first choice for most companies because of its The mature technology and development community already have very good performance. 12. Your needs for web server determine your choice. Big In some cases, nginx is better than APACHE, such as static file processing, PHP-CGI support, reverse proxy function, front-end Cache, maintaining connections, etc. exist In 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. 13. You can take a look at the nginx lua module: https://github.com/chaoslaw...apache has more modules than nginx, and can be implemented directly with lua. Apache is the most popular, why? Most people are too lazy to update to nginx or learn new things 14. For nginx, I like it The configuration file is very concisely written. Regular configuration makes many things simple. It runs efficiently, takes up less resources, and proxy It has powerful functions and 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 rewrite is frequent, then Apache is the best choice

Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.

The above introduces the comparison between Apache and ngnix, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.

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
解决方法:您的组织要求您更改 PIN 码解决方法:您的组织要求您更改 PIN 码Oct 04, 2023 pm 05:45 PM

“你的组织要求你更改PIN消息”将显示在登录屏幕上。当在使用基于组织的帐户设置的电脑上达到PIN过期限制时,就会发生这种情况,在该电脑上,他们可以控制个人设备。但是,如果您使用个人帐户设置了Windows,则理想情况下不应显示错误消息。虽然情况并非总是如此。大多数遇到错误的用户使用个人帐户报告。为什么我的组织要求我在Windows11上更改我的PIN?可能是您的帐户与组织相关联,您的主要方法应该是验证这一点。联系域管理员会有所帮助!此外,配置错误的本地策略设置或不正确的注册表项也可能导致错误。即

Windows 11 上调整窗口边框设置的方法:更改颜色和大小Windows 11 上调整窗口边框设置的方法:更改颜色和大小Sep 22, 2023 am 11:37 AM

Windows11将清新优雅的设计带到了最前沿;现代界面允许您个性化和更改最精细的细节,例如窗口边框。在本指南中,我们将讨论分步说明,以帮助您在Windows操作系统中创建反映您的风格的环境。如何更改窗口边框设置?按+打开“设置”应用。WindowsI转到个性化,然后单击颜色设置。颜色更改窗口边框设置窗口11“宽度=”643“高度=”500“>找到在标题栏和窗口边框上显示强调色选项,然后切换它旁边的开关。若要在“开始”菜单和任务栏上显示主题色,请打开“在开始”菜单和任务栏上显示主题

如何在 Windows 11 上更改标题栏颜色?如何在 Windows 11 上更改标题栏颜色?Sep 14, 2023 pm 03:33 PM

默认情况下,Windows11上的标题栏颜色取决于您选择的深色/浅色主题。但是,您可以将其更改为所需的任何颜色。在本指南中,我们将讨论三种方法的分步说明,以更改它并个性化您的桌面体验,使其具有视觉吸引力。是否可以更改活动和非活动窗口的标题栏颜色?是的,您可以使用“设置”应用更改活动窗口的标题栏颜色,也可以使用注册表编辑器更改非活动窗口的标题栏颜色。若要了解这些步骤,请转到下一部分。如何在Windows11中更改标题栏的颜色?1.使用“设置”应用按+打开设置窗口。WindowsI前往“个性化”,然

OOBELANGUAGE错误Windows 11 / 10修复中出现问题的问题OOBELANGUAGE错误Windows 11 / 10修复中出现问题的问题Jul 16, 2023 pm 03:29 PM

您是否在Windows安装程序页面上看到“出现问题”以及“OOBELANGUAGE”语句?Windows的安装有时会因此类错误而停止。OOBE表示开箱即用的体验。正如错误提示所表示的那样,这是与OOBE语言选择相关的问题。没有什么可担心的,你可以通过OOBE屏幕本身的漂亮注册表编辑来解决这个问题。快速修复–1.单击OOBE应用底部的“重试”按钮。这将继续进行该过程,而不会再打嗝。2.使用电源按钮强制关闭系统。系统重新启动后,OOBE应继续。3.断开系统与互联网的连接。在脱机模式下完成OOBE的所

Windows 11 上启用或禁用任务栏缩略图预览的方法Windows 11 上启用或禁用任务栏缩略图预览的方法Sep 15, 2023 pm 03:57 PM

任务栏缩略图可能很有趣,但它们也可能分散注意力或烦人。考虑到您将鼠标悬停在该区域的频率,您可能无意中关闭了重要窗口几次。另一个缺点是它使用更多的系统资源,因此,如果您一直在寻找一种提高资源效率的方法,我们将向您展示如何禁用它。不过,如果您的硬件规格可以处理它并且您喜欢预览版,则可以启用它。如何在Windows11中启用任务栏缩略图预览?1.使用“设置”应用点击键并单击设置。Windows单击系统,然后选择关于。点击高级系统设置。导航到“高级”选项卡,然后选择“性能”下的“设置”。在“视觉效果”选

Windows 11 上的显示缩放比例调整指南Windows 11 上的显示缩放比例调整指南Sep 19, 2023 pm 06:45 PM

在Windows11上的显示缩放方面,我们都有不同的偏好。有些人喜欢大图标,有些人喜欢小图标。但是,我们都同意拥有正确的缩放比例很重要。字体缩放不良或图像过度缩放可能是工作时真正的生产力杀手,因此您需要知道如何对其进行自定义以充分利用系统功能。自定义缩放的优点:对于难以阅读屏幕上的文本的人来说,这是一个有用的功能。它可以帮助您一次在屏幕上查看更多内容。您可以创建仅适用于某些监视器和应用程序的自定义扩展配置文件。可以帮助提高低端硬件的性能。它使您可以更好地控制屏幕上的内容。如何在Windows11

10种在 Windows 11 上调整亮度的方法10种在 Windows 11 上调整亮度的方法Dec 18, 2023 pm 02:21 PM

屏幕亮度是使用现代计算设备不可或缺的一部分,尤其是当您长时间注视屏幕时。它可以帮助您减轻眼睛疲劳,提高易读性,并轻松有效地查看内容。但是,根据您的设置,有时很难管理亮度,尤其是在具有新UI更改的Windows11上。如果您在调整亮度时遇到问题,以下是在Windows11上管理亮度的所有方法。如何在Windows11上更改亮度[10种方式解释]单显示器用户可以使用以下方法在Windows11上调整亮度。这包括使用单个显示器的台式机系统以及笔记本电脑。让我们开始吧。方法1:使用操作中心操作中心是访问

如何修复Windows服务器中的激活错误代码0xc004f069如何修复Windows服务器中的激活错误代码0xc004f069Jul 22, 2023 am 09:49 AM

Windows上的激活过程有时会突然转向显示包含此错误代码0xc004f069的错误消息。虽然激活过程已经联机,但一些运行WindowsServer的旧系统可能会遇到此问题。通过这些初步检查,如果这些检查不能帮助您激活系统,请跳转到主要解决方案以解决问题。解决方法–关闭错误消息和激活窗口。然后,重新启动计算机。再次从头开始重试Windows激活过程。修复1–从终端激活从cmd终端激活WindowsServerEdition系统。阶段–1检查Windows服务器版本您必须检查您使用的是哪种类型的W

See all articles

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)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool