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
orange — Client side concurrency made simple
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Florian Plank
October 17, 2013
Programming
160
0
Share
orange — Client side concurrency made simple
Florian Plank
October 17, 2013
More Decks by Florian Plank
See All by Florian Plank
Ready, set, immersion!
polarblau
0
220
Prototyping all the things
polarblau
2
190
CoffeeScript vs. ECMAScript 6
polarblau
5
3.7k
Design for a complex Reality — Siili Breakfast Edition
polarblau
0
170
Enabling Design for a Complex Reality
polarblau
2
150
A primer on Content Security Policy
polarblau
1
460
Rails and the future of the open web
polarblau
3
150
Brief Ruby/Ruby on Rails intro
polarblau
3
210
Ruby Idioms
polarblau
3
620
Other Decks in Programming
See All in Programming
CSC307 Lecture 17
javiergs
PRO
0
280
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
210
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
2.1k
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
11
3.1k
Oxlintのカスタムルールの現況
syumai
5
900
3Dシーンの圧縮
fadis
1
530
RailsTokyo 2026#4: AI様があれば、 Hotwireの弱点は消えるか?
naofumi
5
1k
AIエージェントの隔離技術の徹底比較
kawayu
0
440
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
11k
inferと仲良くなる10分間
ryokatsuse
1
280
AIチームを指揮するOSS「TAKT」活用術 / How to Use “TAKT,” an OSS Tool for Orchestrating AI Teams
nrslib
6
750
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
1
530
Featured
See All Featured
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
580
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
160
Google's AI Overviews - The New Search
badams
0
1k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
230
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
200
Bash Introduction
62gerente
615
210k
My Coaching Mixtape
mlcsv
0
140
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
1
130
Building Adaptive Systems
keathley
44
3k
Design in an AI World
tapps
1
220
Embracing the Ebb and Flow
colly
88
5.1k
Transcript
orange — Client side concurrency made simple
rubysauna.org
heartrate.js
None
None
None
None
Concurrency
A B C
A B C
A B C
Concurrency is hard
A B C
Concurrency
Barber z z
Barber Customer z z Sleeping?
Barber Customer
Barber Customer Working?
Barber Customer
Barber
Barber Customer
Barber
Barber Customer ?
Barber Customer Crap.
Barber
Barber Customer
Barber z z Crap.
Concurrency in the browser
JavaScript and the golden thread
None
None
None
foo() 10ms 20ms 30ms 40ms click handled click fired setInterval
(10ms)
None
Synchronous —vs— Asynchronous
WebWorkers
JavaScript Thread Worker
Worker JavaScript Thread
Worker Worker JavaScript Thread
Dedicated, Shared & Inline Workers
None
orange
The queue
Define a worker
# workers/sum.coffee importScripts 'orange/worker.js' perform (data)-> data.numbers.reduce (a, b)-> a
+ b
# workers/sum.coffee importScripts 'orange/worker.js' perform (data)-> data.numbers.reduce (a, b)-> a
+ b
Create a new job
job = new Orange.Job('sum', numbers: [1..100])
job = new Orange.Job('sum', numbers: [1..100]) job.on 'success', (response) ->
console.log('Sum', response) job.perform()
Events
job.on 'success', (response)-> job.on 'complete', -> job.on 'error', (error)-> job.on
'failure', (error)->
Logging
# workers/sum.coffee importScripts 'orange/worker.js' perform (data)-> log 'The background worker
Gotham deserves ...' data.numbers.reduce (a, b) ->a + b
Batches
batch = new Orange.Batch
batch = new Orange.Batch job = new Orange.Job('sum', [1..100]) batch.push
job batch.perform()
batch = new Orange.Batch [job1, job2, job3]
batch.on 'complete', (jobs) -> batch.on 'job:success', (job) -> batch.on 'job:complete',
(job)-> batch.on 'job:error', (job) -> batch.on 'job:failure', (job) ->
job.getResponse() job.getLastError()
Configuration
Orange.Config.set maxWorkerPoolSize: 4 maxRetries : 3 workersPath : '/lib/workers/'
Retry mechanism and exponential back–off
Error handling
job.on 'error', (error)-> throw error BatchStateTransitionError JobStateTransitionError ResponderNotFoundError …
None
Roadmap >0.2.0
Customized Worker Shim Test coverage Data serialization Benchmarking
Forward arbitrary method calls to worker? Custom events? Instrumentation? Inline
Workers? Helper modules?
Kiitos!
@polarblau