Professional Documents
Culture Documents
with EventMachine
Mike Perham
And you are...?
Developer at OneSpot
memcache-client maintainer
data_fabric author
Scalable Processing?
Map/Reduce (Hadoop)
Message Queues
Efficient Processing!
Your code will spend 90% waiting for IO, 10% doing
actual work
Blocking
What if we could...
Have Ruby work on one operation while another
waited on I/O?
Fill in the green gaps?
Without threads?
Evented IO rules
a concurrent programming pattern
EventMachine
for handling service requests
delivered concurrently to a service
handler by one or more inputs. The
service handler then demultiplexes
the incoming requests and
dispatches them synchronously to
the associated request handlers.
Difficult to understand
Little, poor documentation
Learning curve for newbies
Testing
Blocking IO is everywhere
Easy to lose parallelism
Code
Evented
Threading sucks
Blocking IO is everywhere
Use EM for IO to peg a single core
Use multiple processes for multi-core
Ruby 1.9 makes evented code nicer
Thank you!
Questions?
@mperham
mperham@gmail.com