SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

Más de 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
 

Más de 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
 

Último

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Último (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

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.