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

Nginx報錯日誌有以下內容:php

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

服務器開發環境: SLES12sp2 + Nginx + PHP-FPM + Maraidb集羣數據庫

請求PHP頁面,瀏覽器一直處在加載狀態,頁面阻塞,沒有任何反應;瀏覽器

網上不少資料,大意是修改nginx配置文件,延長fastcgi等待時間,但不能解決根本問題。服務器

經測試,問題出在php-fpm,php代碼要使用file存取session,讀寫數據庫,其中有一項操做緩慢,都能形成nginx假死;session

解決方案:php7

打開php-fpm慢日誌:php-fpm

mkdir /var/log/php-fpm && chown nginx:nginx /var/log/php-fpm測試

vi   /etc/php7/fpm/php-fpm.d/www.confspa

修改:

request_slowlog_timeout = 2s

request_terminate_timeout = 30s

slowlog = /var/log/php-fpm/$pool.log.slow

重啓nginx和php-fpm

刷新頁面,頁面一直停留在阻塞狀態,沒有反應,這時,

tailf  /var/log/php-fpm/www.log.slow

能夠清楚看到執行慢的語句和操做,這樣就能找到具體緣由!

相關文章
相關標籤/搜索