JRuby on Rails

6,872 views
6,761 views

Published on

Por que roda Ruby sobre a Máquina Virtual Java?

O que ganhamos rodando aplicações Rails em cima da máquina virtual Java?

Published in: Technology
0 Comments
8 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
6,872
On SlideShare
0
From Embeds
0
Number of Embeds
962
Actions
Shares
0
Downloads
53
Comments
0
Likes
8
Embeds 0
No embeds

No notes for slide


  • silver bullet
    escolher uma




  • 2004, 2005, 2006, ...
  • xml, html, css, js
    ferramenta certa, hora certa
  • fragmentação
    stop-the-world
  • fragmentação
    stop-the-world
  • fragmentação
    stop-the-world
  • fragmentação
    stop-the-world
  • fragmentação
    stop-the-world
  • fragmentação
    stop-the-world
  • fragmentação
    stop-the-world
  • fragmentação
    stop-the-world
  • fragmentação
    stop-the-world
  • produtividade
    aposta
    fun
  • + rápido
    compactação
    adaptatividade
  • + rápido
    compactação
    adaptatividade
  • + rápido
    compactação
    adaptatividade
  • + rápido
    compactação
    adaptatividade
  • + rápido
    compactação
    adaptatividade
  • + rápido
    compactação
    adaptatividade
  • + rápido
    compactação
    adaptatividade
  • + rápido
    compactação
    adaptatividade
  • + rápido
    compactação
    adaptatividade
  • + rápido
    compactação
    adaptatividade


  • funcionalidades
  • jruby é o + rápido










  • CGI: processo por request
    FCGI: pool
  • CGI: processo por request
    FCGI: pool
  • CGI: processo por request
    FCGI: pool
  • CGI: processo por request
    FCGI: pool
  • CGI: processo por request
    FCGI: pool
  • CGI: processo por request
    FCGI: pool
  • http
    share-nothing
    mongrel per request
    30Mb-80Mb


  • http
    share-nothing
    mongrel per request
    30Mb-80Mb


  • http
    share-nothing
    mongrel per request
    30Mb-80Mb


  • http
    share-nothing
    mongrel per request
    30Mb-80Mb


  • http
    share-nothing
    mongrel per request
    30Mb-80Mb


  • http
    share-nothing
    mongrel per request
    30Mb-80Mb


  • concorrencia desde 97
    share nothing?
    cache, session, jndi
    distribuido vai para terracotta, jboss tree, memcached


  • concorrencia desde 97
    share nothing?
    cache, session, jndi
    distribuido vai para terracotta, jboss tree, memcached


  • concorrencia desde 97
    share nothing?
    cache, session, jndi
    distribuido vai para terracotta, jboss tree, memcached


  • concorrencia desde 97
    share nothing?
    cache, session, jndi
    distribuido vai para terracotta, jboss tree, memcached


  • concorrencia desde 97
    share nothing?
    cache, session, jndi
    distribuido vai para terracotta, jboss tree, memcached


  • concorrencia desde 97
    share nothing?
    cache, session, jndi
    distribuido vai para terracotta, jboss tree, memcached


  • concorrencia desde 97
    share nothing?
    cache, session, jndi
    distribuido vai para terracotta, jboss tree, memcached


  • concorrencia desde 97
    share nothing?
    cache, session, jndi
    distribuido vai para terracotta, jboss tree, memcached


  • concorrencia desde 97
    share nothing?
    cache, session, jndi
    distribuido vai para terracotta, jboss tree, memcached


  • concorrencia desde 97
    share nothing?
    cache, session, jndi
    distribuido vai para terracotta, jboss tree, memcached


  • protocolo leve
    filter
    desacopla o fw web
    rails requer bastante memória














  • sem feedback instantâneo
  • glassfish_gem


  • JRuby on Rails

    1. 1. JRuby on Rails fabio.kung@caelum.com.br Monday, March 2, 2009
    2. 2. http://www.robert-tolksdorf.de/vmlanguages.html Monday, March 2, 2009
    3. 3. DSLs Monday, March 2, 2009
    4. 4. DSLs Externa Interna (host) Monday, March 2, 2009
    5. 5. HAPPY INTERNATIONAL INVOKEDYNAMIC DAY JSR-292 http://openjdk.java.net/projects/mlvm/ Monday, March 2, 2009
    6. 6. Monday, March 2, 2009
    7. 7. Mas e por que Java? “por que?” Monday, March 2, 2009
    8. 8. Memória Heap objeto objeto objeto objeto objeto objeto objeto Monday, March 2, 2009
    9. 9. Memória Heap objeto objeto objeto objeto objeto objeto objeto Monday, March 2, 2009
    10. 10. Memória Heap objeto objeto objeto objeto objeto objeto objeto Monday, March 2, 2009
    11. 11. Memória Heap objeto objeto objeto objeto objeto objeto objeto Monday, March 2, 2009
    12. 12. Memória Heap objeto objeto objeto objeto objeto objeto objeto Monday, March 2, 2009
    13. 13. 95% dos objetos tem vida curta Monday, March 2, 2009
    14. 14. Mortalidade Infantil Memória Heap Eden Tenured Monday, March 2, 2009
    15. 15. Mortalidade Infantil Memória Heap Eden Tenured Monday, March 2, 2009
    16. 16. Mortalidade Infantil Memória Heap Eden Tenured objeto objeto objeto objeto Monday, March 2, 2009
    17. 17. Mortalidade Infantil Memória Heap Eden Tenured objeto objeto objeto objeto Monday, March 2, 2009
    18. 18. Mortalidade Infantil Memória Heap Eden Tenured objeto objeto objeto objeto Monday, March 2, 2009
    19. 19. Flexibilidade • Serial • ParNew • Parallel Scavenge • Serial Old • CMS • Parallel Old • G1 http://blogs.sun.com/jonthecollector/entry/our_collectors Monday, March 2, 2009
    20. 20. Ea performance? Monday, March 2, 2009
    21. 21. http://headius.blogspot.com/2008/02/jruby-rc2-released-whats-next.html JRuby's performance regularly exceeds Ruby 1.8.6, and in many cases has started to exceed Ruby 1.9 http://www.flickr.com/photos/diathesis/2115578333/ Monday, March 2, 2009
    22. 22. JIT Compiler Monday, March 2, 2009
    23. 23. Startup • -X:bootclasspath • Nailgun: http://www.martiansoftware.com/nailgun/ Monday, March 2, 2009
    24. 24. Startup • -X:bootclasspath • Nailgun: http://www.martiansoftware.com/nailgun/ Nailgun tcp/ip Client Nailgun tcp/ip JVM Server Client Nailgun tcp/ip Client Monday, March 2, 2009
    25. 25. Rails não escala! Monday, March 2, 2009
    26. 26. http://www.akitaonrails.com/2008/4/19/di-rio-de-bordo-do-fisl-9 Sim! Rails escala! http://picasaweb.google.com/leo.torres84/FISL2008 Monday, March 2, 2009
    27. 27. Ruby on Rails http WebServer Rails CGI “como?” Monday, March 2, 2009
    28. 28. Ruby on Rails Rails CGI http WebServer Rails CGI CGI Rails “como?” Monday, March 2, 2009
    29. 29. Ruby on Rails Proxy Reverso Mongrel http / http Rails Load Balancer Monday, March 2, 2009
    30. 30. Ruby on Rails Mongrel http Rails Proxy Reverso Mongrel http / http Rails Load Balancer Mongrel http Rails Monday, March 2, 2009
    31. 31. JRuby on Rails container http Servlet Monday, March 2, 2009
    32. 32. JRuby on Rails container Thread Thread Thread http Servlet Thread Thread Monday, March 2, 2009
    33. 33. JRuby on Rails container Thread Thread Rails Thread http Servlet (JRuby) Thread Thread Monday, March 2, 2009
    34. 34. JRuby on Rails container Rails Thread (JRuby) Thread Rails Thread http Servlet (JRuby) Thread Rails Thread (JRuby) Monday, March 2, 2009
    35. 35. JRuby on Rails container Rails Thread (JRuby) Thread Goldspike Rails Thread http Servlet (JRuby) http://wiki.jruby.org/wiki/Goldspike Thread Rails Thread (JRuby) Monday, March 2, 2009
    36. 36. JRuby Rack Rails Thread rack (JRuby) Thread Filter Rails Thread http Servlet rack JRuby (JRuby) Rack Thread Rails Thread rack (JRuby) Monday, March 2, 2009
    37. 37. JRuby Rack Rails Thread rack (JRuby) Thread Merb? Filter Rails Thread http Servlet rack JRuby (JRuby) Rack http://merbivore.com/ Thread Rails Thread rack (JRuby) Monday, March 2, 2009
    38. 38. I agree, the memory situation is not the best but compared to MRI, JRuby deployments are actually favorable. We're seeing around 20MB per runtime in our deployment, ... http://www.flickr.com/photos/nicksieger Monday, March 2, 2009
    39. 39. Rails 2.2 is thread-safe! http://joshpeek.com/ Monday, March 2, 2009
    40. 40. -server -Xmx1024m httperf --num-conns 100 --rate 10 class HomeController < ApplicationController def index render :text => quot;<html>fibonnaci(29) = #{fibonacci(29)}</html>quot; end private def fibonacci(number) return number if number < 2 fibonacci(number - 1) + fibonacci(number - 2) end end Monday, March 2, 2009
    41. 41. Tomcat 1 runtime, thread-safe: 176 MB 3 runtimes: 200 MB 5 runtimes: 244 MB Jetty 1 runtime, thread-safe: 193 MB 3 runtimes: 204 MB 5 runtimes: 245 MB Glassfish 1 runtime, thread-safe: 315 MB 3 runtimes: 370 MB 5 runtimes: 417 MB Monday, March 2, 2009
    42. 42. jruby -S gem install mongrel cd railsapp jruby script/server Glassfish v3 (gem) http://wiki.jruby.org/wiki/JRuby_on_Rails_in_GlassFish jruby -S gem install glassfish jruby -S glassfish Monday, March 2, 2009
    43. 43. Warbler http://wiki.jruby.org/wiki/Warbler jruby -S gem install warbler cd railsapp jruby -S warble Monday, March 2, 2009
    44. 44. Monday, March 2, 2009
    45. 45. jruby -S gem install jetty-rails cd railsapp jruby -S jetty_rails http://jetty-rails.rubyforge.org/ Monday, March 2, 2009
    46. 46. Eu ouvi dizer que Jruby é lento! Monday, March 2, 2009
    47. 47. Monday, March 2, 2009
    48. 48. httperf --num-conns 2500 --rate 25 guj2: ~20 resp/s Monday, March 2, 2009
    49. 49. httperf --num-conns 8000 --rate 140 Monday, March 2, 2009
    50. 50. httperf --num-conns 8000 --rate 140 guj3: ~140 resp/s vs 20 resp/s Monday, March 2, 2009
    51. 51. “como?” Monday, March 2, 2009
    52. 52. Cache! Monday, March 2, 2009
    53. 53. Cache! container Rails (JRuby) Servlet Context fragmento fragmento Rails fragmento fragmento (JRuby) fragmento fragmento fragmento fragmento Rails (JRuby) Monday, March 2, 2009
    54. 54. Conexões ao banco Monday, March 2, 2009
    55. 55. Mongrel http Rails Mongrel http Rails Proxy Reverso Mongrel / http Rails Load Balancer Mongrel http Rails Mongrel http Rails Monday, March 2, 2009
    56. 56. Mongrel http Rails Mongrel http Rails Proxy Reverso Mongrel / http Rails Pool? Load Balancer Mongrel http Rails Mongrel http Rails Monday, March 2, 2009
    57. 57. JRuby Connection Pool Runtime JRuby Runtime JDBC JRuby JRuby Rack Adapter Runtime Filter (jndi) JRuby Runtime JRuby Runtime Monday, March 2, 2009
    58. 58. “” Não importa a tecnologia, Monday, March 2, 2009
    59. 59. “” Não importa a tecnologia, desde que você a conheça muito bem! Monday, March 2, 2009
    60. 60. + Monday, March 2, 2009
    61. 61. http://code.google.com/p/activehibernate/ class Person include Hibernate primary_key_accessor :id, :long h_component :address, [[:street,:string], [:city,:string]] end Monday, March 2, 2009
    62. 62. No. Ribs! class Blog Ribs! :table => :fox_blog do |r| r.id.primary_key! r.title :column => :blog_title r.body :column => :content_text r.something.avoid! end end Monday, March 2, 2009
    63. 63. Spring <beans xmlns=quot;...quot;> <lang:jruby id=quot;messageServicequot; script-interfaces=quot;br.com.caelum.Messengerquot; script-source=quot;classpath:ruby_messenger.rbquot;> <lang:property name=quot;messagequot; value=quot;Hello World!quot;/> </lang:jruby> <bean id=quot;businessLogicquot; class=quot;br.com.caelum.Logicquot;> <constructor-arg ref=quot;messageServicequot; /> </bean> </beans> Monday, March 2, 2009
    64. 64. MagLev Monday, March 2, 2009
    65. 65. (J)MagLev Monday, March 2, 2009
    66. 66. Dúvidas? Obrigado! fabio.kung@caelum.com.br Monday, March 2, 2009

    ×