PHP Fatal error: Out of memory 再び!!

この記事を読む およそ時間 5

もーねぇ!やめてよ!! Fatal : Out of memory ってことで、

今日アクセスされた方、ほとんどがPHP Fatal error: Out of memory だったと思います。

ようは、真っ白な画面でリロードすると、表示されるような挙動だったと推測されます。

 

↑ひでーぇじゃないですか!500をnginxが返しているグラフなんですよ。

そもそも、httpdの世界で500ってInternalServerErrortって事なんですよ。

正常にサービスが出来ていない状況を示します。例えば画面が真っ白だったりとか、

 

↓がそのログのキャプチャーだったりします。

 

 

さて、ここまで来たらですね、ちょっと本腰入れてやるしかねーなって感じになってきましたので

そこで!登場!パラッラッパパーパーパーw

ABテストツー---ル!w

紹介しよう!ABテストツールとは、Apacheに付属してついてくる負荷ベンチツールの事である。

起動は簡単、使い方も簡単何でも簡単!w

 

ab -n 100 -c 200 負荷テストサイトURL

これで、まずは、-n が回数 -c が同時アクセス数なので、 -c 100 -c 200 はパラメーター上エラーになる。

まあ、当然の話やねw

■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■

最初-n 10 -c 1 でテストする → サイトを10回表示させる。1多重

[root@st tmp]# ab -n 10 -c 1 https://blog.rurineko.com/

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking blog.rurineko.com (be patient)…..done

 

Server Software: nginx/*.*.*
Server Hostname: blog.rurineko.com
Server Port: 80

Document Path: /
Document Length: 162177 bytes

Concurrency Level: 1
Time taken for tests: 4.248 seconds
Complete requests: 10
Failed requests: 9
(Connect: 0, Receive: 0, Length: 9, Exceptions: 0)
Write errors: 0
Total transferred: 1623542 bytes
HTML transferred: 1621500 bytes
Requests per second: 2.35 [#/sec] (mean)
Time per request: 424.842 [ms] (mean)
Time per request: 424.842 [ms] (mean, across all concurrent requests)
Transfer rate: 373.19 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 1 0.2 1 1
Processing: 255 424 313.1 357 1304
Waiting: 238 407 313.1 340 1287
Total: 256 425 313.1 357 1304

Percentage of the requests served within a certain time (ms)
50% 357
66% 363
75% 394
80% 403
90% 1304
95% 1304
98% 1304
99% 1304
100% 1304 (longest request)

結果問題無くって、当たり前やね。

■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■

次-n 10 -c 2 でテストする → サイトを10回表示させる。2多重

[root@st tmp]# ab -n 10 -c 2 https://blog.rurineko.com/

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking blog.rurineko.com (be patient)…..done

 

Server Software: nginx/*.*.*
Server Hostname: blog.rurineko.com
Server Port: 80

Document Path: /
Document Length: 162147 bytes

Concurrency Level: 2
Time taken for tests: 2.988 seconds
Complete requests: 10
Failed requests: 3
(Connect: 0, Receive: 0, Length: 3, Exceptions: 0)
Write errors: 0
Total transferred: 1623674 bytes
HTML transferred: 1621450 bytes
Requests per second: 3.35 [#/sec] (mean)
Time per request: 597.669 [ms] (mean)
Time per request: 298.835 [ms] (mean, across all concurrent requests)
Transfer rate: 530.60 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 1 0.3 1 1
Processing: 315 530 341.9 386 1195
Waiting: 298 512 341.5 369 1178
Total: 316 530 342.0 387 1196

Percentage of the requests served within a certain time (ms)
50% 387
66% 390
75% 398
80% 1159
90% 1196
95% 1196
98% 1196
99% 1196
100% 1196 (longest request)

■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■

次-n 10 -c 5 でテストする → サイトを10回表示させる。5多重

[root@st tmp]# ab -n 10 -c 5 https://blog.rurineko.com/

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking blog.rurineko.com (be patient)…..done

 

Server Software: nginx/*.*.*
Server Hostname: blog.rurineko.com
Server Port: 80

Document Path: /
Document Length: 162129 bytes

Concurrency Level: 5
Time taken for tests: 1.426 seconds
Complete requests: 10
Failed requests: 0
Write errors: 0
Total transferred: 1623150 bytes
HTML transferred: 1621290 bytes
Requests per second: 7.02 [#/sec] (mean)
Time per request: 712.755 [ms] (mean)
Time per request: 142.551 [ms] (mean, across all concurrent requests)
Transfer rate: 1111.96 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 1 0.1 1 1
Processing: 299 508 166.7 564 831
Waiting: 282 491 166.8 547 813
Total: 300 509 166.7 564 832

Percentage of the requests served within a certain time (ms)
50% 564
66% 567
75% 573
80% 676
90% 832
95% 832
98% 832
99% 832
100% 832 (longest request)

■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■

次-n 100 -c 5 でテストする → サイトを100回表示させる。5多重

[root@st tmp]# ab -n 100 -c 5 https://blog.rurineko.com/

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking blog.rurineko.com (be patient)…..done

 

Server Software: nginx/*.*.*
Server Hostname: blog.rurineko.com
Server Port: 80

Document Path: /
Document Length: 162129 bytes

Concurrency Level: 5
Time taken for tests: 11.250 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 16231500 bytes
HTML transferred: 16212900 bytes
Requests per second: 8.89 [#/sec] (mean)
Time per request: 562.510 [ms] (mean)
Time per request: 112.502 [ms] (mean, across all concurrent requests)
Transfer rate: 1408.96 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 0.2 1 1
Processing: 238 543 151.9 525 873
Waiting: 221 525 152.2 508 857
Total: 239 544 151.8 526 874

Percentage of the requests served within a certain time (ms)
50% 526
66% 603
75% 637
80% 653
90% 800
95% 836
98% 863
99% 874
100% 874 (longest request)

まだまだ、いけそうじゃんw この時点でも、500は発生して折らず問題なさげw

■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■

えぇい!めんどくさい 次-n 100 -c 10 でテストする → サイトを100回表示させる10多重

このくらいの負荷で落ちるなんて、落ちるならおちちまえ!!w

[root@st tmp]# ab -n 100 -c 10 https://blog.rurineko.com/

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking blog.rurineko.com (be patient)…..done

 

Server Software: nginx/*.*.*
Server Hostname: blog.rurineko.com
Server Port: 80

Document Path: /
Document Length: 162129 bytes

Concurrency Level: 10
Time taken for tests: 12.319 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 16231500 bytes
HTML transferred: 16212900 bytes
Requests per second: 8.12 [#/sec] (mean)
Time per request: 1231.866 [ms] (mean)
Time per request: 123.187 [ms] (mean, across all concurrent requests)
Transfer rate: 1286.75 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 0.4 1 3
Processing: 288 1167 264.0 1195 1824
Waiting: 270 1148 264.5 1175 1799
Total: 288 1168 263.9 1195 1825

Percentage of the requests served within a certain time (ms)
50% 1195
66% 1284
75% 1312
80% 1367
90% 1467
95% 1528
98% 1739
99% 1825
100% 1825 (longest request)

意外にもんだいねーなぁw

■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■

もっともっと!限界値をさがすぞーw

次-n 100 -c 100 でテストする → サイトを100回表示させる10多重で、1000アクセス

[root@st tmp]# ab -n 100 -c 100 https://blog.rurineko.com/

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking blog.rurineko.com (be patient)…..done

 

 

Server Software: nginx/*.*.*
Server Hostname: blog.rurineko.com
Server Port: 80

Document Path: /
Document Length: 162131 bytes

Concurrency Level: 100
Time taken for tests: 12.184 seconds
Complete requests: 100
Failed requests: 99
(Connect: 0, Receive: 0, Length: 99, Exceptions: 0)
Write errors: 0
Total transferred: 16228912 bytes
HTML transferred: 16210130 bytes
Requests per second: 8.21 [#/sec] (mean)
Time per request: 12184.018 [ms] (mean)
Time per request: 121.840 [ms] (mean, across all concurrent requests)
Transfer rate: 1300.77 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 14 6.2 14 25
Processing: 472 5657 2923.5 5473 10652
Waiting: 456 5637 2923.9 5456 10627
Total: 497 5671 2917.7 5487 10656

Percentage of the requests served within a certain time (ms)
50% 5487
66% 7359
75% 8206
80% 8819
90% 9783
95% 10276
98% 10648
99% 10656
100% 10656 (longest request)

意外にもんだいねーなぁw

■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■

もっともっともーーーーーーーと!!!限界値をさがすぞーw

次-n 200 -c 200 でテストする → サイトを200回表示させ20多重で、4000アクセス

 

[root@st tmp]# ab -n 200 -c 200 https://blog.rurineko.com/

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking blog.rurineko.com (be patient)
Completed 100 requests
Completed 200 requests
Finished 200 requests

 

Server Software: nginx/*.*.*
Server Hostname: blog.rurineko.com
Server Port: 80

Document Path: /
Document Length: 162096 bytes

Concurrency Level: 200
Time taken for tests: 21.512 seconds
Complete requests: 200
Failed requests: 0
Write errors: 0
Total transferred: 32456400 bytes
HTML transferred: 32419200 bytes
Requests per second: 9.30 [#/sec] (mean)
Time per request: 21512.207 [ms] (mean)
Time per request: 107.561 [ms] (mean, across all concurrent requests)
Transfer rate: 1473.38 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 33 120.1 18 1001
Processing: 372 10761 5806.3 10741 21060
Waiting: 355 10741 5806.6 10724 21044
Total: 403 10794 5807.1 10759 21064

Percentage of the requests served within a certain time (ms)
50% 10759
66% 13730
75% 15651
80% 16751
90% 18862
95% 20084
98% 20771
99% 21025
100% 21064 (longest request)

意外にもんだいねーなぁw

と思ったら、まずnginxが499のエラーコードを書き出し

そして、php-fpmのログを見ると、ごめーーーーん!

4つのワーカープロセスしか、あげれないように設定されている為

これ以上どうしようもねーぜぇ!と悲鳴を上げているwwww

まあ、結局4000の負荷テストは通過したけど、一応このようなエラーがあって

一部通信が乱れた事を確認したが、メモリーもCPUもまだ余裕があった為

どんな記事を書いても、21秒で4000のアクセスが来るとも思えずw

これで、アウトオブメモリともという事でいいかなw

[05-Jul-2017 22:37:40] WARNING: [pool ] server reached pm.max_children setting (4), consider raising it
[05-Jul-2017 22:38:00] WARNING: [pool www] server reached pm.max_children setting (4), consider raising it
[05-Jul-2017 22:38:32] WARNING: [pool www] server reached pm.max_children setting (4), consider raising it
[05-Jul-2017 22:40:12] WARNING: [pool www] server reached pm.max_children setting (4), consider raising it

■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■

結論からすると、nginxでワーカーノードの制限を設定したけど、実質意味なし

次にphpを処理しているphp-fpmのワーカーノードのあがる数を制限した事で

今まで7ノードまで最大あがってしまって、アウトオブメモリが発生してたけど

4ノードまでしか増えないので、実質これらの最大処理数を4000弱まで耐えれるとして

1GBの弱小メモリーで処理出来る最大数として、これで一軒落着と思われる。

これで、様子を見たいと思います。nginxは、と違ってワーカーもその通信が

終わらないと、次のコネクションを貼れない仕様ではないので、これで4ワーカーでも

かなりの数をこなせるのが実証出来たので、まあよしとしましょう。

 

おっと!書き忘れたけど、nginxが返した499は、途中で切断されて通信についての

エラーコードでした。前段のphp-fpmで蹴られた可能性がありますね。

まあ、abbenchでは、Failed requests: 0となっているので、内部的に切断されたけど

RETRYしてなんとか、通信は返せたという事だとは思います。

今回は、長くなってしまいました。10737文字かいてしまいました。

Related posts