More Related Content
The Actor Model - Towards Better Concurrency
Actor Patterns and NATS - Boulder Meetup
Actor model : A Different Concurrency Approach
A gentle introduction into AKKA and the actor model
Model with actors and implement with Akka
Introduction to Actor Model and Akka
Actor-based concurrency and Akka Fundamentals
Hybrid concurrency patterns
What's hot
Introduction to Actor Model and Akka
Akka.net versus microsoft orleans
Ruby is dying. What languages are cool now?
Web development basics (Part-6)
Online game server on Akka.NET (NDC2016)
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Combining the strength of erlang and Ruby
Actors Set the Stage for Project Orleans
Functional Programming in Clojure
Erlang factory SF 2011 "Erlang and the big switch in social games"
Introduction to the Actor Model
Viewers also liked
Building Reactive Systems with Akka (in Java 8 or Scala)
Real Time Data Streaming using Kafka & Storm
Is ruby logger thread(process)-safe? at RubyConf 2013
Threading and Concurrency in Ruby
Concurrent Programming with Ruby and Tuple Spaces
JRuby on Rails and Thread Safety
Scaling Ruby with Evented I/O - Ruby underground
Akka - Developing SEDA Based Applications
Multi-threaded web crawler in Ruby
Ruby Concurrency and EventMachine
Real-Time Analytics with Kafka, Cassandra and Storm
Similar to Actors and Threads
Ruby Concurrency Realities
Ruby's Concurrency Management: Now and Future
Concurrency patterns in Ruby
Concurrency patterns in Ruby
Concurrent programming with Celluloid (MWRC 2012)
Concurrency: Rubies, Plural
Concurrency: Rubies, plural
Bringing Concurrency to Ruby - RubyConf India 2014
Clojure's take on concurrency
Comparing implementations of the actor model
Processes and Threads in Windows Vista
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
Recently uploaded
2DArrays_Matrix data structure and algorithm
Building Agents in Microsoft Agent Framework.pptx
Session 2 - Solving Unstructured & Complex Documents with UiPath IXP
THREE PATHS TO PERSITENT AWS COMPROMISE A pentester's playbook.pptx
Workshop on Sustaining & Growing Open Source Communities - GAS2025
Emancipatory Information Retrieval: Radically Reorienting Information Retriev...
GDG Cloud Southlake #48: Goutham Rao: Building Agentic Systems for SRE's
Cross-Cultural Agile Development -Challenges and Strategies for Overcoming Them-
UiPath Autonomous Agents | Building and Orchestrating Agents End-to-End
Two UX Patterns We Don’t Talk About Enough
Fundamentals and Frontiers of Post Quantum Cryptography
Lab 3.3 Serverless, Secrets, and API Gateway - 2nd Sight Lab Cloud Security C...
Lab 4.1 Cloud IAM - 2nd Sight Lab Cloud Security Class
Ai Chatbot development: Guide for Modern Businesses
10 Things AI-First Apps Do Differently by iProgrammer Solutions
Introduction to cybersecurity and pentesting
Lab 2.2 DNS In The Cloud - 2nd Sight Lab Cloud Security Class
What Is a Private LLM and Why Enterprises Need It
Core Components of Internet of Things (IoT)
Copy of AI in Pharma Sector by Dhairya.pptx
Actors and Threads
- 1.
- 2.
Who Am I? •Numerous gems (dalli, memcache-client, rack-fiber_pool, connection_pool, etc) • Scalability/Performance guy • Fibers and EventMachine • Technical Lead at Carbon Five
- 3.
- 4.
What This Isn’t •Threads vs Events vs Processes • Threads won’t make you love Java
- 5.
Definitions • Concurrency -performing two operations in tandem (e.g. two web requests) • Parallelism - performing two operations literally at the same time (requires two cores) Concurrent Parallel
- 6.
- 7.
The problem isalways communication (true in the real world too!)
- 8.
- 10.
- 11.
- 12.
Threads • Much moreefficient than processes • Communication mechanism? • Variables! • POSIX 1995
- 13.
- 14.
- 15.
End Goals • RuntimeEfficiency isn’t the only goal! • Remember Fun? • Ease of Development is huge
- 16.
- 17.
- 18.
Lock Benchmark # Results: Ruby 1.9.2, GIL means no parallel threading # user system total real # single locked 4.310000 0.010000 4.320000 ( 4.311850) # threaded locked 4.230000 0.080000 4.310000 ( 4.307405) # # Results: JRuby 1.6.3, parallel threads mean massive lock contention # user system total real # single locked 4.080000 0.000000 4.080000 ( 4.080000) # threaded locked 17.109000 0.000000 17.109000 ( 17.109000) Context Switching!
- 19.
- 20.
What can wedo? • Look to other languages • Go • Scala • Erlang
- 21.
- 22.
Goroutines • Really likethis model • Maps well to a distributed model • Backed by a pool of threads
- 23.
Actors • unit ofexecution • has a mailbox • You just send it a message, e.g. • actor << { :amount => 11.99 }
- 24.
- 25.
- 26.
- 27.
- 28.
Celluloid • Tony Arcieri(Revactor, Reia) • https://github.com/tarcieri/celluloid • OO Actors • Asynchronous method invocation • Mix of Threads and Fibers
- 29.
- 30.
- 31.
girl_friday • yours truly •http://github.com/mperham/girl_friday • Background processing pools • Parallel batch operations • More functional than OO • Thread-based
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
STM • Software TransactionalMemory • All mutation via transactions • Provide ACI (not ACID) guarantees • See Clojure (and Cloby!)
- 38.
Atomic Instructions • SincePentium (1993) • XCHG - swap registers or register/ memory • CPMXCHG - Compare And Set (‘CAS’)
- 39.
- 40.
Atomic Benchmark # Results:JRuby 1.6.3 # user system total real # single atomic 2.041000 0.000000 2.041000 ( 2.041000) # threaded atomic 0.978000 0.000000 0.978000 ( 0.979000) 2 cores = 2x speedup!
- 41.
- 42.
- 43.
Concurrency It’s always hard! Modern languages should support tools and APIs that scale well AND are developer-friendly.
- 44.
To Do • Needstandard Actor API • Concurrent data structures • STM impl for Ruby (via JRuby?) • Multiverse
- 45.
Further Reading • Kilim- Actors for Java • Disruptor - concurrency without locks • Actors in Scala • Concurrency in Erlang
- 46.
Thank You! Questions? @mperham http://mikeperham.com http://blog.carbonfive.com PS We’re hiring!