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
610
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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.6k
Elixir and Ecto
vanstee
5
1k
Bootstrap
vanstee
8
850
HTTP API Design for iOS Applications
vanstee
11
720
Consensus: An Introduction to Raft
vanstee
21
3.2k
Convergent Replicated Data Types
vanstee
4
880
Pour Over Brewing Method
vanstee
1
430
Map Reduce & Ruby
vanstee
10
920
Other Decks in Programming
See All in Programming
使用 Meilisearch 建立新聞搜尋工具
johnroyer
0
200
信頼性について考えてみる(SRE NEXT 2026 miniLT)
hayama17
0
240
Android CLI
fornewid
0
200
なぜ関数型プログラミングで「型」と「証明」が語られるのか #fp_matsuri
kajitack
3
1.1k
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
3
730
全PRの83%がAIレビューだけでマージできるようになった開発組織はその後どうなったか
athug
0
1.1k
What's New in Android 2026
veronikapj
0
240
5分で問診!Composer セキュリティ健康診断
codmoninc
0
780
自動化したのに回らないテスト運用の壁ーAI時代の品質責任と生産性
mfunaki
0
120
AIエージェントで 変わるAndroid開発環境
takahirom
2
760
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
420
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
490
Featured
See All Featured
Making Projects Easy
brettharned
120
6.7k
Are puppies a ranking factor?
jonoalderson
1
3.7k
Between Models and Reality
mayunak
4
380
Designing for Timeless Needs
cassininazir
1
430
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
Code Review Best Practice
trishagee
74
20k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Optimising Largest Contentful Paint
csswizardry
37
3.9k
Ruling the World: When Life Gets Gamed
codingconduct
0
290
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
680
Java REST API Framework Comparison - PWX 2021
mraible
34
9.6k
HDC tutorial
michielstock
2
760
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