【问题标题】:Nginx, sendfile and FastCGINginx、sendfile 和 FastCGI
【发布时间】:2015-11-06 10:48:56
【问题描述】:

如果 nginx 仅配置为将请求转发到 FastCGI 后端(Mono、PHP 等),而不涉及任何基于文件的缓存,那么在 nginx.conf 中使用 sendfile on 会带来任何性能提升吗?

示例 nginx.conf:

worker_processes  1;
daemon off;

events {
    worker_connections  1024;
    use epoll;
}

http {
    sendfile        on; # <-- ???
    tcp_nopush      on;
    tcp_nodelay     on;

    server {
        listen       80;
        server_name  localhost;

        location / {
            root   /usr/aspnet/;
            fastcgi_pass 127.0.0.1:9000;
            include /etc/nginx/nginx-fastcgi-params.conf;
        }
    }
}

【问题讨论】:

  • 我怀疑。但它也不会受到伤害。只是没用。

标签: nginx fastcgi


【解决方案1】:

来自Sendfile man pages

ssize_t sendfile(int out_fd, int in_fd, off_t * offset ", size_t" " count" );
....
in_fd 参数必须对应于支持类似 mmap(2) 操作的文件(即,它不能是套接字)。

换句话说,启用 sendfile 不会有任何区别,除非 nginx 正在读取可以映射到虚拟内存空间(如文件)的内容。所以它不会对 fastcgi_pass 的性能产生任何影响。

【讨论】:

    猜你喜欢
    • 2013-09-15
    • 2020-08-04
    • 2015-04-08
    • 2014-08-22
    • 1970-01-01
    • 2015-07-07
    • 2016-03-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多