問題場景
接問題反饋,部分系統登錄時報404,部分刷新頁面後正常。
剖析
報 404 頁面的地址經檢查有該文件,遂檢查日誌
[ info ] ceshi.sy.foodvip.net/home/login/index.html [運行時間:0.037186s][吞吐率:26.89req/s] [內存消耗:4,285.29kb] [文件加載:65]
[ info ] [ BEHAVIOR ] Run \app\common\behavior\Initdefine @app_init [ RunTime:0.000429s ]
[ info ] [ DB ] INIT mysql
[ info ] [ CACHE ] INIT File
[ info ] [ BEHAVIOR ] Run \app\common\behavior\Config @app_init [ RunTime:0.015711s ]
[ info ] [ BEHAVIOR ] Run \app\common\behavior\Compatible @app_init [ RunTime:0.000311s ]
[ info ] [ LANG ] /www/wwwroot/customer/yanshi/thinkphp/lang/zh-cn.php
[ info ] [ ROUTE ] array (
'type' => 'module',
'module' =>
array (
0 => '502',
1 => NULL,
2 => NULL,
),
)
[ info ] [ PARAM ] array (
's' => '/502.html',
)
發現日誌錯誤中路由指向 502,且實際請求 根下502.html , 檢查 nginx 配置
#ERROR-PAGE-START 錯誤頁配置,可以註釋、刪除或修改
error_page 404 /404.html;
error_page 502 /502.html;
當nginx捕捉到 502 時回去請求 根下 502.html, 但是文件不存在, 故狀態碼變爲 404, 但實際爲 502;
檢查 php 日誌後,發現報錯同時子進程被 kill,初步考慮是否是內存不足,檢查 opcache status 發現 used memory 過高,如果 php 或者 服務器出問題,應該大範圍 502,考慮是否有中間件操作了php-fpm進程,結合上述考慮,查詢 “opcache 502”資料,發現的確會引起類似問題,但是解決方案和實際不符,遂先 關閉 opcache 以確認追蹤相關問題。
可能的問題點
排查時發現內存佔用太高,是否可以調整可用內存大小?