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
590
4
Share
Celluloid & DCell
Patrick Van Stee
July 11, 2012
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
990
Bootstrap
vanstee
8
830
HTTP API Design for iOS Applications
vanstee
11
690
Consensus: An Introduction to Raft
vanstee
21
3.1k
Convergent Replicated Data Types
vanstee
4
850
Pour Over Brewing Method
vanstee
1
400
Map Reduce & Ruby
vanstee
10
880
Other Decks in Programming
See All in Programming
AIエージェントで業務改善してみた
taku271
0
490
Go_College_最終発表資料__外部公開用_.pdf
xe_pc23
0
130
Codex CLI でつくる、Issue から merge までの開発フロー
amata1219
0
330
ドメインイベントでビジネスロジックを解きほぐす #phpcon_odawara
kajitack
2
110
テレメトリーシグナルが導くパフォーマンス最適化 / Performance Optimization Driven by Telemetry Signals
seike460
PRO
2
220
PHP でエミュレータを自作して Ubuntu を動かそう
m3m0r7
PRO
2
170
3分でわかるatama plusのQA/about atama plus QA
atamaplus
0
110
Strategy for Finding a Problem for OSS: With Real Examples
kibitan
0
140
Don't Prompt Harder, Structure Better
kitasuke
0
380
AI時代の脳疲弊と向き合う ~言語学としてのPHP~
sakuraikotone
1
1.8k
PHPで TLSのプロトコルを実装してみるをもう一度しゃべりたい
higaki_program
0
180
それはエンジニアリングの糧である:AI開発のためにAIのOSSを開発する現場より / It serves as fuel for engineering: insights from the field of developing open-source AI for AI development.
nrslib
1
830
Featured
See All Featured
The browser strikes back
jonoalderson
0
900
Producing Creativity
orderedlist
PRO
348
40k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
130
The Mindset for Success: Future Career Progression
greggifford
PRO
0
300
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.2k
Believing is Seeing
oripsolob
1
110
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1k
The agentic SEO stack - context over prompts
schlessera
0
730
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
510
sira's awesome portfolio website redesign presentation
elsirapls
0
210
The Cost Of JavaScript in 2023
addyosmani
55
9.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