Nginx / FastCGI一直在崩溃

时间:2012-01-12 00:38:52

标签: mono nginx fastcgi

是否有任何Nginx / FastCGI专家可以帮助我?

我正在使用Debian Squeeze运行nox 1.0.11 Mono FastCGI(fastcgi-mono-server4 2.10.2.0)。我注意到FastCGI实例经常崩溃以响应超过~350,000字节的POST请求。虽然这种规模的一些要求是成功的,但它们更有可能因流量增加而失败。此外,通常当FastCGI实例失败时,Nginx工作进程将被僵尸化(即Nginx仍处理请求但超时 - 尽管所有网关都可能已关闭,但不会返回502)。我打开了Nginx调试并在工作进程和FastCGI实例崩溃之前发现了以下内容。

2012/01/11 20:38:42 [debug] 1744#0: *141 writev: 8
2012/01/11 20:38:42 [debug] 1744#0: *141 sendfile: @360448 32768
2012/01/11 20:38:42 [debug] 1744#0: *141 sendfile: 32768, @360448 32768:32768
2012/01/11 20:38:42 [debug] 1744#0: *141 writev: 8
2012/01/11 20:38:42 [debug] 1744#0: *141 sendfile: @393216 12167
2012/01/11 20:38:42 [debug] 1744#0: *141 sendfile: 12167, @393216 12167:12167
2012/01/11 20:38:42 [debug] 1744#0: *141 writev: 9
2012/01/11 20:38:42 [debug] 1744#0: *141 chain writer out: 0000000000000000
2012/01/11 20:38:42 [debug] 1744#0: *141 event timer del: 16: 1326314382071
2012/01/11 20:38:42 [debug] 1744#0: *141 event timer add: 16: 60000:1326314382072

这些只是记录的最后10个项目,但是,如果您想看到更多,我当然可以发布或PM。最后,这是我的Nginx配置文件。

user                 www-data;
worker_processes     2;
worker_rlimit_nofile 8192;
events {
    worker_connections  2048;
    use                 epoll;
}

http {
    error_log               /var/log/error.log;
    include                 mime.types;
    default_type            application/octet-stream;           
    sendfile                on;
    keepalive_timeout       65;

    gzip              on;
    gzip_http_version 1.1;
    gzip_vary         on;
    gzip_comp_level   6;
    gzip_proxied      any;
    gzip_types        text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js font/opentype application/font-woff;
    gzip_buffers      16 8k;
    gzip_disable      "MSIE [1-6]\.(?!.*SV1)";

    upstream backend {
        server 127.0.0.1:8080;
        server 127.0.0.1:8081;
    }

    server {
        listen       80;
        server_name  my_server;
        root         /var/www;
        access_log   /var/log/host.access.log;

        location / {
            fastcgi_param            SCRIPT_FILENAME /scripts$fastcgi_script_name;
            include                  fastcgi_params;
            fastcgi_pass             backend;
            fastcgi_next_upstream    http_500 http_404 error timeout;
            fastcgi_read_timeout     60;
        }

        location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$ {
            root /var/www;
        }
    }
}

1 个答案:

答案 0 :(得分:0)

证明了Mono的LOH并且缺乏对它进行碎片整理是个问题。所以这个解决方案是为这个问题投入更多的内存。

http://blog.mohammadjalloul.com/blogs/mo/archive/2010/02/21/the-large-object-heap.aspx