メモ > サーバ > 構築: チューニング > nginx チューニング
nginx チューニング
nginxの基本設定を改めてちゃんと調べてみた - Qiita
https://qiita.com/hclo/items/35f00b266506a707447e
開発サーバーでもこれだけはやっておくnginxの設定 - Qiita
https://qiita.com/yuse/items/fe05cec1a331306eac19
(コピペ)nginx最大パフォーマンスを出すための基本設定
https://gist.github.com/aliyome/d6a5e4bfb54985145b7297863c03aecb
Nginxのパフォーマンスを極限にするための考察 - Qiita
https://qiita.com/iwai/items/1e29adbdd269380167d2
nginxのパラメータチューニングとh2o - Qiita
https://qiita.com/cubicdaiya/items/235777dc401ec419b14e
応答速度28.8倍。WordPressをApacheからNginxに移行して感じたブログ運営
http://hamako9999.net/apache2nginx/
NginxのRatelimit発動時に、安定したアクセスを提供するngx-smart-ratelimitを開発しました | ten-snapon.com
https://ten-snapon.com/archives/2701
以下、いったんVagrant環境でデフォルト設定でベンチマークを取得したのみ
■計測前
$ uptime
18:23:15 up 38 min, 1 user, load average: 0.00, 0.03, 0.07
■計測(PHPで日時を表示するだけのページを計測)
$ ab -n 1000 -c 100 http://192.168.33.11/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.33.11 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: nginx
Server Hostname: 192.168.33.11
Server Port: 80
Document Path: /
Document Length: 167 bytes
Concurrency Level: 100
Time taken for tests: 0.435 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 323000 bytes
HTML transferred: 167000 bytes
Requests per second: 2299.92 [#/sec] (mean)
Time per request: 43.480 [ms] (mean)
Time per request: 0.435 [ms] (mean, across all concurrent requests)
Transfer rate: 725.46 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 5 4.5 5 18
Processing: 10 36 8.1 37 53
Waiting: 1 34 8.5 36 52
Total: 14 41 6.0 42 66
Percentage of the requests served within a certain time (ms)
50% 42
66% 43
75% 45
80% 46
90% 47
95% 48
98% 53
99% 58
100% 66 (longest request)
■計測(インストール直後のLaravelホーム画面を計測。100人で計1000リクエスト)
$ ab -n 1000 -c 100 http://192.168.33.11/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.33.11 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: nginx
Server Hostname: 192.168.33.11
Server Port: 80
Document Path: /
Document Length: 2321 bytes
Concurrency Level: 100
Time taken for tests: 32.582 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 3229696 bytes
HTML transferred: 2321000 bytes
Requests per second: 30.69 [#/sec] (mean)
Time per request: 3258.241 [ms] (mean)
Time per request: 32.582 [ms] (mean, across all concurrent requests)
Transfer rate: 96.80 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 2 3.2 0 14
Processing: 150 3138 590.0 3241 3964
Waiting: 150 3137 590.0 3241 3964
Total: 163 3139 587.4 3242 3964
Percentage of the requests served within a certain time (ms)
50% 3242
66% 3380
75% 3437
80% 3475
90% 3575
95% 3657
98% 3742
99% 3794
100% 3964 (longest request)
※捌ききれている
$ uptime
19:05:20 up 1:20, 1 user, load average: 17.68, 4.66, 1.66
■計測(インストール直後のLaravelホーム画面を計測。200人で計2000リクエスト。1回目)
$ ab -n 2000 -c 200 http://192.168.33.11/
〜略〜
Concurrency Level: 200
Time taken for tests: 69.349 seconds
Complete requests: 2000
Failed requests: 13
(Connect: 0, Receive: 0, Length: 13, Exceptions: 0)
Write errors: 0
Non-2xx responses: 13
Total transferred: 6421768 bytes
HTML transferred: 4614115 bytes
Requests per second: 28.84 [#/sec] (mean)
Time per request: 6934.949 [ms] (mean)
Time per request: 34.675 [ms] (mean, across all concurrent requests)
Transfer rate: 90.43 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 3 6.6 0 28
Processing: 88 6673 4797.3 5858 60123
Waiting: 60 6673 4797.3 5858 60123
Total: 88 6675 4796.1 5859 60124
Percentage of the requests served within a certain time (ms)
50% 5859
66% 6141
75% 6679
80% 6911
90% 9102
95% 9834
98% 12491
99% 13183
100% 60124 (longest request)
※捌ききれていない
$ uptime
19:12:46 up 1:27, 1 user, load average: 31.74, 11.19, 4.58
■計測(インストール直後のLaravelホーム画面を計測。200人で計2000リクエスト。2回目)
$ ab -n 2000 -c 200 http://192.168.33.11/
Concurrency Level: 200
Time taken for tests: 75.520 seconds
Complete requests: 2000
Failed requests: 1
(Connect: 0, Receive: 0, Length: 1, Exceptions: 0)
Write errors: 0
Non-2xx responses: 1
Total transferred: 6456186 bytes
HTML transferred: 4639855 bytes
Requests per second: 26.48 [#/sec] (mean)
Time per request: 7552.007 [ms] (mean)
Time per request: 37.760 [ms] (mean, across all concurrent requests)
Transfer rate: 83.49 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 3 6.8 0 28
Processing: 89 6553 2782.2 6006 60062
Waiting: 61 6552 2782.3 6006 60062
Total: 89 6556 2780.1 6006 60063
Percentage of the requests served within a certain time (ms)
50% 6006
66% 6553
75% 6902
80% 7081
90% 8592
95% 9344
98% 13094
99% 20815
100% 60063 (longest request)
※捌ききれていない
$ uptime
20:14:49 up 2:29, 1 user, load average: 26.53, 9.69, 4.44
■計測(インストール直後のLaravelホーム画面を計測。200人で計2000リクエスト。keepaliveあり。1回目)
$ ab -k -n 2000 -c 200 http://192.168.33.11/
Concurrency Level: 200
Time taken for tests: 72.615 seconds
Complete requests: 2000
Failed requests: 2
(Connect: 0, Receive: 0, Length: 2, Exceptions: 0)
Write errors: 0
Non-2xx responses: 2
Keep-Alive requests: 2
Total transferred: 6453816 bytes
HTML transferred: 4637710 bytes
Requests per second: 27.54 [#/sec] (mean)
Time per request: 7261.466 [ms] (mean)
Time per request: 36.307 [ms] (mean, across all concurrent requests)
Transfer rate: 86.79 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 3 6.7 0 28
Processing: 90 6385 3016.7 5941 60064
Waiting: 62 6385 3016.7 5941 60064
Total: 90 6387 3014.7 5941 60064
Percentage of the requests served within a certain time (ms)
50% 5941
66% 6212
75% 6634
80% 6809
90% 7346
95% 9025
98% 13095
99% 20571
100% 60064 (longest request)
※捌ききれていないが、先ほどよりは捌けている
keepaliveによって、何らかの処理が省略されて負荷が減ったか
$ uptime
19:22:05 up 1:37, 1 user, load average: 26.11, 11.06, 5.85
■計測(インストール直後のLaravelホーム画面を計測。200人で計2000リクエスト。keepaliveあり。2回目)
$ ab -k -n 2000 -c 200 http://192.168.33.11/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.33.11 (be patient)
Completed 200 requests
Completed 400 requests
Completed 600 requests
Completed 800 requests
Completed 1000 requests
Completed 1200 requests
Completed 1400 requests
Completed 1600 requests
Completed 1800 requests
Completed 2000 requests
Finished 2000 requests
Server Software: nginx
Server Hostname: 192.168.33.11
Server Port: 80
Document Path: /
Document Length: 2321 bytes
Concurrency Level: 200
Time taken for tests: 73.802 seconds
Complete requests: 2000
Failed requests: 2
(Connect: 0, Receive: 0, Length: 2, Exceptions: 0)
Write errors: 0
Non-2xx responses: 2
Keep-Alive requests: 2
Total transferred: 6453686 bytes
HTML transferred: 4637710 bytes
Requests per second: 27.10 [#/sec] (mean)
Time per request: 7380.221 [ms] (mean)
Time per request: 36.901 [ms] (mean, across all concurrent requests)
Transfer rate: 85.40 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 3 7.1 0 30
Processing: 92 6286 2990.2 5748 60051
Waiting: 62 6286 2990.2 5748 60051
Total: 92 6289 2988.2 5748 60051
Percentage of the requests served within a certain time (ms)
50% 5748
66% 6240
75% 6598
80% 6743
90% 8217
95% 8827
98% 12684
99% 13564
100% 60051 (longest request)
$ uptime
19:52:53 up 2:08, 1 user, load average: 28.34, 9.61, 4.19