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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Patrick Van Stee
July 11, 2012
Programming
4
590
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
141
7.3k
Elixir and Ecto
vanstee
5
980
Bootstrap
vanstee
8
820
HTTP API Design for iOS Applications
vanstee
11
680
Consensus: An Introduction to Raft
vanstee
21
3.1k
Convergent Replicated Data Types
vanstee
4
840
Pour Over Brewing Method
vanstee
1
390
Map Reduce & Ruby
vanstee
10
870
Other Decks in Programming
See All in Programming
守る「だけ」の優しいEMを抜けて、 事業とチームを両方見る視点を身につけた話
maroon8021
2
100
API Platformを活用したPHPによる本格的なWeb API開発 / api-platform-book-intro
ttskch
1
120
CSC307 Lecture 11
javiergs
PRO
0
580
AIとペアプロして処理時間を97%削減した話 #pyconshizu
kashewnuts
1
190
24時間止められないシステムを守る-医療ITにおけるランサムウェア対策の実際
koukimiura
2
180
米国のサイバーセキュリティタイムラインと見る Goの暗号パッケージの進化
tomtwinkle
1
380
並行開発のためのコードレビュー
miyukiw
2
2.2k
Go 1.26でのsliceのメモリアロケーション最適化 / Go 1.26 リリースパーティ #go126party
mazrean
1
330
TipKitTips
ktcryomm
0
150
あなたはユーザーではない #PdENight
kajitack
4
300
Premier Disciplin for Micro Frontends Multi Version/ Framework Scenarios @OOP 2026, Munic
manfredsteyer
PRO
0
200
DSPy入門 Pythonで実現する自動プロンプト最適化 〜人手によるプロンプト調整からの卒業〜
seaturt1e
1
470
Featured
See All Featured
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.1k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Scaling GitHub
holman
464
140k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
86
The Curious Case for Waylosing
cassininazir
0
260
We Are The Robots
honzajavorek
0
190
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
A better future with KSS
kneath
240
18k
Rails Girls Zürich Keynote
gr2m
96
14k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
360
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
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