JRuby 㨠CRuby ã® Rails ã¢ããªã®æ§è½æ¯ (render :text ã«ã¦)
Thin ã¨ã GlassFish ã¨ãæ°ã«ãªã£ã¦ã¯ãããã§ãããèªèº«ã®ä½æã¨ãã¦åãã£ã¦ããªãã£ãã®ã§ãç°¡åãªã¨ããã§æ¯ã¹ã¦ã¿ã¾ããã"render :text => ... "ã®ã¹ã«ã¼ããããã¿ã¦ã¾ããã絶対å¤çãªæ§è½ã§ã¯ãªããç¸å¯¾çãªæè¦ãæ´ã¿ããã¦ãã£ã¦ã¿ã¾ããã
ç°å¢
- iMac (intel Core 2 Duo 2.33GHz)
- Mac OS X 10.5.6
- å¦çç³»ãã©ã¤ãã©ãªã®ãã¼ã¸ã§ã³ã¯ä»¥ä¸ã®ã¨ãã
% ruby186 -v ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-darwin9.6.0] % ruby187 -v ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9.5.0] % jruby -v jruby 1.1.6RC1 (ruby 1.8.6 patchlevel 114) (2008-12-03 rev 8263) [i386-java] % java -version java version "1.6.0_07" Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153) Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-57, mixed mode) % $GLASSFISH_HOME/bin/asadmin version [GlassFish v3.0-Prelude Prelude (build b28c)] % $GLASSFISH_HOME/bin/asadmin version ãã¼ã¸ã§ã³ = Sun GlassFish Enterprise Server v2.1 % gem list --local *** LOCAL GEMS *** glassfish (0.9.1) jetty-rails (0.8) mongrel (1.1.5) mongrel_jcluster (0.0.1) rails (2.2.2,2.1.2) thin (1.0.0) warbler (0.9.12) ... # ç®ã¼ãããã®ãé©å½ã«æç²
測ãæ¹
- render :text => 'Hello world!' ããã ãã®ã¢ã¯ã·ã§ã³ãç¨æ
- ãã¼ã¿ãã¼ã¹ã«åãåãããå¦çã¯ã¾ãä»åº¦
- ãããåã ãã© production ã¢ã¼ã
- ãã£ãããªã®ã§ config.threadsafe! ã uncomment
- åä¸çä½ãã apache bench ã§è² è·
- % ab -c 10 -n 10000 ã¢ããªã®URL
- ã¢ããªã±ã¼ã·ã§ã³ãµã¼ããã¨ã®ã¹ã«ã¼ãããã観å¯
- 絶対å¤ããç¸å¯¾çãªæ§è½å·®ãã¿ãã®ã主ç®ç
çµæ
çµã¿åãã | Requests per second (mean) | åºæºå | Time per request (mean) |
---|---|---|---|
å¦çç³»+APãµã¼ã | [#/sec] | åºæºå¤ã 100 ã¨ãã¦æç® | [ms] |
ruby186 + mongrel | 309.64 | 100 | 3.230 |
ruby186 + mongrel* | 450.91 | 146 | 2.218 |
ruby186 + mongrel** | 305.48 | 99 | 3.274 |
ruby187 + mongrel | 308.39 | 100 | 3.243 |
ruby186 + thin | 455.60 | 147 | 2.195 |
jruby + webrick | 137.71 | 44 | 7.261 |
jruby + webrick** | 153.62 | 50 | 6.509 |
jruby + jetty-rails | 185.49 | 60 | 5.391 |
jruby + glassfish-v3-p | 323.79 | 105 | 3.088 |
jruby + glassfish-v3-p** | 240.05 | 78 | 4.166 |
jruby + glassfish-v2.1 | 373.67 | 121 | 2.676 |
注1: * ã®é¨åã¯ãrails 2.1.2 ã§è¨æ¸¬ãããã®ãã»ãã¯ãã¹ã¦ 2.2.2ã
注2: ** ã®é¨åã¯ãconfig.threadsafe! ãªãã·ã§ã³ãã³ã¡ã³ãã¢ã¦ãã®ã¾ã¾ã«ãã¦è¨æ¸¬ã
注3: jruby + mongrel ã試ãã¦ã¿ããã£ãããjrubycli ããªãã¨ããã¨ã©ã¼ãã§ããバグらしいã
ææ
- render :text => ... ã§æ¯è¼ããã¨ã
- rails-2.2.2 㯠rails-2.1.2 ããé ãã£ã
- threadsafe ãªãã·ã§ã³ã®å½±é¿ã¯ã¾ã ãªãã¨ãè¨ããªã (ãã¨ã§è©³ããã¿ã¦ã¿ãã)
- thin ãµã¼ããéã£!
- jruby + glassfish ããã£ããããã°ã£ã¦ã
- ã§ãããããããªã³ãã¯ã§ãã
- glassfish-v3-prelude ã§ã¯ä½¿ç¨ã¡ã¢ãªãå¢ãã¦ããã¨æ§è½ãå£å... (-Xmx ãªãã·ã§ã³ã®è¨å®ããª?)
- glassfish-v2.1 ã¯å®å®ããã¤ã¹ã«ã¼ãããããã
- ãã«ãã³ã¢ç°å¢ã§è¤æ°ã¤ã³ã¹ã¿ã³ã¹ç¨æããã¨ãã®æ§è½ãæ¯ã¹ã¦ã¿ãã
ä½æ¥ãã° (é©å½ã«æç²)
- ruby186 + mongrel
% ruby186 script/server -e production => Booting Mongrel (use 'script/server webrick' to force WEBrick) => Rails 2.2.2 application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with production environment... ** Rails loaded. ** Loading any Rails specific GemPlugins ** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart). ** Rails signals registered. HUP => reload (without restart). It might not work well. ** Mongrel 1.1.5 available at 0.0.0.0:3000 ** Use CTRL-C to stop.
-
- èµ·åæã®ã¡ã¢ãªä½¿ç¨é㯠30MBå¼±
- ab å®è¡æ㯠CPU 98%åå¾ãã¡ã¢ãª 31MBåå¾
- ruby186 + mongrel*
% ruby186 script/server -e production => Booting Mongrel (use 'script/server webrick' to force WEBrick) => Rails 2.1.2 application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with production environment... ** Rails loaded. ** Loading any Rails specific GemPlugins ** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart). ** Rails signals registered. HUP => reload (without restart). It might not work well. ** Mongrel 1.1.5 available at 0.0.0.0:3000 ** Use CTRL-C to stop.
-
- èµ·åæã®ã¡ã¢ãªä½¿ç¨é㯠30MBå¼± (2.2.2 ããã¯æ°æã¡å°ãã)
- ab å®è¡æ㯠CPU 98%åå¾ãã¡ã¢ãª 31MBåå¾
- ruby187 + mongrel
% ruby187 script/server -e production => Booting Mongrel (use 'script/server webrick' to force WEBrick) => Rails 2.2.2 application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with production environment... ** Rails loaded. ** Loading any Rails specific GemPlugins ** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart). ** Rails signals registered. HUP => reload (without restart). It might not work well. ** Mongrel 1.1.5 available at 0.0.0.0:3000 ** Use CTRL-C to stop.
-
- èµ·åæã®ã¡ã¢ãªä½¿ç¨é㯠30MBå¼±
- ab å®è¡æ㯠CPU 98%åå¾ãã¡ã¢ãª 31MBåå¾
- ruby186 + thin
% thin start -e production >> Using rails adapter >> Thin web server (v1.0.0 codename That's What She Said) >> Maximum connections set to 1024 >> Listening on 0.0.0.0:3000, CTRL+C to stop
-
- èµ·åæã®ã¡ã¢ãªä½¿ç¨é㯠30MBå¼±
- ab å®è¡æ㯠CPU 94%åå¾ãã¡ã¢ãª 32MBåå¾
% jruby script/server -e production JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL => Booting WEBrick... => Rails 2.2.2 application started on http://0.0.0.0:3000 => Ctrl-C to shutdown server; call with --help for options [2009-01-27 18:33:31] INFO WEBrick 1.3.1 [2009-01-27 18:33:31] INFO ruby 1.8.6 (2008-12-03) [java] [2009-01-27 18:33:36] INFO WEBrick::HTTPServer#start: pid=76137 port=3000
-
- èµ·åæã®ã¡ã¢ãªä½¿ç¨é㯠71MBå¼±
- ab å®è¡æ㯠CPU 160%åå¾ãã¡ã¢ãª 150MBãããã¾ã§çã ã¨ä¸æ
- ab å®è¡å¾ã®ã¡ã¢ãªã¯ 154MB
% jruby -S jetty_rails -e production JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL 2009-01-27 18:54:19.927::INFO: Logging to STDERR via org.mortbay.log.StdErrLog Starting server 3000 2009-01-27 18:54:20.124::INFO: jetty-6.1.14 2009-01-27 18:54:20.886:/:INFO: Info: using runtime pool timeout of 30 seconds 2009-01-27 18:54:20.886:/:INFO: Info: received min runtimes = 1 2009-01-27 18:54:20.886:/:INFO: Info: received max runtimes = 5 JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL 2009-01-27 18:54:26.04:/:INFO: Info: add application to the pool. size now = 1 2009-01-27 18:54:26.072::INFO: Started [email protected]:3000
-
- èµ·åæã®ã¡ã¢ãªä½¿ç¨é㯠105MB
- ab å®è¡æ㯠CPU 160%åå¾ãã¡ã¢ãª 320MBãããã¾ã§çã ã¨ä¸æ
- ab å®è¡å¾ã®ã¡ã¢ãªã¯ 322MB
% $GLASSFISH_HOME/bin/asadmin start-domain % jruby -S warble cp config/environment.rb tmp/war/WEB-INF/config/environment.rb cp config/environments/production.rb tmp/war/WEB-INF/config/environments/production.rb mkdir -p tmp/war/WEB-INF % $GLASSFISH_HOME/bin/asadmin deploy hoge.war ã³ãã³ã deploy ã¯æ£å¸¸ã«å®è¡ããã¾ããã % $GLASSFISH_HOME/bin/asadmin stop-domain
-
- glassfish èµ·åæã§ã76MB
- war ãã¡ã¤ã«ã® deploy å¾ã§ã220MB
- ab å®è¡æ㯠CPU 180%åå¾ãã¡ã¢ãª 360MBãããã¾ã§çã ã¨ä¸æ
- ab å®è¡å¾ã®ã¡ã¢ãªã¯ 364MB
- glassfish ãèµ·åããã¾ã¾ã2åç®ã® ab ããããã¨åãããã®æ§è½
- çµæã¨ãã¦è¼ãã¦ããã®ã¯ã3åç®ã®ãã®
- ab ãç¹°ãè¿ãããã¦ããã¨ãã¡ã¢ãªä½¿ç¨éã¯ä¸æãæ§è½ãã§ãªããªã£ã¦ãã...
-
- (追è¨: 2009-01-28)
- ãã®çµã¿åããã®ãã¨ã§ããã£ãã ab ãç¹°ãè¿ãããã¦ã¿ã
Requests per second: 138.82 [#/sec] (mean) # 1åç® (使ç¨ã¡ã¢ãª 368MB ã«å°é) Requests per second: 308.44 [#/sec] (mean) # 2åç® (使ç¨ã¡ã¢ãª 444MB ã«å°é) Requests per second: 331.52 [#/sec] (mean) # 3åç® (使ç¨ã¡ã¢ãª 466MB ã«å°é) Requests per second: 206.12 [#/sec] (mean) # 4åç® (使ç¨ã¡ã¢ãª 518MB ã«å°é) Requests per second: 187.02 [#/sec] (mean) # 5åç® (使ç¨ã¡ã¢ãª 550MB ã«å°é) Requests per second: 178.27 [#/sec] (mean) # 6åç® (使ç¨ã¡ã¢ãª 579MB ã«å°é) Requests per second: 166.90 [#/sec] (mean) # 7åç® (使ç¨ã¡ã¢ãª 610MB ã«å°é) Requests per second: 123.10 [#/sec] (mean) # 8åç® (使ç¨ã¡ã¢ãª 629MB ã«å°é) Requests per second: 72.44 [#/sec] (mean) # 9åç® (使ç¨ã¡ã¢ãª 629MB ã®ã¾ã¾) Requests per second: 58.24 [#/sec] (mean) # 10åç® (使ç¨ã¡ã¢ãª 629MB ã®ã¾ã¾)
-
- ã¡ã¢ãªä½¿ç¨ã®å¢å ã«ã¨ããªã£ã¦å£å
- 空ãã¡ã¢ãªã¯ãã£ããã©ãjava ããã»ã¹ã®ã¡ã¢ãªã¯é æã¡ã«ãªã£ã
- ããã©ã«ãã 㨠-Xmx 512m ã«ãªã£ã¦ãããããª?
- jruby + glassfish-v3-p**
- config/environments/production.rb ãæ¸ãæ¿ããã®ã¡ãä¸è¨ã¨åã
- ab ãä½åº¦ãããã¦ãã£ãçµæ
Requests per second: 151.28 [#/sec] (mean) # 1åç® Requests per second: 228.21 [#/sec] (mean) # 2åç® Requests per second: 240.05 [#/sec] (mean) # 3åç® Requests per second: 181.32 [#/sec] (mean) # 4åç® Requests per second: 155.52 [#/sec] (mean) # 5åç® Requests per second: 145.33 [#/sec] (mean) # 6åç® (使ç¨ã¡ã¢ãªã¯600MBããã)
(追è¨: 2009-01-28)
% java -Xmx256m -jar glassfish-installer-v2.1-b60e-darwin-ml.jar % cd glassfish % chmod -R +x lib/ant/bin % lib/ant/bin/ant -f setup.xml % bin/asadmin version ãã¼ã¸ã§ã³ = Sun GlassFish Enterprise Server v2.1 % bin/asadmin start-domain % $GLASSFISH_HOME_v21/bin/asadmin deploy hoge.war ã³ãã³ã deploy ã¯æ£å¸¸ã«å®è¡ããã¾ããã
-
- èµ·å & é åå¾ã®ã¡ã¢ãªã¯ 260MB
- ab ãä½åº¦ãããã¦ãã£ãçµæ
Requests per second: 309.77 [#/sec] (mean) # 1åç® (使ç¨ã¡ã¢ãª 304MB ã«å°é) Requests per second: 361.46 [#/sec] (mean) # 2åç® (使ç¨ã¡ã¢ãª 343MB ã«å°é) Requests per second: 373.67 [#/sec] (mean) # 3åç® (使ç¨ã¡ã¢ãª 355MB ã«å°é) Requests per second: 369.09 [#/sec] (mean) # 4åç® (使ç¨ã¡ã¢ãª 373MB ã«å°é) Requests per second: 370.19 [#/sec] (mean) # 5åç® (使ç¨ã¡ã¢ãª 391MB ã«å°é) Requests per second: 362.62 [#/sec] (mean) # 6åç® (使ç¨ã¡ã¢ãª 416MB ã«å°é) Requests per second: 371.15 [#/sec] (mean) # 7åç® (使ç¨ã¡ã¢ãª 417MB ã«å°é) Requests per second: 372.59 [#/sec] (mean) # 8åç® (使ç¨ã¡ã¢ãª 432MB ã«å°é) Requests per second: 369.12 [#/sec] (mean) # 8åç® (使ç¨ã¡ã¢ãª 447MB ã«å°é) Requests per second: 371.53 [#/sec] (mean) # 10åç® (使ç¨ã¡ã¢ãª 464MB ã«å°é) Requests per second: 346.91 [#/sec] (mean) # 11åç® (使ç¨ã¡ã¢ãª 502MB ã«å°é) Requests per second: 370.91 [#/sec] (mean) # 12åç® (使ç¨ã¡ã¢ãª 502MB ã«å°é) Requests per second: 373.10 [#/sec] (mean) # 13åç® (使ç¨ã¡ã¢ãª 502MB ã«å°é) Requests per second: 372.93 [#/sec] (mean) # 14åç® (使ç¨ã¡ã¢ãª 514MB ã«å°é) Requests per second: 373.43 [#/sec] (mean) # 15åç® (使ç¨ã¡ã¢ãª 526MB ã«å°é) Requests per second: 356.92 [#/sec] (mean) # 16åç® (使ç¨ã¡ã¢ãª 551MB ã«å°é) Requests per second: 365.73 [#/sec] (mean) # 17åç® (使ç¨ã¡ã¢ãª 551MB ã«å°é) Requests per second: 265.37 [#/sec] (mean) # 18åç® (使ç¨ã¡ã¢ãª 568MB ã«å°é) Requests per second: 249.14 [#/sec] (mean) # 19åç® (使ç¨ã¡ã¢ãª 568MB ã«å°é) Requests per second: 219.37 [#/sec] (mean) # 20åç® (使ç¨ã¡ã¢ãª 570MB ã«å°é)
-
- % ab -c 10 -n 10000 ... ã§å®è¡ããã®ã§ãæç¶çã« 20ä¸ãªã¯ã¨ã¹ã
- glassfish-v3-prelude ã¨æ¯è¼ããã¨ãããã«å®å®
- 空ãã¡ã¢ãªããªããªã£ã¦ããé åãã§é æã¡?
- ã¹ã«ã¼ãããçã«ã¯ãCRuby + Mongrel ãããããçµæ (ç´2å²å¢)