Quick Upload

JRuby on Rails and Thread Safety

from Naoto.Takai, 1 month ago Add as contact

642 views | 0 comments | 3 favorites | 2 embeds (Stats)

Embed customize close
 

More Info

This slideshow is Public

Views: 642 Comments: 0 Favorites: 3 Downloads: 21

View Details: 530 on Slideshare
112 from embeds
Most viewed embeds (Top 5): (…more)
All Embeds: (less)
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this slideshow as inappropriate.

If needed, use the feedback form to let us know more details.

Loading...
Flash Player 9 (or above) is needed to view slideshows. We have detected that you do not have it on your computer. To install it, go here.
Post to Twitter Post to Twitter
Share on Facebook Share on Facebook
Post to Blogger Post to Blogger
Myspace Hi5 Friendster Xanga LiveJournal Facebook Blogger Tagged Typepad Freewebs BlackPlanet gigya icons

Presentation Transcript

  1. Slide 1: JRuby on Rails and Thread Safety Naoto Takai Akasaka.rb / Itochu Techno-Solutions Corp. 29 November 2008
  2. Slide 2: ‣ JRuby on Rails and Thread Safety ‣ ActiveRecord and Connection Pooling ‣ JNDI and Connection Pooling
  3. Slide 3: ‣ JRuby on Rails and Thread Safety ‣ ActiveRecord and Connection Pooling ‣ JNDI and Connection Pooling
  4. Slide 4: Ruby on Rails 2.2 Release Notes
  5. Slide 5: Ruby on Rails 2.1 or Prior Ruby Process Rails Instance Ruby Process Rails Database Instance Ruby Process Rails Instance
  6. Slide 6: JRuby on Rails 2.1 or Prior Thread JRuby Rails Instance Thread JRuby Rails Database Instance Thread JRuby Rails Instance Thread
  7. Slide 7: One JRuby Instance, One Database Connection JRuby Thread Rails Database Instance
  8. Slide 8: JRuby on Rails 2.2 or Later Thread JRuby Rails Instance Thread JRuby Connection Rails Database Instance Pool Thread JRuby Rails Instance Thread
  9. Slide 9: One JRuby Instance, Many Database Connections Thread JRuby Rails Database Instance Thread You need less JRuby instances per database connections.
  10. Slide 10: ‣ JRuby on Rails and Thread Safety ‣ ActiveRecord and Connection Pooling ‣ JNDI and Connection Pooling
  11. Slide 11: ActiveRecord Connection Pool ActiveRecord::Base.establish_connection( :adapter => \"mysql\", :username => \"root\", :database => \"database\", :pool => 5 )
  12. Slide 12: Demo Code 10.times do Thread.new do ActiveRecord::Base.connection_pool \\ .with_connection do |c| ret = c.execute(\"select connection_id()\") puts \"Connection ID: %s\" % ret.fetch_row end end end
  13. Slide 13: ActiveRecord Connection Pooling (1) Check-out Connect Connection ActiveRecord Database Pool Connection
  14. Slide 14: ActiveRecord Connection Pooling (2) Check-out Connection ActiveRecord Database Pool Connection
  15. Slide 15: ActiveRecord Connection Pooling (3) Wait Check-out Connection ActiveRecord Database Pool Connection Check-out Check-in ActiveRecord
  16. Slide 16: ‣ JRuby on Rails and Thread Safety ‣ ActiveRecord and Connection Pooling ‣ JNDI and Connection Pooling
  17. Slide 17: ‣ JNDI (Java Naming and Directory Service) ‣ Binding a name to an object. ‣ Look-up the object by name.
  18. Slide 18: Using JNDI Look-up ActiveRecord::Base.establish_connection( :adapter => \"jdbc\", :jndi => \"jdbc/MySQL\", :driver => \"com.mysql.jdbc.Driver\", :pool => 5 )
  19. Slide 19: JNDI Look-up Look-up Reference Connection Client Database Pool Data Source
  20. Slide 20: Java EE Application Server Connection Pooling Connect or Check-out Reconnect ActiveRecord App Server ActiveRecord Connection Connection Pool Pool Connection Connection Check-in Disconnect Database