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.4k
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
850
Pour Over Brewing Method
vanstee
1
390
Map Reduce & Ruby
vanstee
10
880
Other Decks in Programming
See All in Programming
Windows on Ryzen and I
seosoft
0
300
最初からAWS CDKで技術検証してもいいんじゃない?
akihisaikeda
4
150
Fundamentals of Software Engineering In the Age of AI
therealdanvega
1
260
20260315 AWSなんもわからん🥲
chiilog
2
160
ふつうの Rubyist、ちいさなデバイス、大きな一年
bash0c7
0
970
Swift ConcurrencyでよりSwiftyに
yuukiw00w
0
270
nuget-server - あなたが必要だったNuGetサーバー
kekyo
PRO
0
260
RAGでハマりがちな"Excelの罠"を、データの構造化で突破する
harumiweb
9
2.9k
new(1.26) ← これすき / kamakura.go #8
utgwkk
0
2.3k
PostgreSQL を使った快適な go test 環境を求めて
otakakot
0
560
オブザーバビリティ駆動開発って実際どうなの?
yohfee
3
850
Angular-Apps smarter machen mit Gen AI: Lokal und offlinefähig - Hands-on Workshop!
christianliebel
PRO
0
120
Featured
See All Featured
A better future with KSS
kneath
240
18k
We Are The Robots
honzajavorek
0
200
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
190
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
640
Mind Mapping
helmedeiros
PRO
1
120
Design in an AI World
tapps
0
170
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
160
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
60
42k
Darren the Foodie - Storyboard
khoart
PRO
3
2.9k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
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