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
520
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.8k
Elixir and Ecto
vanstee
5
900
Bootstrap
vanstee
8
760
HTTP API Design for iOS Applications
vanstee
11
590
Consensus: An Introduction to Raft
vanstee
22
2.9k
Convergent Replicated Data Types
vanstee
4
720
Pour Over Brewing Method
vanstee
1
330
Map Reduce & Ruby
vanstee
10
760
Other Decks in Programming
See All in Programming
Generative AI for Beginners .NETの紹介
tomokusaba
1
130
JAWS Days 2025のインフラ
komakichi
1
370
Duke on CRaC with Jakarta EE
ivargrimstad
0
540
ML.NETで始める機械学習
ymd65536
0
300
エンジニアに許された特別な時間の終わり
watany
69
57k
The Price of Micro Frontends… and Your Alternatives @bastacon 2025 in Frankfurt
manfredsteyer
PRO
0
320
Lambdaの監視、できてますか?Datadogを用いてLambdaを見守ろう
nealle
2
860
もう少しテストを書きたいんじゃ〜 #phpstudy
o0h
PRO
21
4.5k
Boos Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
950
技術を改善し続ける
gumioji
0
190
AIレビュー導入によるCIツールとの共存と最適化
kamo26sima
1
1.3k
「個人開発マネタイズ大全」が教えてくれたこと
bani24884
1
320
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
The Language of Interfaces
destraynor
156
24k
Designing on Purpose - Digital PM Summit 2013
jponch
117
7.1k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Docker and Python
trallard
44
3.3k
The World Runs on Bad Software
bkeepers
PRO
67
11k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.5k
Done Done
chrislema
182
16k
Bash Introduction
62gerente
611
210k
Large-scale JavaScript Application Architecture
addyosmani
511
110k
Faster Mobile Websites
deanohume
306
31k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.3k
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