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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Patrick Van Stee
July 11, 2012
Programming
4
580
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.3k
Elixir and Ecto
vanstee
5
980
Bootstrap
vanstee
8
810
HTTP API Design for iOS Applications
vanstee
11
670
Consensus: An Introduction to Raft
vanstee
21
3.1k
Convergent Replicated Data Types
vanstee
4
830
Pour Over Brewing Method
vanstee
1
380
Map Reduce & Ruby
vanstee
10
870
Other Decks in Programming
See All in Programming
AgentCoreとHuman in the Loop
har1101
5
230
AIと一緒にレガシーに向き合ってみた
nyafunta9858
0
190
OCaml 5でモダンな並列プログラミングを Enjoyしよう!
haochenx
0
140
Fragmented Architectures
denyspoltorak
0
150
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
4
270
AIによる開発の民主化を支える コンテキスト管理のこれまでとこれから
mulyu
3
190
Package Management Learnings from Homebrew
mikemcquaid
0
210
dchart: charts from deck markup
ajstarks
3
990
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.9k
そのAIレビュー、レビューしてますか? / Are you reviewing those AI reviews?
rkaga
6
4.5k
Lambda のコードストレージ容量に気をつけましょう
tattwan718
0
120
AIエージェントのキホンから学ぶ「エージェンティックコーディング」実践入門
masahiro_nishimi
5
410
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
Building AI with AI
inesmontani
PRO
1
690
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
110
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
34k
Agile that works and the tools we love
rasmusluckow
331
21k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
77
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
380
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
640
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
0
3.4k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
160
Paper Plane
katiecoart
PRO
0
46k
The agentic SEO stack - context over prompts
schlessera
0
630
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