<font class="Apple-style-span" face="'courier new', monospace">Hi, because of teepeedee2 thread, i tried to benchmark ( nginx + spawn-fcgi + v8cgi x 1024 children ) vs ( apache2 + mod_php + php5 ) on example of my testing and development setting.<br>
<br>############### SIMPLE LOOP AND CONCATENATION<br><br>### bench.php<br><? for($zxc=0;$zxc<999999;++$zxc) { echo ' '.$zxc; }<br><br>## time php bench.php > /dev/null<br>real 0m0.833s<br>user 0m0.712s<br>
sys 0m0.104s<br><br>### bench.esptime <br>for(var zxc=0;zxc<999999;++zxc) { system.stdout(' '+zxc); }<br><br>## time v8cgi bench.esp > /dev/null<br>real 0m0.696s<br>user 0m0.668s<br>sys 0m0.004s<br>
<br>############### SIMPLE LOOP, INDEX, MATH AND CONCATENATION<br><br>### bench2.php<br><? $str = array();<br>$str2 = ' ';<br>$max = 1000;<br>$max2 = 999999;<br>for($zxc=0;$zxc<$max2;++$zxc) { $str[$zxc*$zxc%$max] += $zxc*$zxc%$max; } <br>
for($zxc=0;$zxc<$max;++$zxc) { $str2 .= $str[$zxc]; }<br><br>## time php bench2.php<br>real 0m0.660s<br>user 0m0.604s<br>sys 0m0.040s<br><br><br>### bench2.esp<br>var $str = [];<br>var $str2 = ' ';<br>
var $max = 1000;<br>var $max2 = 999999;<br>for(var $zxc=0;$zxc<$max2;++$zxc) { $str[$zxc*$zxc%$max] += $zxc*$zxc%$max; }<br>for(var $zxc=0;$zxc<$max;++$zxc) { $str2 += $str[$zxc]; }<br><br>## time v8cgi bench2.esp<br>
real 0m0.319s<br>user 0m0.308s<br>sys 0m0.008s<br><br>############### SIMPLE LONG CONCATENATION<br><br>### bench3.php<br><? $str = '<table>';<br>$max = 999;<br>for($zxc=0;$zxc<$max;++$zxc) {<br>
$str .= '<tr>';<br> for($xcv=0;$xcv<$zxc;++$xcv) {<br> $str .= '<td>' . $zxc . ' ' . $xcv . '</td>';<br> }<br>$str .= '</tr>';<br>
}<br>$str .= '</table>';<br><br>## time php bench3.php<br>real 0m0.621s<br>user 0m0.576s<br>sys 0m0.036s<br><br>### bench3.esp<br>var $str = '<table>';<br>var $max = 999;<br>for(var $zxc=0;$zxc<$max;++$zxc) {<br>
$str += '<tr>';<br> for(var $xcv=0;$xcv<$zxc;++$xcv) {<br> $str += '<td>' + $zxc + ' ' + $xcv + '</td>';<br> }<br>$str += '</tr>';<br>
}<br>$str += '</table>';<br><br>## time v8cgi bench3.esp<br>real 0m0.831s<br>user 0m0.696s<br>sys 0m0.092s<br><br>############### INTERPRETER<br><br>this benchmark show that v8cgi and php quite the same except php faster on string concatenation (because javascript using ambigous "+" operator), and v8cgi faster on variable indexing (or so i guess because v8 developer said so..)<br>
<br>############### WEB SERVER + COMPRESSION + INTERPRETER<br><br>and the benchmark using web servers, i don't know if it's fair configuration:<br><br>############### my nginx configuration (i'm newbie):<br><br>
user www-data;<br>worker_processes 1;<br><br>error_log /var/log/nginx/error.log info;<br>pid /var/run/nginx.pid;<br><br>events {<br> worker_connections 1024;<br>}<br><br>http {<br> include /etc/nginx/mime.types;<br>
<br> access_log /var/log/nginx/access.log;<br><br> sendfile on;<br><br> keepalive_timeout 65;<br> tcp_nodelay on;<br><br> gzip on;<br> gzip_disable msie6;<br><br> include /etc/nginx/conf.d/*.conf;<br>
include /etc/nginx/sites-enabled/*;<br>}<br><br>server {<br> listen 80;<br> server_name localhost;<br><br> access_log /var/log/nginx/localhost.access.log;<br> error_log /var/log/nginx/localhost.error.log notice;<br>
<br> location / {<br> root /home/kyz/Projects/site;<br> index index.html index.htm; <br> autoindex on; <br> } <br>
<br> location ~ \.(sjs|ssjs|esp)$ {<br> fastcgi_pass <a href="http://127.0.0.1:9000">127.0.0.1:9000</a>;<br> fastcgi_param SCRIPT_FILENAME /home/kyz/Projects/site$fastcgi_script_name;<br>
include fastcgi_params; <br> } <br><br> location /doc {<br>
root /usr/share;<br> autoindex on; <br> allow 127.0.0.1; <br> deny all; <br> } <br><br> location /images {<br>
root /usr/share;<br> autoindex off; <br> } <br><br>}<br><br>############### my apache2 configuration (i'm quite newbie too, i guess ^^ and i'm not using apache anymore) :<br>
<br><VirtualHost *:80><br> ServerSignature Off<br> <Directory /><br> Options FollowSymLinks<br> AllowOverride None<br> </Directory><br> DocumentRoot /home/kyz/Projects/site<br>
<Directory /home/kyz/Projects/site ><br> Options FollowSymLinks Indexes<br> AllowOverride AuthConfig FileInfo Limit Options<br> Order Allow,Deny<br> Allow from All<br>
</Directory><br> SetOutputFilter DEFLATE<br> BrowserMatch ^Mozilla/4 gzip-only-text/html<br> BrowserMatch ^Mozilla/4\.0[678] no-gzip<br> BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html<br>
AddOutputFilterByType DEFLATE text/plain<br> AddOutputFilterByType DEFLATE text/xml<br> AddOutputFilterByType DEFLATE application/xhtml+xml<br> AddOutputFilterByType DEFLATE text/css<br> AddOutputFilterByType DEFLATE application/xml<br>
AddOutputFilterByType DEFLATE image/svg+xml<br> AddOutputFilterByType DEFLATE application/rss+xml<br> AddOutputFilterByType DEFLATE application/atom_xml<br> AddOutputFilterByType DEFLATE application/javascript<br>
AddOutputFilterByType DEFLATE application/x-javascript<br> AddOutputFilterByType DEFLATE application/x-httpd-php<br> AddOutputFilterByType DEFLATE application/x-httpd-fastphp<br> AddOutputFilterByType DEFLATE application/x-httpd-eruby<br>
AddOutputFilterByType DEFLATE text/html<br> DeflateFilterNote deflate_ratio<br> LogFormat "%v %h %l %u %t \"%r\" %>s %b mod_deflate: %{deflate_ratio}n pct." vhost_with_deflate_info<br>
CustomLog /var/log/apache2/kyz_deflate_access.log vhost_with_deflate_info<br> ErrorLog /var/log/apache2/kyz_error.log<br> LogLevel warn<br> CustomLog /var/log/apache2/kyz_access.log combined<br>
</VirtualHost><br><br>############### my spawn fcgi configration (1024 child):<br><br>V8C_SCRIPT="/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -F 1024 `which v8cgi` $ESP_SCRIPT"<br><br>
############### the hello someone script<br><br>the test.php script:<br><h1>Hello <? echo $_GET['name']; ?></h1><br><br>the test.esp script:<br>response.write('<h1>Hello '+<a href="http://request.get.name">request.get.name</a>+'</h1>');<br>
<br>############### NGINX0.8 hello someone<br><br>ab -n 5000 -c 10 <a href="http://127.0.0.1/test.esp?name=john">http://127.0.0.1/test.esp?name=john</a><br>This is ApacheBench, Version 2.3 <$Revision: 655654 $><br>Copyright 1996 Adam Twiss, Zeus Technology Ltd, <a href="http://www.zeustech.net/">http://www.zeustech.net/</a><br>
Licensed to The Apache Software Foundation, <a href="http://www.apache.org/">http://www.apache.org/</a><br><br>Benchmarking 127.0.0.1 (be patient)<br>Completed 500 requests<br>Completed 1000 requests<br>Completed 1500 requests<br>
Completed 2000 requests<br>Completed 2500 requests<br>Completed 3000 requests<br>Completed 3500 requests<br>Completed 4000 requests<br>Completed 4500 requests<br>Completed 5000 requests<br>Finished 5000 requests<br><br><br>
Server Software: nginx/0.8.19<br>Server Hostname: 127.0.0.1<br>Server Port: 80<br><br>Document Path: /test.esp?name=john<br>Document Length: 19 bytes<br><br>Concurrency Level: 10<br>
Time taken for tests: 24.448 seconds<br>Complete requests: 5000<br>Failed requests: 0<br>Write errors: 0<br>Total transferred: 705000 bytes<br>HTML transferred: 95000 bytes<br>Requests per second: 204.51 [#/sec] (mean)<br>
Time per request: 48.897 [ms] (mean)<br>Time per request: 4.890 [ms] (mean, across all concurrent requests)<br>Transfer rate: 28.16 [Kbytes/sec] received<br><br>Connection Times (ms)<br> min mean[+/-sd] median max<br>
Connect: 0 0 1.9 0 48<br>Processing: 5 49 38.7 35 277<br>Waiting: 0 48 38.7 34 277<br>Total: 5 49 38.8 35 277<br><br>Percentage of the requests served within a certain time (ms)<br>
50% 35<br> 66% 41<br> 75% 47<br> 80% 56<br> 90% 113<br> 95% 138<br> 98% 166<br> 99% 183<br> 100% 277 (longest request)<br><br>############### APACHE2 hello someone<br><br> ab -n 5000 -c 1 <a href="http://127.0.0.1/test.php?name=john">http://127.0.0.1/test.php?name=john</a><br>
This is ApacheBench, Version 2.3 <$Revision: 655654 $><br>Copyright 1996 Adam Twiss, Zeus Technology Ltd, <a href="http://www.zeustech.net/">http://www.zeustech.net/</a><br>Licensed to The Apache Software Foundation, <a href="http://www.apache.org/">http://www.apache.org/</a><br>
<br>Benchmarking 127.0.0.1 (be patient)<br>Completed 500 requests<br>Completed 1000 requests<br>Completed 1500 requests<br>Completed 2000 requests<br>Completed 2500 requests<br>Completed 3000 requests<br>Completed 3500 requests<br>
Completed 4000 requests<br>Completed 4500 requests<br>Completed 5000 requests<br>Finished 5000 requests<br><br><br>Server Software: Apache/2.2.12<br>Server Hostname: 127.0.0.1<br>Server Port: 80<br>
<br>Document Path: /test.php?name=john<br>Document Length: 329 bytes<br><br>Concurrency Level: 1<br>Time taken for tests: 1.959 seconds<br>Complete requests: 5000<br>Failed requests: 0<br>
Write errors: 0<br>Non-2xx responses: 5000<br>Total transferred: 2660000 bytes<br>HTML transferred: 1645000 bytes<br>Requests per second: 2551.83 [#/sec] (mean)<br>Time per request: 0.392 [ms] (mean)<br>
Time per request: 0.392 [ms] (mean, across all concurrent requests)<br>Transfer rate: 1325.75 [Kbytes/sec] received<br><br>Connection Times (ms)<br> min mean[+/-sd] median max<br>Connect: 0 0 0.0 0 0<br>
Processing: 0 0 0.2 0 6<br>Waiting: 0 0 0.1 0 6<br>Total: 0 0 0.2 0 7<br><br>Percentage of the requests served within a certain time (ms)<br> 50% 0<br>
66% 0<br> 75% 0<br> 80% 0<br> 90% 0<br> 95% 0<br> 98% 0<br> 99% 1<br> 100% 7 (longest request)<br><br>ab -n 5000 -c 10 <a href="http://127.0.0.1/test.php?name=john">http://127.0.0.1/test.php?name=john</a><br>
This is ApacheBench, Version 2.3 <$Revision: 655654 $><br>Copyright 1996 Adam Twiss, Zeus Technology Ltd, <a href="http://www.zeustech.net/">http://www.zeustech.net/</a><br>Licensed to The Apache Software Foundation, <a href="http://www.apache.org/">http://www.apache.org/</a><br>
<br>Benchmarking 127.0.0.1 (be patient)<br>Completed 500 requests<br>Completed 1000 requests<br>Completed 1500 requests<br>Completed 2000 requests<br>Completed 2500 requests<br>Completed 3000 requests<br>Completed 3500 requests<br>
Completed 4000 requests<br>Completed 4500 requests<br>Completed 5000 requests<br>Finished 5000 requests<br><br><br>Server Software: Apache/2.2.12<br>Server Hostname: 127.0.0.1<br>Server Port: 80<br>
<br>Document Path: /test.php?name=john<br>Document Length: 20 bytes<br><br>Concurrency Level: 10<br>Time taken for tests: 1.890 seconds<br>Complete requests: 5000<br>Failed requests: 4978<br>
(Connect: 0, Receive: 0, Length: 4978, Exceptions: 0)<br>Write errors: 0<br>Non-2xx responses: 4980<br>Total transferred: 2654880 bytes<br>HTML transferred: 1638900 bytes<br>Requests per second: 2645.16 [#/sec] (mean)<br>
Time per request: 3.780 [ms] (mean)<br>Time per request: 0.378 [ms] (mean, across all concurrent requests)<br>Transfer rate: 1371.60 [Kbytes/sec] received<br><br>Connection Times (ms)<br> min mean[+/-sd] median max<br>
Connect: 0 2 0.6 2 9<br>Processing: 1 2 0.7 2 10<br>Waiting: 0 2 0.7 1 9<br>Total: 1 4 0.8 4 11<br>WARNING: The median and mean for the waiting time are not within a normal deviation<br>
These results are probably not that reliable.<br><br>Percentage of the requests served within a certain time (ms)<br> 50% 4<br> 66% 4<br> 75% 4<br> 80% 4<br> 90% 4<br> 95% 5<br>
98% 5<br> 99% 6<br> 100% 11 (longest request)<br><br>############### APACHE2 bench3.php max 99 with echo<br><br>ab -n 50 -c 10 <a href="http://127.0.0.1/bench3.php">http://127.0.0.1/bench3.php</a><br>This is ApacheBench, Version 2.3 <$Revision: 655654 $><br>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, <a href="http://www.zeustech.net/">http://www.zeustech.net/</a><br>Licensed to The Apache Software Foundation, <a href="http://www.apache.org/">http://www.apache.org/</a><br>
<br>Benchmarking 127.0.0.1 (be patient).....done<br><br><br>Server Software: Apache/2.2.12<br>Server Hostname: 127.0.0.1<br>Server Port: 80<br><br>Document Path: /bench3.php<br>Document Length: 331 bytes<br>
<br>Concurrency Level: 10<br>Time taken for tests: 0.040 seconds<br>Complete requests: 50<br>Failed requests: 1<br> (Connect: 0, Receive: 0, Length: 1, Exceptions: 0)<br>Write errors: 0<br>Non-2xx responses: 50<br>
Total transferred: 127498 bytes<br>HTML transferred: 116968 bytes<br>Requests per second: 1258.34 [#/sec] (mean)<br>Time per request: 7.947 [ms] (mean)<br>Time per request: 0.795 [ms] (mean, across all concurrent requests)<br>
Transfer rate: 3133.50 [Kbytes/sec] received<br><br>Connection Times (ms)<br> min mean[+/-sd] median max<br>Connect: 0 2 2.8 2 12<br>Processing: 1 5 4.6 2 23<br>
Waiting: 1 3 3.1 2 12<br>Total: 3 7 5.0 4 25<br><br>Percentage of the requests served within a certain time (ms)<br> 50% 4<br> 66% 11<br> 75% 12<br> 80% 13<br>
90% 14<br> 95% 14<br> 98% 25<br> 99% 25<br> 100% 25 (longest request)<br><br><div>ab -n 50 -c 1 <a href="http://127.0.0.1/bench3.php">http://127.0.0.1/bench3.php</a></div><div>This is ApacheBench, Version 2.3 <$Revision: 655654 $></div>
<div>Copyright 1996 Adam Twiss, Zeus Technology Ltd, <a href="http://www.zeustech.net/">http://www.zeustech.net/</a></div><div>Licensed to The Apache Software Foundation, <a href="http://www.apache.org/">http://www.apache.org/</a></div>
<div><br></div><div>Benchmarking 127.0.0.1 (be patient).....done</div><div><br></div><div><br></div><div>Server Software: Apache/2.2.12</div><div>Server Hostname: 127.0.0.1</div><div>Server Port: 80</div>
<div><br></div><div>Document Path: /bench3.php</div><div>Document Length: 67840 bytes</div><div><br></div><div>Concurrency Level: 1</div><div>Time taken for tests: 0.201 seconds</div><div>Complete requests: 50</div>
<div>Failed requests: 32</div><div> (Connect: 0, Receive: 0, Length: 32, Exceptions: 0)</div><div>Write errors: 0</div><div>Non-2xx responses: 32</div><div>Total transferred: 1241628 bytes</div>
<div>HTML transferred: 1231712 bytes</div><div>Requests per second: 248.32 [#/sec] (mean)</div><div>Time per request: 4.027 [ms] (mean)</div><div>Time per request: 4.027 [ms] (mean, across all concurrent requests)</div>
<div>Transfer rate: 6021.90 [Kbytes/sec] received</div><div><br></div><div>Connection Times (ms)</div><div> min mean[+/-sd] median max</div><div>Connect: 0 0 0.0 0 0</div><div>
Processing: 0 4 4.8 0 11</div><div>Waiting: 0 2 2.9 0 10</div><div>Total: 0 4 4.9 0 11</div><div><br></div><div>Percentage of the requests served within a certain time (ms)</div>
<div> 50% 0</div><div> 66% 10</div><div> 75% 10</div><div> 80% 10</div><div> 90% 11</div><div> 95% 11</div><div> 98% 11</div><div> 99% 11</div><div> 100% 11 (longest request)</div>
<div><br></div>############### NGINX0.8 bench3.esp max 99 with response.write<br><br>ab -n 50 -c 1 <a href="http://127.0.0.1/bench3.esp">http://127.0.0.1/bench3.esp</a><br>This is ApacheBench, Version 2.3 <$Revision: 655654 $><br>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, <a href="http://www.zeustech.net/">http://www.zeustech.net/</a><br>Licensed to The Apache Software Foundation, <a href="http://www.apache.org/">http://www.apache.org/</a><br>
<br>Benchmarking 127.0.0.1 (be patient).....done<br><br><br>Server Software: nginx/0.8.19<br>Server Hostname: 127.0.0.1<br>Server Port: 80<br><br>Document Path: /bench3.esp<br>Document Length: 67840 bytes<br>
<br>Concurrency Level: 1<br>Time taken for tests: 2.455 seconds<br>Complete requests: 50<br>Failed requests: 0<br>Write errors: 0<br>Total transferred: 3398100 bytes<br>HTML transferred: 3392000 bytes<br>
Requests per second: 20.37 [#/sec] (mean)<br>Time per request: 49.094 [ms] (mean)<br>Time per request: 49.094 [ms] (mean, across all concurrent requests)<br>Transfer rate: 1351.87 [Kbytes/sec] received<br>
<br>Connection Times (ms)<br> min mean[+/-sd] median max<br>Connect: 0 0 0.0 0 0<br>Processing: 27 49 11.1 54 60<br>Waiting: 26 48 11.0 54 60<br>Total: 27 49 11.1 55 60<br>
<br>Percentage of the requests served within a certain time (ms)<br> 50% 55<br> 66% 55<br> 75% 56<br> 80% 57<br> 90% 58<br> 95% 60<br> 98% 60<br> 99% 60<br> 100% 60 (longest request)<br>
<br></font><div><font class="Apple-style-span" face="'courier new', monospace">############### NGINX0.8 other benchmark (print recursively all global variables)</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br>
</font><div><font class="Apple-style-span" face="'courier new', monospace"><div>ab -n 2000 -c 1000 <a href="http://127.0.0.1/index.esp">http://127.0.0.1/index.esp</a></div><div>This is ApacheBench, Version 2.3 <$Revision: 655654 $></div>
<div>Copyright 1996 Adam Twiss, Zeus Technology Ltd, <a href="http://www.zeustech.net/">http://www.zeustech.net/</a></div><div>Licensed to The Apache Software Foundation, <a href="http://www.apache.org/">http://www.apache.org/</a></div>
<div><br></div><div>Benchmarking 127.0.0.1 (be patient)</div><div>Completed 200 requests</div><div>Completed 400 requests</div><div>Completed 600 requests</div><div>Completed 800 requests</div><div>Completed 1000 requests</div>
<div>Completed 1200 requests</div><div>Completed 1400 requests</div><div>Completed 1600 requests</div><div>Completed 1800 requests</div><div>Completed 2000 requests</div><div>Finished 2000 requests</div><div><br></div><div>
<br></div><div>Server Software: nginx/0.8.19</div><div>Server Hostname: 127.0.0.1</div><div>Server Port: 80</div><div><br></div><div>Document Path: /index.esp</div><div>Document Length: 47 bytes</div>
<div><br></div><div>Concurrency Level: 1000</div><div>Time taken for tests: 3.690 seconds</div><div>Complete requests: 2000</div><div>Failed requests: 482</div><div> (Connect: 0, Receive: 0, Length: 482, Exceptions: 0)</div>
<div>Write errors: 0</div><div>Non-2xx responses: 482</div><div>Total transferred: 427652 bytes</div><div>HTML transferred: 164372 bytes</div><div>Requests per second: 542.06 [#/sec] (mean)</div>
<div>Time per request: 1844.801 [ms] (mean)</div><div>Time per request: 1.845 [ms] (mean, across all concurrent requests)</div><div>Transfer rate: 113.19 [Kbytes/sec] received</div><div><br></div><div>
Connection Times (ms)</div><div> min mean[+/-sd] median max</div><div>Connect: 0 83 379.7 48 3008</div><div>Processing: 33 514 384.3 343 1295</div><div>Waiting: 30 513 384.3 342 1287</div>
<div>Total: 108 597 528.9 344 3378</div><div><br></div><div>Percentage of the requests served within a certain time (ms)</div><div> 50% 344</div><div> 66% 392</div><div> 75% 1142</div><div> 80% 1145</div>
<div> 90% 1150</div><div> 95% 1199</div><div> 98% 1277</div><div> 99% 3346</div><div> 100% 3378 (longest request)</div><div><br></div></font><div><font class="Apple-style-span" face="'courier new', monospace">############### AND????<br>
<br>so is it already good enough? because nginx never fail when apache mostly did (except less than 10 connections).. and if the fastcgi script was executed too slow..</font></div><div><font class="Apple-style-span" face="'courier new', monospace">btw i'm sorry if this e-mail too large ^^ i'm so excited and happy that i found a good justification for leaving apache.. ^^<br>
</font><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">Regards,</font></div><div><font class="Apple-style-span" face="'courier new', monospace">GB</font></div>
</div></div></div>