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
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
970
Bootstrap
vanstee
8
810
HTTP API Design for iOS Applications
vanstee
11
660
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
860
Other Decks in Programming
See All in Programming
脳の「省エネモード」をデバッグする ~System 1(直感)と System 2(論理)の切り替え~
panda728
PRO
0
130
2年のAppleウォレットパス開発の振り返り
muno92
PRO
0
180
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
270
クラウドに依存しないS3を使った開発術
simesaba80
0
220
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
3
1k
AI 駆動開発ライフサイクル(AI-DLC):ソフトウェアエンジニアリングの再構築 / AI-DLC Introduction
kanamasa
11
5.3k
AI Agent Tool のためのバックエンドアーキテクチャを考える #encraft
izumin5210
6
1.6k
Basic Architectures
denyspoltorak
0
200
副作用をどこに置くか問題:オブジェクト指向で整理する設計判断ツリー
koxya
1
400
【卒業研究】会話ログ分析によるユーザーごとの関心に応じた話題提案手法
momok47
0
170
dchart: charts from deck markup
ajstarks
3
960
生成AI時代を勝ち抜くエンジニア組織マネジメント
coconala_engineer
0
39k
Featured
See All Featured
The World Runs on Bad Software
bkeepers
PRO
72
12k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
First, design no harm
axbom
PRO
2
1.1k
Fireside Chat
paigeccino
41
3.8k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
0
2.3k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.4k
Side Projects
sachag
455
43k
Abbi's Birthday
coloredviolet
0
4.3k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.3k
Optimizing for Happiness
mojombo
379
70k
Stop Working from a Prison Cell
hatefulcrawdad
273
21k
ラッコキーワード サービス紹介資料
rakko
0
2M
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