Paradigms of Concurrency
Why is this important?
Or for geeks to relate...
Without right abstractions...
So what do we have in hand?
●   Threads – The Java hangover
●   Fibers – Red headed cousin of threads
●   Actors – Stylish...
A folk definition of insanity is to do the
same thing over and over again and to
expect the results to be different. By th...
Threading in Ruby




Concurrency is a myth Ruby -
          @igvita
Fibers
●   New kid in the block from Ruby 1.9
●   Green threads with cooperatively
    scheduler
●   Can give up CPU contr...
Nginx vs Apache Death Match
EventMachine – Reactor
       Pattern
EventMachine
●   Based on python Twisted
●   Reactor sits in the middle
●   IOC pattern – Not many get used to it
●   Defe...
Actors -Stylishly passing
       messages
Actors
●   Message passing concurrency
●   No first class support in Ruby
●   Revactor is good but we had problems
    wit...
Transactions – We are safe
Software Transactional
              Memory
●   Similar to database transactions but
    inmemory (ACIDXX)
●   Unfortunate...
Multi Process
Coordination
Coordination
●   How do we coordinate independent
    units of execution?
●   Dataflow – Forgotten paradigm
●   Other meth...
Nirvana
Nirvana
●   Polyglotism – Let the languages which
    excel in concurrency do the job
●   Make Ruby talk with Clojure, Erl...
Sai Venkat
        github.com/saivenkat
             @sai_venkat
http://developer-in-test.blogspot.com




               ...
All images used are attributed to the
   awesome guys who took them..
       Please don't sue us :D
Concurrency patterns in Ruby
Concurrency patterns in Ruby
Concurrency patterns in Ruby
Upcoming SlideShare
Loading in...5
×

Concurrency patterns in Ruby

4,224

Published on

Ruby is a wonderful language for rapid development, it is easy to learn, we have wonderful frameworks, an active and dynamic community. But when it comes to concurrency Ruby is plagued with problems, controversies and urban legends. A lot of people would know about green threads in Ruby, GIL and its inherent limitations. But that it only one part of the big picture. Ruby offers much more than threads to helps us with concurrency.

This presentation explores other options of writing highly concurrent applications in Ruby and options available in it. We cover topics ranging from Actor like message passing concurrency in Ruby, dataflow concurrency of how we can coordinate across different threads, Event driven methods, coroutine based concurrency which never blocks ;) and finally Software Transactional Memory. We look at lots of code, some serious looking yet colorful performance graphs comparisons, and conditions at which each of these forms are concurrency are effective and ineffective.

Published in: Technology
0 Comments
11 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,224
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
62
Comments
0
Likes
11
Embeds 0
No embeds

No notes for slide

Transcript of "Concurrency patterns in Ruby"

  1. 1. Paradigms of Concurrency
  2. 2. Why is this important?
  3. 3. Or for geeks to relate...
  4. 4. Without right abstractions...
  5. 5. 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
  6. 6. 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
  7. 7. Threading in Ruby Concurrency is a myth Ruby - @igvita
  8. 8. 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...
  9. 9. Nginx vs Apache Death Match
  10. 10. EventMachine – Reactor Pattern
  11. 11. 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)
  12. 12. Actors -Stylishly passing messages
  13. 13. 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
  14. 14. Transactions – We are safe
  15. 15. Software Transactional Memory ● Similar to database transactions but inmemory (ACIDXX) ● 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
  16. 16. Multi Process
  17. 17. Coordination
  18. 18. 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)
  19. 19. Nirvana
  20. 20. 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.
  21. 21. Sai Venkat github.com/saivenkat @sai_venkat http://developer-in-test.blogspot.com HariKrishnan github.com/harikrishnan83 @harikrishnan83 http://harikrishnan83.wordpress.com
  22. 22. All images used are attributed to the awesome guys who took them.. Please don't sue us :D
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×