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
Florian Plank
October 17, 2013
Programming
0
140
orange — Client side concurrency made simple
Florian Plank
October 17, 2013
Tweet
Share
More Decks by Florian Plank
See All by Florian Plank
Ready, set, immersion!
polarblau
0
160
Prototyping all the things
polarblau
2
150
CoffeeScript vs. ECMAScript 6
polarblau
5
3.4k
Design for a complex Reality — Siili Breakfast Edition
polarblau
0
120
Enabling Design for a Complex Reality
polarblau
2
120
A primer on Content Security Policy
polarblau
1
370
Rails and the future of the open web
polarblau
3
110
Brief Ruby/Ruby on Rails intro
polarblau
3
160
Ruby Idioms
polarblau
3
550
Other Decks in Programming
See All in Programming
Fixstars高速化コンテスト2024準優勝解法
eijirou
0
190
知られざるDMMデータエンジニアの生態 〜かつてツチノコと呼ばれし者〜
takaha4k
1
470
shadcn/uiを使ってReactでの開発を加速させよう!
lef237
0
300
Beyond ORM
77web
11
1.6k
Amazon Nova Reelの可能性
hideg
0
200
良いユニットテストを書こう
mototakatsu
11
3.6k
ecspresso, ecschedule, lambroll を PipeCDプラグインとして動かしてみた (プロトタイプ) / Running ecspresso, ecschedule, and lambroll as PipeCD Plugins (prototype)
tkikuc
2
1.9k
Alba: Why, How and What's So Interesting
okuramasafumi
0
210
いりゃあせ、PHPカンファレンス名古屋2025 / Welcome to PHP Conference Nagoya 2025
ttskch
1
190
GitHub CopilotでTypeScriptの コード生成するワザップ
starfish719
26
6k
React 19でお手軽にCSS-in-JSを自作する
yukukotani
5
570
ドメインイベント増えすぎ問題
h0r15h0
2
570
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.6k
GraphQLの誤解/rethinking-graphql
sonatard
68
10k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
570
The World Runs on Bad Software
bkeepers
PRO
66
11k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
19
2.3k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
52k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.4k
Writing Fast Ruby
sferik
628
61k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
39
1.9k
Docker and Python
trallard
43
3.2k
VelocityConf: Rendering Performance Case Studies
addyosmani
327
24k
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