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
440
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
134
6.5k
Elixir and Ecto
vanstee
5
780
Bootstrap
vanstee
8
690
HTTP API Design for iOS Applications
vanstee
11
520
Consensus: An Introduction to Raft
vanstee
22
2.7k
Convergent Replicated Data Types
vanstee
4
640
Pour Over Brewing Method
vanstee
1
270
Map Reduce & Ruby
vanstee
10
660
Other Decks in Programming
See All in Programming
Microservices rules (July 2024) : what good looks like
cer
PRO
0
1.6k
生成AIをkintoneに連携してみた
hideg
0
230
12年前の『型システム入門』翻訳の思い出話
mame
11
1.2k
企業向け生成AIアプリの 開発から得られた知見
takaakikakei
0
310
日付と正規化
megmogmog1965
0
140
TiDB Serverless ~理想のServerless DBを考える~
soso_15315
1
160
Javaの現状2024夏 / Java current status 2024 summer
kishida
4
1.4k
ドメイン駆動設計の実践
masuda220
PRO
17
5.1k
SRE チーム立ち上げ前に考えたこと・取り組んだこと / Considerations and Preparations Before Establishing an SRE Team
mackey0225
3
320
[After Kotlin Fest 2024 LT Night @ Sansan] もっともっとKotlinを好きになる!K2 Compiler Pluginで遊んでみよう!
kitakkun
2
260
Product Management LT会_クアンド新家
shinshin
0
210
みんなのオブザーバビリティプラットフォームを作ってるんだがパフォーマンスがやばい #mackerelio #srenext
ne_sachirou
0
370
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
48
13k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
17
8.7k
Speed Design
sergeychernyshev
9
270
Leading Effective Engineering Teams 2024
addyosmani
3
300
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
12
3.8k
The MySQL Ecosystem @ GitHub 2015
samlambert
248
12k
Fireside Chat
paigeccino
25
2.8k
Navigating Team Friction
lara
181
13k
A better future with KSS
kneath
231
17k
How GitHub (no longer) Works
holman
305
140k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
17
1.5k
VelocityConf: Rendering Performance Case Studies
addyosmani
321
23k
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