SlideShare a Scribd company logo
1 of 28
Modeling concurrency in Ruby and beyond what is an advanced concurrency model? Ilya Grigorik @igrigorik
“Concurrency is a property of systems in which several computations are executing simultaneously, and potential interacting with each other.”
Threads! No. Events! Neither. You need them both. and neither is enough…
2Ghz CPU = 0.5 ns cycle RAM: 2000 wasted cycles! ~0.5 ns ~100 ns ,[object Object]
Brand prediction
Instruction pipelining
Hyperthreading
Speculative execution
…~7 ns Hardware Parallelism  maximizing resource utilization http://bit.ly/cSKKVb
if(cond1 && cond2) { System.err.println("Am I faster yet?"); } if (cond1 || cond2) { System.err.println("Am I fast yet?"); } 1 2 Turns out. We don’t know. A quick poll which is faster?
Hardware Parallelism Software Parallelism (Processes, Threads, Events) pthreads, lwkt, epoll, kqueue, … C / C++, Java, Ruby, …. The “concurrency API” a bolt-on systems component for any language
Bruce: if you could go back in time, what is the one thing you would change? Matz: “I would remove the thread and add actors or some other more advanced concurrency features” More advanced concurrency features?
Hardware Parallelism Software Parallelism (Processes, Threads, Events) pthreads, lwkt, epoll, kqueue, … New! “Advanced concurrency model” C / C++, Java, Ruby, ….
Dataflow Petri-nets Actor Model Transactional Memory Pi-calculus / CSP … http://bit.ly/fMLJR8
The value of a tool / model is in: what it enables you to do    the constraints it imposes ,[object Object]
Dictate a structure
Dictate a style
Disallow unwanted behavior
Implicitly “make the right choice”
Eliminate a class of errors,[object Object]
Give every process a name Give every process a “mailbox” Communicate via messages ,[object Object],Enables: ,[object Object]
Communication between: threads, processes, machines
Distributed programmingConstraints: ,[object Object]
No race conditions
No mutexes, no semaphoresActor Model The 50k foot view…
“Communicating sequential processes” Hoare, C.A.R. (1978) CCS, pi-calculus, … … Limbo (1995), Go (2007), CSP++, PyCSP… The history:CSPmodel Let’s rewind back to the 1978 …
Processes are anonymous Give every channel a name Processes communicate over named channels ,[object Object],Enables: ,[object Object]
Communication between: threads, processes, machines

More Related Content

More from Ilya Grigorik

No Callbacks, No Threads - RailsConf 2010
No Callbacks, No Threads - RailsConf 2010No Callbacks, No Threads - RailsConf 2010
No Callbacks, No Threads - RailsConf 2010Ilya Grigorik
 
Real-time Ruby for the Real-time Web
Real-time Ruby for the Real-time WebReal-time Ruby for the Real-time Web
Real-time Ruby for the Real-time WebIlya Grigorik
 
Ruby C10K: High Performance Networking - RubyKaigi '09
Ruby C10K: High Performance Networking - RubyKaigi '09Ruby C10K: High Performance Networking - RubyKaigi '09
Ruby C10K: High Performance Networking - RubyKaigi '09Ilya Grigorik
 
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Ilya Grigorik
 
Leveraging Social Media - Strategies & Tactics - PostRank
Leveraging Social Media - Strategies & Tactics - PostRankLeveraging Social Media - Strategies & Tactics - PostRank
Leveraging Social Media - Strategies & Tactics - PostRankIlya Grigorik
 
Ruby Proxies for Scale, Performance, and Monitoring
Ruby Proxies for Scale, Performance, and MonitoringRuby Proxies for Scale, Performance, and Monitoring
Ruby Proxies for Scale, Performance, and MonitoringIlya Grigorik
 
Building Mini Google in Ruby
Building Mini Google in RubyBuilding Mini Google in Ruby
Building Mini Google in RubyIlya Grigorik
 
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.comRuby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.comIlya Grigorik
 
Event Driven Architecture - MeshU - Ilya Grigorik
Event Driven Architecture - MeshU - Ilya GrigorikEvent Driven Architecture - MeshU - Ilya Grigorik
Event Driven Architecture - MeshU - Ilya GrigorikIlya Grigorik
 
Taming The RSS Beast
Taming The  RSS  BeastTaming The  RSS  Beast
Taming The RSS BeastIlya Grigorik
 

More from Ilya Grigorik (10)

No Callbacks, No Threads - RailsConf 2010
No Callbacks, No Threads - RailsConf 2010No Callbacks, No Threads - RailsConf 2010
No Callbacks, No Threads - RailsConf 2010
 
Real-time Ruby for the Real-time Web
Real-time Ruby for the Real-time WebReal-time Ruby for the Real-time Web
Real-time Ruby for the Real-time Web
 
Ruby C10K: High Performance Networking - RubyKaigi '09
Ruby C10K: High Performance Networking - RubyKaigi '09Ruby C10K: High Performance Networking - RubyKaigi '09
Ruby C10K: High Performance Networking - RubyKaigi '09
 
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
 
Leveraging Social Media - Strategies & Tactics - PostRank
Leveraging Social Media - Strategies & Tactics - PostRankLeveraging Social Media - Strategies & Tactics - PostRank
Leveraging Social Media - Strategies & Tactics - PostRank
 
Ruby Proxies for Scale, Performance, and Monitoring
Ruby Proxies for Scale, Performance, and MonitoringRuby Proxies for Scale, Performance, and Monitoring
Ruby Proxies for Scale, Performance, and Monitoring
 
Building Mini Google in Ruby
Building Mini Google in RubyBuilding Mini Google in Ruby
Building Mini Google in Ruby
 
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.comRuby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
 
Event Driven Architecture - MeshU - Ilya Grigorik
Event Driven Architecture - MeshU - Ilya GrigorikEvent Driven Architecture - MeshU - Ilya Grigorik
Event Driven Architecture - MeshU - Ilya Grigorik
 
Taming The RSS Beast
Taming The  RSS  BeastTaming The  RSS  Beast
Taming The RSS Beast
 

Recently uploaded

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 

Recently uploaded (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 

Modeling concurrency in Ruby and beyond

  • 1. Modeling concurrency in Ruby and beyond what is an advanced concurrency model? Ilya Grigorik @igrigorik
  • 2. “Concurrency is a property of systems in which several computations are executing simultaneously, and potential interacting with each other.”
  • 3. Threads! No. Events! Neither. You need them both. and neither is enough…
  • 4.
  • 9. …~7 ns Hardware Parallelism maximizing resource utilization http://bit.ly/cSKKVb
  • 10. if(cond1 && cond2) { System.err.println("Am I faster yet?"); } if (cond1 || cond2) { System.err.println("Am I fast yet?"); } 1 2 Turns out. We don’t know. A quick poll which is faster?
  • 11. Hardware Parallelism Software Parallelism (Processes, Threads, Events) pthreads, lwkt, epoll, kqueue, … C / C++, Java, Ruby, …. The “concurrency API” a bolt-on systems component for any language
  • 12. Bruce: if you could go back in time, what is the one thing you would change? Matz: “I would remove the thread and add actors or some other more advanced concurrency features” More advanced concurrency features?
  • 13. Hardware Parallelism Software Parallelism (Processes, Threads, Events) pthreads, lwkt, epoll, kqueue, … New! “Advanced concurrency model” C / C++, Java, Ruby, ….
  • 14. Dataflow Petri-nets Actor Model Transactional Memory Pi-calculus / CSP … http://bit.ly/fMLJR8
  • 15.
  • 19. Implicitly “make the right choice”
  • 20.
  • 21.
  • 22. Communication between: threads, processes, machines
  • 23.
  • 25. No mutexes, no semaphoresActor Model The 50k foot view…
  • 26. “Communicating sequential processes” Hoare, C.A.R. (1978) CCS, pi-calculus, … … Limbo (1995), Go (2007), CSP++, PyCSP… The history:CSPmodel Let’s rewind back to the 1978 …
  • 27.
  • 28. Communication between: threads, processes, machines
  • 29.
  • 31. No mutexes, no semaphoresCSP / Pi-calculus The 50k foot view…
  • 32. A Multiple workers can share a channel A Workers are mobile! Delegate the channel to someone else! C(A) A A(B) Send a “response” channel to another process! B
  • 33. gem install agent let’s get hands on…
  • 34. Named channel Typed channel c =Agent::Channel.new(name: 'incr', type: Integer) go(c) do |c, i=0| loop { c <<i+= 1 } end p c.receive# => 1 p c.receive# => 2 Spawn the worker Consume the results Producer / Consumer look, no threads!
  • 35. Request =Struct.new(:args, :resultChan) clientRequests=Agent::Channel.new(name: :clientRequests, type: Request, size: 2) worker = Proc.new do |reqs| loop do req = reqs.receive sleep 1.0 req.resultChan << [Time.now, req.args + 1].join(' : ') end end # start two workers go(clientRequests, &worker) go(clientRequests, &worker) req1 = Request.new(1, Agent::Channel.new(:name => "resultChan-1", :type => String)) req2 = Request.new(2, Agent::Channel.new(:name => "resultChan-2", :type => String)) clientRequests << req1 clientRequests << req2 puts req1.resultChan.receive # => 2010-11-28 23:31:08 -0500 : 2 puts req2.resultChan.receive # => 2010-11-28 23:31:08 -0500 : 3 “Request” type A “multi-threaded” server! where’s the synchronization?
  • 36. Request =Struct.new(:args, :resultChan) clientRequests=Agent::Channel.new(name: :clientRequests, type: Request, size: 2) worker =Proc.newdo |reqs| loopdo req=reqs.receive sleep 1.0 req.resultChan<< [Time.now, req.args+ 1].join(' : ') end end # start two workers go(clientRequests, &worker) go(clientRequests, &worker) req1 = Request.new(1, Agent::Channel.new(:name => "resultChan-1", :type => String)) req2 = Request.new(2, Agent::Channel.new(:name => "resultChan-2", :type => String)) clientRequests << req1 clientRequests << req2 puts req1.resultChan.receive # => 2010-11-28 23:31:08 -0500 : 2 puts req2.resultChan.receive # => 2010-11-28 23:31:08 -0500 : 3 wait for work Sleep, increment, add timestamp A “multi-threaded” server! where’s the synchronization?
  • 37. Request =Struct.new(:args, :resultChan) clientRequests=Agent::Channel.new(name: :clientRequests, type: Request, size: 2) worker =Proc.newdo |reqs| loopdo req=reqs.receive sleep 1.0 req.resultChan<< [Time.now, req.args+ 1].join(' : ') end end # start two workers go(clientRequests, &worker) go(clientRequests, &worker) req1 = Request.new(1, Agent::Channel.new(:name => "resultChan-1", :type => String)) req2 = Request.new(2, Agent::Channel.new(:name => "resultChan-2", :type => String)) clientRequests << req1 clientRequests << req2 puts req1.resultChan.receive # => 2010-11-28 23:31:08 -0500 : 2 puts req2.resultChan.receive # => 2010-11-28 23:31:08 -0500 : 3 Both workers listen on same channel A “multi-threaded” server! where’s the synchronization?
  • 38. Request =Struct.new(:args, :resultChan) clientRequests=Agent::Channel.new(name: :clientRequests, type: Request, size: 2) worker =Proc.newdo |reqs| loopdo req=reqs.receive sleep 1.0 req.resultChan<< [Time.now, req.args+ 1].join(' : ') end end # start two workers go(clientRequests, &worker) go(clientRequests, &worker) req1 =Request.new(1, Agent::Channel.new(:name => "resultChan-1", :type => String)) req2 =Request.new(2, Agent::Channel.new(:name => "resultChan-2", :type => String)) clientRequests << req1 clientRequests << req2 puts req1.resultChan.receive # => 2010-11-28 23:31:08 -0500 : 2 puts req2.resultChan.receive # => 2010-11-28 23:31:08 -0500 : 3 Create two requests, each with return channel of type String A “multi-threaded” server! where’s the synchronization?
  • 39. Request =Struct.new(:args, :resultChan) clientRequests=Agent::Channel.new(name: :clientRequests, type: Request, size: 2) worker =Proc.newdo |reqs| loopdo req=reqs.receive sleep 1.0 req.resultChan<< [Time.now, req.args+ 1].join(' : ') end end # start two workers go(clientRequests, &worker) go(clientRequests, &worker) req1 =Request.new(1, Agent::Channel.new(:name => "resultChan-1", :type => String)) req2 =Request.new(2, Agent::Channel.new(:name => "resultChan-2", :type => String)) clientRequests<< req1 clientRequests<< req2 puts req1.resultChan.receive # => 2010-11-28 23:31:08 -0500 : 2 puts req2.resultChan.receive # => 2010-11-28 23:31:08 -0500 : 3 Dispatch both requests A “multi-threaded” server! where’s the synchronization?
  • 40. Request =Struct.new(:args, :resultChan) clientRequests=Agent::Channel.new(name: :clientRequests, type: Request, size: 2) worker =Proc.newdo |reqs| loopdo req=reqs.receive sleep 1.0 req.resultChan<< [Time.now, req.args+ 1].join(' : ') end end # start two workers go(clientRequests, &worker) go(clientRequests, &worker) req1 =Request.new(1, Agent::Channel.new(:name => "resultChan-1", :type => String)) req2 =Request.new(2, Agent::Channel.new(:name => "resultChan-2", :type => String)) clientRequests<< req1 clientRequests<< req2 puts req1.resultChan.receive # => 2010-11-28 23:31:08 -0500 : 2 puts req2.resultChan.receive # => 2010-11-28 23:31:08 -0500 : 3 A “multi-threaded” server! where’s the synchronization? Collect the results!
  • 41. So, Ruby? JRuby, RBX, MacRuby, MRI, …
  • 42.
  • 44. Existing libraries & frameworks: Akka, Kilim, etc
  • 45.
  • 46. Built in Channel / Actor primitives
  • 47.
  • 49.
  • 51. GCD + higher level API?The many Rubies… for your concurrency experiments
  • 52.
  • 54.
  • 56.
  • 58.
  • 60. http://www.scala-lang.org/… and many others … Pick up & experiment with other runtimes! learn what works, find what resonates…
  • 61.
  • 62. Are threads, events, etc., the right API for modeling concurrency? Likely not.
  • 63.