Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Celluloid & DCell
Search
Patrick Van Stee
July 11, 2012
Programming
4
530
Celluloid & DCell
Patrick Van Stee
July 11, 2012
Tweet
Share
More Decks by Patrick Van Stee
See All by Patrick Van Stee
Raft: Consensus for Rubyists
vanstee
137
6.9k
Elixir and Ecto
vanstee
5
910
Bootstrap
vanstee
8
770
HTTP API Design for iOS Applications
vanstee
11
600
Consensus: An Introduction to Raft
vanstee
22
2.9k
Convergent Replicated Data Types
vanstee
4
730
Pour Over Brewing Method
vanstee
1
330
Map Reduce & Ruby
vanstee
10
770
Other Decks in Programming
See All in Programming
Firebase Dynamic Linksの代替手段を自作する / Create your own Firebase Dynamic Links alternative
kubode
0
240
Boost Your Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
1.4k
Devinのメモリ活用の学びを自社サービスにどう組み込むか?
itarutomy
0
2.1k
Code smarter, not harder - How AI Coding Tools Boost Your Productivity | Webinar 2025
danielsogl
0
120
SQL Server ベクトル検索
odashinsuke
0
170
趣味全開のAITuber開発
kokushin
0
200
RuboCop: Modularity and AST Insights
koic
1
160
State of Namespace
tagomoris
4
930
5年間継続して開発した自作OSSの記録
bebeji_nappa
0
190
Agentic Applications with Symfony
el_stoffel
2
270
英語 × の私が、生成AIの力を借りて、OSSに初コントリビュートした話
personabb
0
200
Bedrock×MCPで社内ブログ執筆文化を育てたい!
har1101
6
950
Featured
See All Featured
Gamification - CAS2011
davidbonilla
81
5.2k
Building an army of robots
kneath
304
45k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.3k
Build The Right Thing And Hit Your Dates
maggiecrowley
35
2.6k
How to Think Like a Performance Engineer
csswizardry
23
1.5k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.2k
Measuring & Analyzing Core Web Vitals
bluesmoon
7
390
Docker and Python
trallard
44
3.3k
GitHub's CSS Performance
jonrohan
1030
460k
The World Runs on Bad Software
bkeepers
PRO
67
11k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
4 Signs Your Business is Dying
shpigford
183
22k
Transcript
Celluloid DCell &
@vanstee github.com/vanstee Patrick Van Stee highgroove.com
@tarcieri Revactor Reia nio4r Cryptosphere cool.io
brew install zeromq gem install dcell Setup
Celluloid General purpose concurrency framework for Ruby built on the
Actor Model
class Counter attr_reader :count def initialize @count = 0 end
def increment @count += 1 end end
class Counter attr_reader :count def initialize @count = 0 @mutex
= Mutex.new end def increment @mutex.synchronize do @count += 1 end end end
Threads are hard!
class Counter include Celluloid attr_reader :count def initialize @count =
0 end def increment @count += 1 end end
Actor Model
•No shared state •Communicate with messages •Process messages sequentially
class Counter include Celluloid def increment(count, actor) return count if
count < 10000 actor.increment( count + 1, Actor.current ) end end
& Asynchronous Method Calls Futures
counter = Counter.new # returns immediately counter.increment! puts counter.count #
returns immediately future = counter.future :increment puts future.value
module Enumerable def map(&block) futures = map do |item| Celluloid::Future.new(
item, &block ) end futures.map(&:value) end end
Caveats
• The GIL in MRI does not allow parallelism •
Threads and Fibers are expensive • Concurrency is still a hard problem [not really]
DCell
Celluloid General purpose concurrency framework for Ruby built on the
Actor Model DCell Distributed Celluloid over 0MQ
“I thought of objects being like biological cells or individual
computers on a network, only able to communicate with messages. Alan Kay
• Exposes Actors on the Network • Send messages as
you normally would
DRb DCell Threads Actors
Demo
Also Checkout Sidekiq
github.com celluloid/celluloid celluloid/dcell
Hack Night