大网数据广告活动
服务器运维问答

Does using fastcgi_keep_conn in nginx increase performance for php-fpm?

· 52CE 我爱测

The nginx docs say that keepalive for fastcgi cannot work if the fastcgi_keep_conn is not on. However, I can't find any further details on this. I already have keepalive enabled server-wide. I am using php-fpm. Are there any issu…

问题原文

原帖链接 · Ryan · CC BY-SA 3.0

The nginx docs say that keepalive for fastcgi cannot work if the fastcgi_keep_conn is not on. However, I can't find any further details on this. I already have keepalive enabled server-wide. I am using php-fpm. Are there any issues about using fastcgi_keep_conn that I should be aware of?

社区高分解答

原帖链接 · Tero Kilkanen · CC BY-SA 3.0

Theoretically fastcgi_keep_conn does increase performance, since the socket between nginx and PHP-FPM stays open after request has been processed. Therefore the time spent opening the socket is saved.

Overall, this would save some milliseconds on each request, so it has not such a big effect.

The documentation simply means that you need to have both an upstream block with keepalive option and fastcgi_keep_conn option in your PHP script block for the connection keepalive to work.

Basically, fastcgi_keep_conn option tells nginx to make PHP-FPM to keep the connection open after the request, and the keepalive connection tells nginx to keep the connection open.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2014-07-13)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。