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
560
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
7.2k
Elixir and Ecto
vanstee
5
950
Bootstrap
vanstee
8
800
HTTP API Design for iOS Applications
vanstee
11
640
Consensus: An Introduction to Raft
vanstee
21
3k
Convergent Replicated Data Types
vanstee
4
780
Pour Over Brewing Method
vanstee
1
360
Map Reduce & Ruby
vanstee
10
820
Other Decks in Programming
See All in Programming
スキーマ駆動で、Zod OpenAPI Honoによる、API開発するために、Hono Takibiというライブラリを作っている
nakita628
0
290
CSC509 Lecture 08
javiergs
PRO
0
230
Google Opalで使える37のライブラリ
mickey_kubo
3
130
EMこそClaude Codeでコード調査しよう
shibayu36
0
290
Goで実践するドメイン駆動開発 AIと歩み始めた新規プロダクト開発の現在地
imkaoru
4
870
大規模アプリのDIフレームワーク刷新戦略 ~過去最大規模の並行開発を止めずにアプリ全体に導入するまで~
mot_techtalk
1
470
フロントエンド開発のためのブラウザ組み込みAI入門
masashi
7
3.3k
開発生産性を上げるための生成AI活用術
starfish719
3
1.6k
なぜあの開発者はDevRelに伴走し続けるのか / Why Does That Developer Keep Running Alongside DevRel?
nrslib
3
410
「ちょっと古いから」って避けてた技術書、今だからこそ読もう
mottyzzz
11
7k
Building, Deploying, and Monitoring Ruby Web Applications with Falcon (Kaigi on Rails 2025)
ioquatix
4
2.4k
Introduce Hono CLI
yusukebe
6
3k
Featured
See All Featured
Done Done
chrislema
185
16k
Statistics for Hackers
jakevdp
799
220k
How to Ace a Technical Interview
jacobian
280
24k
Git: the NoSQL Database
bkeepers
PRO
431
66k
Code Review Best Practice
trishagee
72
19k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
253
22k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
Building an army of robots
kneath
306
46k
4 Signs Your Business is Dying
shpigford
185
22k
The Invisible Side of Design
smashingmag
302
51k
Code Reviewing Like a Champion
maltzj
526
40k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
920
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