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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
CSC307 Lecture 02
javiergs
PRO
1
770
Grafana:建立系統全知視角的捷徑
blueswen
0
330
CSC307 Lecture 05
javiergs
PRO
0
500
今こそ知るべき耐量子計算機暗号(PQC)入門 / PQC: What You Need to Know Now
mackey0225
3
370
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
450
MUSUBIXとは
nahisaho
0
130
Fluid Templating in TYPO3 14
s2b
0
130
16年目のピクシブ百科事典を支える最新の技術基盤 / The Modern Tech Stack Powering Pixiv Encyclopedia in its 16th Year
ahuglajbclajep
5
1k
Architectural Extensions
denyspoltorak
0
280
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
430
Patterns of Patterns
denyspoltorak
0
1.4k
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
170
Featured
See All Featured
Writing Fast Ruby
sferik
630
62k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
160
Joys of Absence: A Defence of Solitary Play
codingconduct
1
290
Ruling the World: When Life Gets Gamed
codingconduct
0
140
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.2k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
320
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
6.9k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
57
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
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