So what do we have in hand?
●
Threads – The Java hangover
●
Fibers – Red headed cousin of threads
●
Actors – Stylish but effective
●
Reactor – He will do all the work...
●
Dataflow – The forgotten one..
●
STM – Remember ATM
●
The Nirvana
Slide 7
Slide 7 text
A folk definition of insanity is to do the
same thing over and over again and to
expect the results to be different. By this
definition, we in fact require that
programmers of multithreaded systems
be insane
- The Problem with Threads
Edward Lee
Slide 8
Slide 8 text
Threading in Ruby
Concurrency is a myth Ruby -
@igvita
Slide 9
Slide 9 text
No content
Slide 10
Slide 10 text
Fibers
●
New kid in the block from Ruby 1.9
●
Green threads with cooperatively
scheduler
●
Can give up CPU control to other fiber
when needed.
●
Based on Coroutines – Like python
generators but can yield to other
coroutines
●
Think NeverBlock...
Slide 11
Slide 11 text
Nginx vs Apache Death Match
Slide 12
Slide 12 text
EventMachine – Reactor
Pattern
Slide 13
Slide 13 text
EventMachine
●
Based on python Twisted
●
Reactor sits in the middle
●
IOC pattern – Not many get used to it
●
Defer long running process
●
Support for lot of protocols and very
active development
●
Try my em-couchdb :)
(http://github.com/saivenkat/em-
couchdb)
Slide 14
Slide 14 text
Actors -Stylishly passing
messages
Slide 15
Slide 15 text
Actors
●
Message passing concurrency
●
No first class support in Ruby
●
Revactor is good but we had problems
with it
●
If Jruby, lots of Java Actor framework
available like Jetlang.
●
Jruby + Jetlang - http://bit.ly/ahXh6j
Slide 16
Slide 16 text
Transactions – We are safe
Slide 17
Slide 17 text
Software Transactional
Memory
●
Similar to database transactions but
inmemory (ACID
XX
)
●
Unfortunately again no first class
support
●
STM library by MentalGuy -
http://bit.ly/c7Mxah
●
In Jruby harness clojure's infrastructure
– Ruby objects as refs.
http://bit.ly/d6vpuP
Slide 18
Slide 18 text
Multi Process
Slide 19
Slide 19 text
Coordination
Slide 20
Slide 20 text
Coordination
●
How do we coordinate independent
units of execution?
●
Dataflow – Forgotten paradigm
●
Other methods – May be a big heavy
weight suitable when multi processing
●
Tuplespace, Queues (RabbitMq or
beanstalk)
Slide 21
Slide 21 text
Nirvana
Slide 22
Slide 22 text
Nirvana
●
Polyglotism – Let the languages which
excel in concurrency do the job
●
Make Ruby talk with Clojure, Erlang,
Haskell, node.js...
●
Lots of ways. VM level support, external
infrastructure.
Slide 23
Slide 23 text
Sai Venkat
github.com/saivenkat
@sai_venkat
http://developer-in-test.blogspot.com
HariKrishnan
github.com/harikrishnan83
@harikrishnan83
http://harikrishnan83.wordpress.com
Slide 24
Slide 24 text
All images used are attributed to the
awesome guys who took them..
Please don't sue us :D