web api无响应解决方案

来源:互联网 发布:c语言鸡兔同笼代码 编辑:程序博客网 时间:2024/05/22 13:19

How to fix upstream timed out (110: Connection timed out) error in Nginx

在Nginx错误日志中,有大量的下列信息:

Upstream timed out (110: Connection timed out) while reading response header from upstream

这种情况主要在两种情况下发生:

1. nginx proxy

需要适当的调整proxy_read_timeout值。

location / {
        ...
        proxy_read_timeout 150;
        ...
    }

2. Nginx作为php-fpm等等其他的有上游服务

在这种情况下,适当的调整fastcgi_read_timeout选项值

location ~* .php$ {
    include         fastcgi_params;
    fastcgi_index   index.php;
    fastcgi_read_timeout 150;
    fastcgi_pass    127.0.0.1:9000;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
}

2。php-fpm.onf配置优化:

下面4个参数的意思分别为:

pm.max_children:静态方式下开启的php-fpm进程数量。
pm.start_servers:动态方式下的起始php-fpm进程数量。
pm.min_spare_servers:动态方式下的最小php-fpm进程数量。
pm.max_spare_servers:动态方式下的最大php-fpm进程数量。

pm=dynamic
pm.max_children=20
pm.start_servers=5
pm.min_spare_servers=5
pm.max_spare_servers=20

这样就可以最大的节省内存并提高执行效率。


0 0
原创粉丝点击