PHP查詢資料庫較慢,nginx 逾時 返回 504:Sorry, the page you are looking for is currently unavailable.

來源:互聯網
上載者:User

標籤:rom   art   reload   read   class   fastcgi   failed   資料庫   bsp   

現象:

PHP查詢資料庫較慢,大約 60s 後 nginx 返回 504:Sorry, the page you are looking for is currently unavailable.

檢查log:

從 /etc/nginx/nginx.conf 找到 /var/log/nginx/access.log 和 /var/log/nginx/error.log

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

解決辦法:

Nginx upstream timed out (why and how to fix)

添加帶有注釋的語句

    location ~ \.php$ {    #    root           html;        fastcgi_read_timeout 300;  #########https://distinctplace.com/2017/04/22/nginx-upstream-timed-out/       upstream timed out (110: Connection timed out) while reading response header from upstream        fastcgi_pass   127.0.0.1:9000;        fastcgi_index  index.php;        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;        include        fastcgi_params;    }

 

執行 service nginx reload 之後,執行查詢,返回頁面沒有顯示 table,繼續檢查log

"PHP message: PHP Warning: file_get_contents(http://127.0.0.1/xxx): failed to open stream: HTTP request failed! in /home/www/uninum/web.php on line 50

PHP message: PHP Notice:  Trying to get property of non-object in xxx.php on line 54" while reading response header from upstream

同步設定  file_get_contents 逾時

php file_get_contents 擷取檔案逾時的處理方法  以及post 和 多次重試

$opts = array(      ‘http‘=>array(          ‘method‘=>"GET",          ‘timeout‘=>300,      )  );  $context = stream_context_create($opts);       $html =file_get_contents(‘http://www.example.com‘, false, $context); 

 

PHP查詢資料庫較慢,nginx 逾時 返回 504:Sorry, the page you are looking for is currently unavailable.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.