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
480
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
136
6.6k
Elixir and Ecto
vanstee
5
830
Bootstrap
vanstee
8
710
HTTP API Design for iOS Applications
vanstee
11
550
Consensus: An Introduction to Raft
vanstee
22
2.8k
Convergent Replicated Data Types
vanstee
4
680
Pour Over Brewing Method
vanstee
1
290
Map Reduce & Ruby
vanstee
10
700
Other Decks in Programming
See All in Programming
Integrating AI in Your Enterprise Java Applications
ivargrimstad
0
950
CSC509 Lecture 04
javiergs
PRO
0
170
Vue3の一歩踏み込んだパフォーマンスチューニング2024
hal_spidernight
3
2.4k
モジュラモノリス、その前に / Modular monolith, before that
euglena1215
8
750
ActiveRecordの力でDBのメタデータを迅速に解析する
lnit
5
2.1k
破壊せよ!データ破壊駆動で考えるドメインモデリング / data-destroy-driven
minodriven
4
430
Kaigi on Rails 2024 - Rails APIモードのためのシンプルで効果的なCSRF対策 / kaigionrails-2024-csrf
corocn
1
240
gopls を改造したら開発生産性が高まった
satorunooshie
7
140
Kubernetes for Data Engineers: Building Scalable, Reliable Data Pipelines
sucitw
1
110
go.mod、DockerfileやCI設定に分散しがちなGoのバージョンをまとめて管理する / Go Connect #3
arthur1
5
1.6k
Vue SFCのtemplateでTypeScriptの型を活用しよう
tsukkee
3
1.2k
Server Driven Compose With Firebase
skydoves
0
190
Featured
See All Featured
Bash Introduction
62gerente
608
210k
10 Git Anti Patterns You Should be Aware of
lemiorhan
653
59k
Practical Orchestrator
shlominoach
186
10k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.6k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
92
16k
Into the Great Unknown - MozCon
thekraken
31
1.4k
Building an army of robots
kneath
302
42k
Optimising Largest Contentful Paint
csswizardry
31
2.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
GraphQLとの向き合い方2022年版
quramy
43
13k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
The Language of Interfaces
destraynor
154
24k
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