Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Concurrency in Ruby

Concurrency in Ruby

Presented at Burlington RubyConf 2014

Avatar for Doug Alcorn

Doug Alcorn

August 03, 2014
Tweet

Other Decks in Technology

Transcript

  1. Celluloid Actor-based concurrent objects for Ruby “Each actor is a

    concurrent object running in its own thread, and every method invocation is wrapped in a fiber that can be suspended whenever it calls out to other actors, and resumed when the response is available.”
  2. ActiveRecord is Thread Safe Just use AR calls as normal

    Eventually, when you're done with the connection(s) and wish it to be returned to the pool, you call ActiveRecord::Base.clear_active_connections!
  3. ActiveRecord is Thread Safe Manually check out a connection You

    are responsible for returning this connection to the pool.
  4. Conclusions • Concurrency is not parallelism • Learning concurrency patterns

    from Go was a big help • Celluloid gives us a good tool to model concurrency with OO design
  5. Conclusions • Concurrency is not parallelism • Learning concurrency patterns

    from Go was a big help • Celluloid gives us a good tool to model concurrency with OO design • JRuby can give us true parallelism
  6. Conclusions • Concurrency is not parallelism • Learning concurrency patterns

    from Go was a big help • Celluloid gives us a good tool to model concurrency with OO design • JRuby can give us true parallelism • “It all depends”
  7. Conclusions • Concurrency is not parallelism • Learning concurrency patterns

    from Go was a big help • Celluloid gives us a good tool to model concurrency with OO design • JRuby can give us true parallelism • “It all depends” • Don’t use node