Skip to content
This repository has been archived by the owner on Jul 22, 2018. It is now read-only.

Scaling Ruby with Actors

Benjamin Oakes edited this page Oct 1, 2011 · 4 revisions

Synopsis

The last two years have been a personal tour of EventMachine, Fibers and Threads for me as I've toured the ecosystem looking for a developer-friendly, efficient solution for scaling Ruby. Historically Threads have performed poorly in Ruby but guess what? - recent events may change your mind. Now would be a good time to give them a second chance.

Goal

Share | Shared Mem| Variables
      | Files     |          
------|-----------|-----------
Copy  | Pipes     | ???
      | Sockets   |    
------|-----------|-----------
      | Processes | Threads

What goes in the "???" box?

Goroutines

  • Go has "Goroutines"
  • Maps well to distributed model
  • Maps to a pool of threads

Actors

  • In Erlang and Scala, it's primary
  • Has a mailbox -- you send it a mesage
  • Thread- or Fiber-backed
  • No locks

Actor.rb

  • Comes with Rubinius
  • Works on MRI and JRuby
  • Ping pong example
  • "Hard to understand, use correctly"

Celluloid

girl_friday

  • The presenter's
  • ...actually seems a lot like Thread.new { ... }

Solutions for concurrency

STM

  • Software Transactional Memory
  • Mutation via transactions
  • Clojure (and Cloby) uses it
  • Does the "ACI" of ACID

Atomics

  • From Java
  • java.util.concurrent
    • ConcurrentHashMap
    • ConcurrentLinkedQueue

TODOs

  • Standard actor API
  • Concurrent data scrutctures
  • STM implementations for Ruby

To see

  • Kilim
  • Disruptor
  • Actors in Scala/Concurrency in Erlang
  • Java Concurrency in Practice book

A crowd-sourced conference wiki!
Working together is better. :)




Clone this wiki locally