• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
JRuby on Rails and Thread Safety
 

JRuby on Rails and Thread Safety

on

  • 8,015 views

 

Statistics

Views

Total Views
8,015
Views on SlideShare
7,781
Embed Views
234

Actions

Likes
7
Downloads
60
Comments
0

9 Embeds 234

http://recompile.net 193
http://www.slideshare.net 26
http://teamco-anthill.blogspot.com 5
http://teamco-anthill.blogspot.com 5
http://webcache.googleusercontent.com 1
http://feeds.feedburner.jp 1
http://blog.livedoor.jp 1
http://web.archive.org 1
http://takai.blog.jp 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    JRuby on Rails and Thread Safety JRuby on Rails and Thread Safety Presentation Transcript

    • JRuby on Rails and Thread Safety Naoto Takai Akasaka.rb / Itochu Techno-Solutions Corp. 29 November 2008
    • ‣ JRuby on Rails and Thread Safety ‣ ActiveRecord and Connection Pooling ‣ JNDI and Connection Pooling
    • ‣ JRuby on Rails and Thread Safety ‣ ActiveRecord and Connection Pooling ‣ JNDI and Connection Pooling
    • Ruby on Rails 2.2 Release Notes
    • Ruby on Rails 2.1 or Prior Ruby Process Rails Instance Ruby Process Rails Database Instance Ruby Process Rails Instance
    • JRuby on Rails 2.1 or Prior Thread JRuby Rails Instance Thread JRuby Rails Database Instance Thread JRuby Rails Instance Thread
    • One JRuby Instance, One Database Connection JRuby Thread Rails Database Instance
    • JRuby on Rails 2.2 or Later Thread JRuby Rails Instance Thread JRuby Connection Rails Database Instance Pool Thread JRuby Rails Instance Thread
    • One JRuby Instance, Many Database Connections Thread JRuby Rails Database Instance Thread You need less JRuby instances per database connections.
    • ‣ JRuby on Rails and Thread Safety ‣ ActiveRecord and Connection Pooling ‣ JNDI and Connection Pooling
    • ActiveRecord Connection Pool ActiveRecord::Base.establish_connection( :adapter => quot;mysqlquot;, :username => quot;rootquot;, :database => quot;databasequot;, :pool => 5 )
    • Demo Code 10.times do Thread.new do ActiveRecord::Base.connection_pool .with_connection do |c| ret = c.execute(quot;select connection_id()quot;) puts quot;Connection ID: %squot; % ret.fetch_row end end end
    • ActiveRecord Connection Pooling (1) Check-out Connect Connection ActiveRecord Database Pool Connection
    • ActiveRecord Connection Pooling (2) Check-out Connection ActiveRecord Database Pool Connection
    • ActiveRecord Connection Pooling (3) Wait Check-out Connection ActiveRecord Database Pool Connection Check-out Check-in ActiveRecord
    • ‣ JRuby on Rails and Thread Safety ‣ ActiveRecord and Connection Pooling ‣ JNDI and Connection Pooling
    • ‣ JNDI (Java Naming and Directory Service) ‣ Binding a name to an object. ‣ Look-up the object by name.
    • Using JNDI Look-up ActiveRecord::Base.establish_connection( :adapter => quot;jdbcquot;, :jndi => quot;jdbc/MySQLquot;, :driver => quot;com.mysql.jdbc.Driverquot;, :pool => 5 )
    • JNDI Look-up Look-up Reference Connection Client Database Pool Data Source
    • 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