php fastcgi 和 fpm 有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4526242/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 13:18:58  来源:igfitidea点击:

What is the difference between fastcgi and fpm?

phpmacosfastcgimacports

提问by Deepan Chakravarthy

I am trying to install php with fpm on macports. I read somewhere that fpm means FastCGI process manager. Does that mean fastcgi and fpm are same? If they are same, then why do we have two different macports variants for php namely "php5 +fastcgi"and "php5 +fpm"

我正在尝试在 macports 上使用 fpm 安装 php。我在某处读到 fpm 意味着 FastCGI 进程管理器。这是否意味着 fastcgi 和 fpm 相同?如果它们相同,那么为什么我们有两种不同的 php macports 变体,即 “php5 +fastcgi”“php5 +fpm”

回答by ircmaxell

FPMis a process manager to manage the FastCGI SAPI (Server API) in PHP.

FPM是一个进程管理器,用于管理 PHP 中的 FastCGI SAPI(服务器 API)。

Basically, it replaces the need for something like SpawnFCGI. It spawns the FastCGI children adaptively (meaning launching more if the current load requires it).

基本上,它取代了对SpawnFCGI 之类的需求。它自适应地生成 FastCGI 子节点(意味着如果当前负载需要它,则启动更多)。

Otherwise, there's not much operating difference between it and FastCGI (The request pipeline from start of request to end is the same). It's just there to make implementing it easier.

否则,它和FastCGI 没有太大的操作区别(从请求开始到结束的请求管道是一样的)。它只是为了简化实施。

回答by spacemonkey

What Anthony says is absolutely correct, but I'd like to add that your experience will likely show a lot better performance and efficiency (due not to fpm-vs-fcgibut more to the implementation of your httpd).

Anthony 说的是绝对正确的,但我想补充一点,您的经验可能会显示出更好的性能和效率(不是因为fpm-vs-,fcgi而是更多地执行了您的httpd)。

For example, I had a quad-core machine running lighttpd+ fcgihumming along nicely. I upgraded to a 16-core machine to cope with growth, and two things exploded: RAM usage, and segfaults. I found myself restarting lighttpdevery 30 minutes to keep the website up.

例如,我有一台四核机器运行lighttpd+fcgi嗡嗡声很好。我升级到 16 核机器以应对增长,有两件事爆炸了:RAM 使用率和段错误。我发现自己lighttpd每 30 分钟重新启动一次以保持网站正常运行。

I switched to php-fpm and nginx, and RAM usage dropped from >20GB to 2GB. Segfaults disappeared as well. After doing some research, I learned that lighttpd and fcgi don't get along well on multi-core machines under load, and also have memory leak issues in certain instances.

我切换到 php-fpm 和 nginx,RAM 使用量从 >20GB 下降到 2GB。段错误也消失了。经过一番研究,我了解到 lighttpd 和 fcgi 在负载下的多核机器上不能很好地相处,并且在某些情况下也存在内存泄漏问题。

Is this due to php-fpmbeing better than fcgi? Not entirely, but howyou hook into php-fpmseems to be a whole heckuva lot more efficient than how you serve via fcgi.

这是因为php-fpmfcgi? 不完全是,但你如何挂钩php-fpm似乎比你通过fcgi.

回答by pulkit8

Running PHP as a CGI means that you basically tell your web server the location of the PHP executable file, and the server runs that executable

将 PHP 作为 CGI 运行意味着您基本上告诉您的 Web 服务器 PHP 可执行文件的位置,然后服务器运行该可执行文件

whereas

然而

PHP FastCGI Process Manager (PHP-FPM) is an alternative FastCGI daemon for PHP that allows a website to handle strenuous loads. PHP-FPM maintains pools (workers that can respond to PHP requests) to accomplish this. PHP-FPM is faster than traditional CGI-based methods, such as SUPHP, for multi-user PHP environments

PHP FastCGI 进程管理器 (PHP-FPM) 是 PHP 的替代 FastCGI 守护程序,它允许网站处理繁重的负载。PHP-FPM 维护池(可以响应 PHP 请求的工作器)来完成此任务。对于多用户 PHP 环境,PHP-FPM 比传统的基于 CGI 的方法(如 SUPHP)更快

However, there are pros and cons to both and one should choose as per their specific use case.

但是,两者各有利弊,应根据其特定用例进行选择。

I found info on this link for fastcgi vs fpmquite helpful in choosing which handler to use in my scenario.

我发现有关fastcgi vs fpm 的此链接的信息对于选择在我的场景中使用哪个处理程序非常有帮助。