Nginxã¨Apacheã®æ¯è¼ï¼Nginxã¯CGIã¹ã¯ãªãããæ®éã§ã¯å©ç¨ã§ããªã件
Nginxã¯Apacheããå¦çé度ãæ©ãã¨ããã¦ãæ¨ä»äººæ°ãåºã¦ãã¦ããã
Nginxã¨Apacheã®é度æ¯è¼ãæ¤è¨ããã¨ã¨ãã«ãé度ã¨æ©è½ã®ç価交æã«ã¤ãã¦
æ¤è¨ãããã
ã¾ãã¯ãããã«ç°¡æ½ã§ãããã¼ã¿ãããã
参考:mod_php(Apache)とspawn-fcgi(nginx)でのパフォーマンス比較
æ¬ãµã¤ããè¦ããªãã£ãã®ã§ããã£ãã·ã¥ããä¸é¨å¼ç¨ããã¦ãããã
Hoståã¯æ½è±¡åãã¦æ²è¼ã
1æ¥ç¶ã§100ã¢ã¯ã»ã¹:Apache VS NGINX
Apache
ã¾ãã¯Webã¹ã¿ãã¯ã®å¤§å¾¡æãApacheã
ab -c 1 -n 100 -H "Host: xxx.xxx" http://xxx.xxx:82/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/Benchmarking xxx.xxx (be patient).....done
Server Software: Apache/2.2.3
Server Hostname: xxx.xxx
Server Port: 82Document Path: /
Document Length: 18653 bytesConcurrency Level: 1
Time taken for tests: 9.100542 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 1886900 bytes
HTML transferred: 1865300 bytes
Requests per second: 10.99 [#/sec] (mean)
Time per request: 91.005 [ms] (mean)
Time per request: 91.005 [ms] (mean, across all concurrent requests)
Transfer rate: 202.41 [Kbytes/sec] receivedConnection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 73 90 23.3 77 157
Waiting: 62 79 23.3 66 146
Total: 73 90 23.3 77 157Percentage of the requests served within a certain time (ms)
50% 77
66% 79
75% 115
80% 115
90% 117
95% 153
98% 155
99% 157
100% 157 (longest request)
Nginx
対ããã¯Webã¹ã¿ãã¯ã®æ°ææãNginxã
Nginx
ab -c 1 -n 100 -H "Host: xxx.xxx" http://xxx.xxx:81/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/Benchmarking xxx.xxx (be patient).....done
Server Software: nginx/0.7.64
Server Hostname: xxx.xxx
Server Port: 81Document Path: /
Document Length: 18653 bytesConcurrency Level: 1
Time taken for tests: 9.789250 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 1886000 bytes
HTML transferred: 1865300 bytes
Requests per second: 10.22 [#/sec] (mean)
Time per request: 97.893 [ms] (mean)
Time per request: 97.893 [ms] (mean, across all concurrent requests)
Transfer rate: 188.06 [Kbytes/sec] receivedConnection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 73 97 127.7 75 1340
Waiting: 62 73 23.4 65 143
Total: 73 97 127.7 75 1340Percentage of the requests served within a certain time (ms)
50% 75
66% 76
75% 77
80% 80
90% 149
95% 151
98% 153
99% 1340
100% 1340 (longest request)
ApacheãRequests per secondï¼ç§éå¦çæ°ï¼ã10.99[#/sec] (mean)ã«å¯¾ãã¦ã
Nginxã®å ´åã10.22 [#/sec] (mean)ã¨ãªã£ã¦ããã100åã¢ã¯ã»ã¹ã§ããã°ãè¥å¹²Apacheãåªä½ã
åæ10æ¥ç¶ã§20ã¢ã¯ã»ã¹:Apache VS Nginx
次ã®æ¡ä»¶ã¯ãåæ10æ¥ç¶ã§20ã¢ã¯ã»ã¹ãããå ´åãå®éã®Webã¯åæã¢ã¯ã»ã¹ãå¤ãã ããããã
ããããæ¡ä»¶ã»ããå®è·µåãã ã
Apache(åæ10æ¥ç¶ã§20ã¢ã¯ã»ã¹)
date; ab -c 10 -t 20 -H "Host: xxx.xxx" http://xxx.xxx/;date
2010å¹´ 2æ 11æ¥ æ¨ææ¥ 16:07:23 JST
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/Benchmarking xxx.xxx (be patient)
Finished 611 requestsServer Software: Apache/2.2.3
Server Hostname: xxx.xxx
Server Port: 82Document Path: /
Document Length: 18376 bytesConcurrency Level: 10
Time taken for tests: 37.188158 seconds
Complete requests: 611
Failed requests: 0
Write errors: 0
Total transferred: 11364056 bytes
HTML transferred: 11231864 bytes
Requests per second: 16.43 [#/sec] (mean)
Time per request: 608.644 [ms] (mean)
Time per request: 60.864 [ms] (mean, across all concurrent requests)
Transfer rate: 298.40 [Kbytes/sec] receivedConnection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 95 244 289.4 188 2277
Waiting: 83 204 215.6 170 1851
Total: 95 244 289.4 188 2277Percentage of the requests served within a certain time (ms)
50% 188
66% 209
75% 229
80% 240
90% 271
95% 312
98% 1736
99% 1795
100% 2277 (longest request)
Nginx(åæ10æ¥ç¶ã§20ã¢ã¯ã»ã¹)
Nginx
date; ab -c 10 -t 20 -H "Host: xxx.xxx" http://xxx.xxx:81/;date
2010å¹´ 2æ 11æ¥ æ¨ææ¥ 16:10:52 JST
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/Benchmarking xxx.xxx (be patient)
Finished 868 requestsServer Software: nginx/0.7.64
Server Hostname: xxx.xxx
Server Port: 81Document Path: /
Document Length: 18376 bytesConcurrency Level: 10
Time taken for tests: 20.1645 seconds
Complete requests: 868
Failed requests: 0
Write errors: 0
Total transferred: 16146515 bytes
HTML transferred: 15966632 bytes
Requests per second: 43.40 [#/sec] (mean)
Time per request: 230.434 [ms] (mean)
Time per request: 23.043 [ms] (mean, across all concurrent requests)
Transfer rate: 788.34 [Kbytes/sec] receivedConnection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 134 228 49.6 223 526
Waiting: 121 215 48.9 210 513
Total: 134 228 49.6 223 526Percentage of the requests served within a certain time (ms)
50% 223
66% 243
75% 260
80% 268
90% 290
95% 308
98% 339
99% 360
100% 526 (longest request)
ApacheãRequests per secondï¼ç§éå¦çæ°ï¼ã16.43[#/sec] (mean)ã«å¯¾ãã¦ã
Nginxã®å ´åã43.40[#/sec] (mean)ã¨ãªã£ã¦ããã
åæ10æ¥ç¶ã®20åã¢ã¯ã»ã¹æ¡ä»¶ã§ããã°ãå§åçã«ApacheããNGINXãåªä½ã
Nginxã®é度ã¨æ©è½
Nginxã¯è»½éã§ããããã¯ãã«ãªWebãµã¼ãã ã
ãã¼ããã©ã³ãµã®æ©è½ãåãã¦ãããã¹ã±ã¼ã«ã¢ã¦ãæ§æãåæã¢ã¯ã»ã¹ã®å¦çã«ãé·ãã¦ããã
ããã¯Apacheãæ©è½æ¡å
ãç®æããã®ã«å¯¾ãã¦ãNGINXã¯å¤§éå¦çãã¹ãã¼ãéè¦ãå¾¹åºçã«è¿½æ±ããçµæã ã
ãSimple is bestãã¨ããå²å¦
ä¾ãã°èå³æ·±ãæ©è½ã®å²å¦ã¨ãã¦ãç´ç²ãªCGIã¹ã¯ãªããã®åãæ±ããããã
NGINXのマニュアル「ThttpdCGI」の項ã«ã¯
以ä¸ã®ããã«ããã
Nginx doesn't serve CGI scripts. While there's all sorts of hacks to work around this, none of them are really satisfactory or general-purpose.
æ訳ããã¨ã
ããããããï¼Nginxï¼ã¯ãCGIã¹ã¯ãªãããªããæ±ããªããã ããã
CGIã¹ã¯ãªããå¨ãã£ã¦ãããããªããã¯ãããã®ããããã
ããããã®ã«æ§ãã®ã£ã¦æ¬å½ã«ããã ãããªããæ®éãããªãããã
ã¨ãªãã
ã§ãã©ããã¦ã使ããããªãã£ã¦ãNginxã¯ãã¨ãã ã¡ã®è»½éWebãµã¼ã
ãthttpdãã®ç´¹ä»ï¼ãããã·æ¹æ³ï¼ãè¼ãã¦ãããã¾ãFastCGIã ã£ãã使ããã
ï¼PerlãPHPãPythonã¯FastCGIä¸ã§åä½ãããï¼
ãã®ãããããå¨ç¨ã§å°ãé
ãApacheãç´¹ä»ããªãããã«ãã¹ãã¼ãéè¦ã®å²å¦ã
貫徹ãã¦ããã
Simple is best:ä¸ã¤ã®ãã¨ããã¾ããã
Unixã®ä¸çã«ã¯ããSimple is bestãã¨ããå²å¦ãããããä¸ã¤ã®ãã¨ããã¾ããããã ã
ããã¯ééããªãUnixã®ä¸çã§ã¯ççã ããã³ã³ãã¥ã¼ãã£ã³ã°ã®ä¸çã«ããã¦æ±ç¨çãªæ³åã®ä¸ã¤ã ã
Nginxã¯ãã®æåä¾ã ããã
Nginxã¯æ©è½ãApacheã¨æ¯è¼ãã¦æ¸ããåãå ã«è¿°ã¹ã大éå¦çãæã«ãããã¦ããã
ããã¯ããã§æåãã¦ããä¾ã ããã
ä»æ¥ã®åè¨ï¼ä¸ã¤ã®ãã¨ããã¾ããã