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
500
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.7k
Elixir and Ecto
vanstee
5
860
Bootstrap
vanstee
8
730
HTTP API Design for iOS Applications
vanstee
11
570
Consensus: An Introduction to Raft
vanstee
22
2.8k
Convergent Replicated Data Types
vanstee
4
700
Pour Over Brewing Method
vanstee
1
310
Map Reduce & Ruby
vanstee
10
730
Other Decks in Programming
See All in Programming
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
500
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
220
どうして手を動かすよりもチーム内のコードレビューを優先するべきなのか
okashoi
3
280
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
890
フロントエンドのディレクトリ構成どうしてる? Feature-Sliced Design 導入体験談
osakatechlab
8
4.1k
Jakarta EE meets AI
ivargrimstad
0
260
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
150
return文におけるstd::moveについて
onihusube
1
1.2k
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
140
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
190
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
420
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.6k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Learning to Love Humans: Emotional Interface Design
aarron
274
40k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Producing Creativity
orderedlist
PRO
342
39k
Statistics for Hackers
jakevdp
796
220k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
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