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
550
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
140
7k
Elixir and Ecto
vanstee
5
930
Bootstrap
vanstee
8
780
HTTP API Design for iOS Applications
vanstee
11
630
Consensus: An Introduction to Raft
vanstee
22
2.9k
Convergent Replicated Data Types
vanstee
4
750
Pour Over Brewing Method
vanstee
1
350
Map Reduce & Ruby
vanstee
10
790
Other Decks in Programming
See All in Programming
Quand Symfony, ApiPlatform, OpenAI et LangChain s'allient pour exploiter vos PDF : de la théorie à la production…
ahmedbhs123
0
120
GoのGenericsによるslice操作との付き合い方
syumai
3
710
PHPでWebSocketサーバーを実装しよう2025
kubotak
0
240
地方に住むエンジニアの残酷な現実とキャリア論
ichimichi
5
1.5k
AWS CDKの推しポイント 〜CloudFormationと比較してみた〜
akihisaikeda
3
320
第9回 情シス転職ミートアップ 株式会社IVRy(アイブリー)の紹介
ivry_presentationmaterials
1
260
既存デザインを変更せずにタップ領域を広げる方法
tahia910
1
260
0626 Findy Product Manager LT Night_高田スライド_speaker deck用
mana_takada
0
140
PicoRuby on Rails
makicamel
2
120
AIコーディング道場勉強会#2 君(エンジニア)たちはどう生きるか
misakiotb
1
270
CursorはMCPを使った方が良いぞ
taigakono
1
210
NPOでのDevinの活用
codeforeveryone
0
650
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
30
5.8k
RailsConf 2023
tenderlove
30
1.1k
Typedesign – Prime Four
hannesfritz
42
2.7k
What's in a price? How to price your products and services
michaelherold
246
12k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3.1k
Done Done
chrislema
184
16k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
24k
Into the Great Unknown - MozCon
thekraken
39
1.9k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
940
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