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
600
4
Share
Celluloid & DCell
Patrick Van Stee
July 11, 2012
More Decks by Patrick Van Stee
See All by Patrick Van Stee
Raft: Consensus for Rubyists
vanstee
141
7.4k
Elixir and Ecto
vanstee
5
990
Bootstrap
vanstee
8
830
HTTP API Design for iOS Applications
vanstee
11
690
Consensus: An Introduction to Raft
vanstee
21
3.1k
Convergent Replicated Data Types
vanstee
4
860
Pour Over Brewing Method
vanstee
1
400
Map Reduce & Ruby
vanstee
10
890
Other Decks in Programming
See All in Programming
GitHubCopilotCLIをはじめよう.pdf
htkym
0
210
The Less-Told Story of Socket Timeouts
coe401_
3
570
tRPCの概要と少しだけパフォーマンス
misoton665
2
220
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
16
5.6k
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
110
iOS機能開発のAI環境と起きた変化
ryunakayama
0
190
ソフトウェア設計の結合バランス #phperkaigi
kajitack
0
140
Liberating Ruby's Parser from Lexer Hacks
ydah
2
1.8k
属人化しないコード品質の作り方_2026.04.07.pdf
muraaano
0
220
瑠璃の宝石に学ぶ技術の声の聴き方 / 【劇場版】アニメから得た学びを発表会2026 #エンジニアニメ
mazrean
0
270
書籍「ユーザーストーリーマッピング」が私のバイブル
asumikam
4
390
Surviving Black Friday: 329 billion requests with Falcon!
ioquatix
0
700
Featured
See All Featured
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
61
43k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.8k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1k
Unsuck your backbone
ammeep
672
58k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
280
The untapped power of vector embeddings
frankvandijk
2
1.7k
Believing is Seeing
oripsolob
1
110
The browser strikes back
jonoalderson
0
980
Tell your own story through comics
letsgokoyo
1
900
How GitHub (no longer) Works
holman
316
150k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
340
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
180
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