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.
Presentation Transcript
- Slide 1: JRuby on Rails and Thread Safety Naoto Takai Akasaka.rb / Itochu Techno-Solutions Corp. 29 November 2008
- Slide 2: ‣ JRuby on Rails and Thread Safety ‣ ActiveRecord and Connection Pooling ‣ JNDI and Connection Pooling
- Slide 3: ‣ JRuby on Rails and Thread Safety ‣ ActiveRecord and Connection Pooling ‣ JNDI and Connection Pooling
- Slide 4: Ruby on Rails 2.2 Release Notes
- Slide 5: Ruby on Rails 2.1 or Prior Ruby Process Rails Instance Ruby Process Rails Database Instance Ruby Process Rails Instance
- Slide 6: JRuby on Rails 2.1 or Prior Thread JRuby Rails Instance Thread JRuby Rails Database Instance Thread JRuby Rails Instance Thread
- Slide 7: One JRuby Instance, One Database Connection JRuby Thread Rails Database Instance
- 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
- Slide 9: One JRuby Instance, Many Database Connections Thread JRuby Rails Database Instance Thread You need less JRuby instances per database connections.
- Slide 10: ‣ JRuby on Rails and Thread Safety ‣ ActiveRecord and Connection Pooling ‣ JNDI and Connection Pooling
- Slide 11: ActiveRecord Connection Pool ActiveRecord::Base.establish_connection( :adapter => \"mysql\", :username => \"root\", :database => \"database\", :pool => 5 )
- 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
- Slide 13: ActiveRecord Connection Pooling (1) Check-out Connect Connection ActiveRecord Database Pool Connection
- Slide 14: ActiveRecord Connection Pooling (2) Check-out Connection ActiveRecord Database Pool Connection
- Slide 15: ActiveRecord Connection Pooling (3) Wait Check-out Connection ActiveRecord Database Pool Connection Check-out Check-in ActiveRecord
- Slide 16: ‣ JRuby on Rails and Thread Safety ‣ ActiveRecord and Connection Pooling ‣ JNDI and Connection Pooling
- Slide 17: ‣ JNDI (Java Naming and Directory Service) ‣ Binding a name to an object. ‣ Look-up the object by name.
- Slide 18: Using JNDI Look-up ActiveRecord::Base.establish_connection( :adapter => \"jdbc\", :jndi => \"jdbc/MySQL\", :driver => \"com.mysql.jdbc.Driver\", :pool => 5 )
- Slide 19: JNDI Look-up Look-up Reference Connection Client Database Pool Data Source
- 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



SlideShare brings the cloud to PowerPoint and your desktop...