• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Hybrid concurrency patterns
 

Hybrid concurrency patterns

on

  • 38,836 views

Ruby developers need to stop using EventMachine. It's the wrong direction. ...

Ruby developers need to stop using EventMachine. It's the wrong direction.

Lost in the "Threads vs Event Driven vs Process Spawning" debate is that you can combine them! Learn how Celluloid is improving thread programming by abstracting them using a higher level framework called Celluloid, how you can use Celluloid::IO to throw a reactor pattern into a thread. Using this approach, you can take advantage of threading and use all CPU power on a machine with JRuby or Rubinius. I also discuss the future of distributed objects and computing, and where I think things are going.

Statistics

Views

Total Views
38,836
Views on SlideShare
38,001
Embed Views
835

Actions

Likes
72
Downloads
140
Comments
12

49 Embeds 835

https://twitter.com 347
http://deepencpp.blogspot.com 94
http://deepencpp.blogspot.ru 85
http://feeds.feedburner.com 46
http://reader.afp-group.com 38
http://www.twylah.com 25
http://localhost 21
http://twylah.local 20
http://staging.twylah.com 14
http://nuevospowerpoints.blogspot.com 12
http://nuevospowerpoints.blogspot.com.es 11
http://www.newsblur.com 10
https://si0.twimg.com 9
http://twitter.com 9
http://reader.aol.com 8
http://www.techgig.com 7
http://www.linkedin.com 7
http://digg.com 6
http://feedly.com 6
http://nuevospowerpoints.blogspot.mx 5
http://127.0.0.1 4
http://rssminer.net 4
http://www.feedspot.com 3
http://blogg-it.ru 3
http://feedproxy.google.com 3
http://deepencpp.blogspot.nl 3
http://x-web-64-5 3
http://deepencpp.blogspot.cz 3
http://bazqux.com 3
http://videofork.com 3
http://mundo-powerpoints.blogspot.com.es 2
http://www.m.techgig.com 2
http://hydsglorial.blogspot.com 2
http://deepencpp.blogspot.ca 2
http://inoreader.com 1
http://newsblur.com 1
http://cloud.feedly.com 1
http://www.slashdocs.com 1
http://moderation.local 1
http://deepencpp.blogspot.com.au 1
http://deepencpp.blogspot.de 1
http://rc.online.feedreader.com 1
http://fro.surl-php5.test.web.informer.com 1
http://redis.io 1
http://feedspot.com 1
http://tweetedtimes.com 1
http://www.crowdlens.com 1
http://deepencpp.blogspot.hu 1
http://nodeslide.herokuapp.com 1
More...

Accessibility

Upload Details

Uploaded via as Apple Keynote

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

110 of 12 previous next Post a comment

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • i really can't tell all you young kids how much of my life i've spent debugging shitty threaded code and writing libraries to make is less error prone.

    it can't be done.

    give up. move on.
    Are you sure you want to
    Your message goes here
    Processing…
  • @bdicasa I certainly agree that detecting bugs caused by non-threadsafe code can be very difficult, my core thesis remains strong and I stick to it. If you focus on making your code threadsafe when you design and build it initially, then you don't NEED to worry about finding bugs due to threading issues. When thread safety is written into every object from the start (which really isn't all that hard, really) then you won't have to address threading bugs, because they won't exist.
    Are you sure you want to
    Your message goes here
    Processing…
  • @Brendten I'm not arguing the fact that knowing how to write thread-safe code is an absolute for any software developer. I'm also not arguing the fact that learning how to write thread safe code is hard. However issues with threading can be hard to detect, so why not use concurrency patterns that help you to avoid race conditions and deadlocks?
    Are you sure you want to
    Your message goes here
    Processing…
  • @peterashford9 So true, Peter. I love Ruby, but I'm not a 'Rubyist'. A problem I've always had with a large group of 'rubyists' out there is that they seem to think being a Ruby dev absolves them from learning CS fundamentals in any way. You can't be a ruby developer without being a developer. Just because you started out as a Web designer/developer and found Ruby by way of Rails doesn't mean you can just ignore and/or not learn and practice the skills that are required fundamentals for software engineers using other languages. I would never even considering hiring a Java dev who couldn't write threadsafe code. Why should I consider hiring a 'rubyist' who can't, either? I hire developers who have the skills and knowledge that form the foundations of CS. If you have that, you can learn Java, or Ruby, or Python, or Objective C, or (*gack*) C# (or even more esoteric languages and frameworks we might use from time to time like Erlang, or OCaml, or Haskell, or whatever).
    Are you sure you want to
    Your message goes here
    Processing…
  • @bdicasa Let's be clear: threads don't introduce problems, programmers who don't know how to use them, or who use them carelessly, introduce the problems. My argument here is that as a developer living and working in a multi-processor, multi-core world, you MUST understand threads and how to write threadsafe code. This should be a core part of everything you do when you design your software. Think about this: Tony has done a really nice job with Celluloid (and I have used it myself on occasion), but what if he gets hit by a bus, or if he suddenly decides to stop open-sourcing the code? Or what if you're not using Celluloid, and developing with MRI in mind, but along comes another developer 5 years after you've moved on to greener pastures, and decides to run your code on JRuby? What will happen to all of this code? It will be broken, and it will be your fault. Why? Because you chose to ignore the 'difficult' problems of multi-threaded concurrency when you originally designed and wrote your code. So, contrary to your assertion that 'it helps to understand how threading works,' I assert that you MUST understand how threading works (and as a corollary, how to write threadsafe code) in order to be even a competent software engineer in the world today.
    Are you sure you want to
    Your message goes here
    Processing…

110 of 12 previous next

Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Hybrid concurrency patterns Hybrid concurrency patterns Presentation Transcript

  • Threads and Events inHarmony with Celluloid Kyle Drake
  • Hi, I’m Kyle Drake. Iwork at Geoloqi Esri.We built a geofencing Textand real-time location streaming platform.
  • Last year, IText a didtalk at KRTConf.
  • I was really intopure event-driven Text(reactor patternbased) architecture.
  • EventMachine, Twisted, Node.js• Event-driven Text• No threads• One CPU core• Process Spawning
  • I releasedsinatra-synchrony,so I could use TextEventMachinewithout callbacks.
  • Since then, I’ve Textchanged my mind.
  • I’m really not a fanof EventMachine Textanymore.
  • EventMachine is• A frankenstein - guts the ruby internals• Not in active development Text• Makes non-blocking IO block• Requires special code from Ruby libraries• Hard to use in an OOP way• Is really difficult to work with• Poorly documented
  • Ruby developersneed to stop usingEventMachine. It’s Textthe wrongdirection.
  • Check thisbenchmark Textout:
  • Texthttp://rhaas.blogspot.com/2012/04/did-i-say-32-cores-how-about-64.html
  • Predictions:More Cores.A lot more.
  • Predictions:More libraries =more memory
  • Will processspawning work forever? It might.
  • It might not.Thousands of cores?
  • Ruby MRI:Global Interpreter Lock (single CPU core) Rubinius and JRuby: Full threading (multiple CPU cores)~20KB per thread
  • We’re not finding a lot of thread safety issues in Ruby.
  • “Threading is hard”
  • Threading is not an intention!
  • Let’s fix it by abstractingthreads into how humans think!
  • http://celluloid.io• Developed by Tony Arcieri• Actor Pattern for Ruby• Lots of inspiration from Erlang
  • Each actor is aconcurrent objectrunning in its own thread
  • First “Killer App”: Sidekiq Mike Perham
  • Don’t get mewrong. Event-driven is still awesome.
  • “..seasoned engineers areusing a mix of threaded,event-based, andalternative concurrencyapproaches like Actors” - Alex Payne
  • What if we couldcombine threads and reactor patterns.. and actors?!
  • https://github.com/celluloid/celluloid-io• One reactor pattern per Celluloid object• Multiple reactors? No problem!• Doesn’t mess with code outside of actor• Utilizes all CPU cores (using JRuby and Rubinius)• Websockets, messaging systems, your hugelysuccessful blog
  • You dont have tochoose between threaded and evented IO!
  • Let’s getdistributed.
  • "I thought of objects being like biological cells and/or individual computers on a network, only able to communicate with messages" - Alan Kay
  • Guess who was really into distributed network objects?
  • NeXT experimented with distributedobjects in the mid 90s.NeXT was way ahead of its time.
  • "Objects can message objects transparentlythat live on other machines over the network, and you dont have to worry about thenetworking gunk, and you dont have to worry about finding them, and you dont have to worry about anything. Its just as if you messaged an object thats right next door." - Steve Jobs
  • “Portable Distributed Objects”
  • https://github.com/celluloid/dcell • Objects talk over networks! • Uses 0MQ • Aware of eachothers’ existence • Distributed gossip protocol • Web UI • In the early stages, very promising
  • CODEEXAMPLES!
  • Help UsBuild This!
  • Thanks! @kyledrakekyledrake.net