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
540
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
610
Consensus: An Introduction to Raft
vanstee
22
2.9k
Convergent Replicated Data Types
vanstee
4
740
Pour Over Brewing Method
vanstee
1
340
Map Reduce & Ruby
vanstee
10
780
Other Decks in Programming
See All in Programming
Orleans + Sekiban + SignalR でリアルタイムWeb作ってみた
tomohisa
0
250
七輪ライブラリー: Claude AI で作る Next.js アプリ
suneo3476
1
190
VibeCoding時代のエンジニアリング
daisuketakeda
0
200
状態と共に暮らす:ステートフルへの挑戦
ypresto
3
1.2k
監視 やばい
syossan27
12
10k
The Missing Link in Angular’s Signal Story: Resource API and httpResource
manfredsteyer
PRO
0
150
fieldalignmentから見るGoの構造体
kuro_kurorrr
0
140
エンジニアが挑む、限界までの越境
nealle
1
330
ニーリーQAのこれまでとこれから
nealle
2
810
GitHub Copilot for Azureを使い倒したい
ymd65536
1
330
Rubyの!メソッドをちゃんと理解する
alstrocrack
1
300
M5UnitUnified 最新動向 2025/05
gob
0
140
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
523
40k
GraphQLとの向き合い方2022年版
quramy
46
14k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
13
840
The Invisible Side of Design
smashingmag
299
50k
Optimizing for Happiness
mojombo
378
70k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Building a Modern Day E-commerce SEO Strategy
aleyda
40
7.2k
The Pragmatic Product Professional
lauravandoore
33
6.6k
We Have a Design System, Now What?
morganepeng
52
7.6k
Practical Orchestrator
shlominoach
187
11k
GraphQLの誤解/rethinking-graphql
sonatard
71
10k
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