Webで突然メモリオーバーした場合の調査方法
突然サービスでエラーが出始めた
とりあえずログを見る
メモリオーバーでエラーが出ている
[21-Sep-2019 04:30:40] PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 71 bytes) in /var/www/xxxxRedisUtil.php on line 60
[21-Sep-2019 04:34:42] PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 6 bytes) in /var/www/xxxxDaoUtil.php on line 314
- データストアのUtilクラスでメモリオーバーしているのは把握できたが、どのページか判断できない
アクセスログで500エラーを探せばだいたい見つかる
[root@xxxWeb01 ~]# cat /var/log/httpd/xxxx.com.access_log.20190920 | grep " 500 "
100.100.xxx.17 - - [20/Sep/2019:00:00:01 +0900] "GET /xxxxx HTTP/1.1" 500 20 "-" "Mozilla/5.0 (Linux; Android 7.0; WAS-LX2J Build/HUAWEIWAS-LX2J; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.132 Mobile Safari/537.36 Sleipnir/3.5.16" "-" "-" "-" 1590957 "-" "-" "64" "/xxxx/" "1684366134" "-" "-"
100.100.xxx.19 - - [20/Sep/2019:00:10:02 +0900] "POST /xxxx HTTP/1.1" 500 20 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1" "-" "-" "-" 2221272 "-" "-" "32" "/xxxxx" "1667523941" "-" "-"
100.100.xxx.40 - - [20/Sep/2019:02:10:01 +0900] "GET /xxxx HTTP/1.1" 500 20 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Mobile/15E148 Safari/604.1" "-" "-" "-" 803358 "-" "-" "32" "/xxxx" "1697658468" "-" "-"
あとは対応するだけ
- ini_setでメモリ増やすなり
- リファクタしてメモリ消費をへらすなり
[21-Sep-2019 04:30:40] PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 71 bytes) in /var/www/xxxxRedisUtil.php on line 60
[21-Sep-2019 04:34:42] PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 6 bytes) in /var/www/xxxxDaoUtil.php on line 314
[root@xxxWeb01 ~]# cat /var/log/httpd/xxxx.com.access_log.20190920 | grep " 500 "
100.100.xxx.17 - - [20/Sep/2019:00:00:01 +0900] "GET /xxxxx HTTP/1.1" 500 20 "-" "Mozilla/5.0 (Linux; Android 7.0; WAS-LX2J Build/HUAWEIWAS-LX2J; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.132 Mobile Safari/537.36 Sleipnir/3.5.16" "-" "-" "-" 1590957 "-" "-" "64" "/xxxx/" "1684366134" "-" "-"
100.100.xxx.19 - - [20/Sep/2019:00:10:02 +0900] "POST /xxxx HTTP/1.1" 500 20 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1" "-" "-" "-" 2221272 "-" "-" "32" "/xxxxx" "1667523941" "-" "-"
100.100.xxx.40 - - [20/Sep/2019:02:10:01 +0900] "GET /xxxx HTTP/1.1" 500 20 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Mobile/15E148 Safari/604.1" "-" "-" "-" 803358 "-" "-" "32" "/xxxx" "1697658468" "-" "-"
Author And Source
この問題について(Webで突然メモリオーバーした場合の調査方法), 我々は、より多くの情報をここで見つけました https://qiita.com/sota/items/a467f688743f5568bab7著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .