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
Froze middleware talk
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Atul Bhosale
July 29, 2017
Technology
0
43
Froze middleware talk
I had given this talk at Deccan Ruby Conf 2017, Pune
Atul Bhosale
July 29, 2017
Tweet
Share
More Decks by Atul Bhosale
See All by Atul Bhosale
Lets enhance ActionCable
atul9
0
57
Mystery of Realtime
atul9
0
45
Other Decks in Technology
See All in Technology
プロポーザルに込める段取り八分
shoheimitani
1
200
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.6k
セキュリティについて学ぶ会 / 2026 01 25 Takamatsu WordPress Meetup
rocketmartue
1
300
We Built for Predictability; The Workloads Didn’t Care
stahnma
0
140
Kiro IDEのドキュメントを全部読んだので地味だけどちょっと嬉しい機能を紹介する
khmoryz
0
180
AI駆動開発を事業のコアに置く
tasukuonizawa
1
140
ブロックテーマでサイトをリニューアルした話 / 2026-01-31 Kansai WordPress Meetup
torounit
0
460
Bill One急成長の舞台裏 開発組織が直面した失敗と教訓
sansantech
PRO
2
350
ZOZOにおけるAI活用の現在 ~開発組織全体での取り組みと試行錯誤~
zozotech
PRO
5
5k
顧客の言葉を、そのまま信じない勇気
yamatai1212
1
350
Greatest Disaster Hits in Web Performance
guaca
0
200
Digitization部 紹介資料
sansan33
PRO
1
6.8k
Featured
See All Featured
Context Engineering - Making Every Token Count
addyosmani
9
650
The SEO Collaboration Effect
kristinabergwall1
0
350
Chasing Engaging Ingredients in Design
codingconduct
0
110
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
How to train your dragon (web standard)
notwaldorf
97
6.5k
How GitHub (no longer) Works
holman
316
140k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
170
So, you think you're a good person
axbom
PRO
2
1.9k
GraphQLの誤解/rethinking-graphql
sonatard
74
11k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
380
Writing Fast Ruby
sferik
630
62k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
56
Transcript
ATUL BHOSALE CODEMANCERS @atul1b
None
Rack middleware
None
1 5 4 3 2 Web Requests
None
None
WHY?
# Non Thread safe code class Counter def initialize @counter
= 0 end def call(_env) counter = @counter sleep 1 counter += 1 @counter = counter [200, { 'Content-Type' => 'text/html' }, ["#{@counter}"]] end end
WHAT? • Don’t mutate state • Freeze middleware instances •
Use data-structures from concurrent-ruby
None
# Thread safe code class Counter def initialize @atomic =
Concurrent::AtomicReference.new(0) end def call(_env) @atomic.update { |v| v + 1 } [200, { 'Content-Type' => 'text/html' }, ["{@atomic}"]] end end
None
None
None
use (Class.new do def call(env) @a = 1 if env['PATH_INFO']
== '/a' @app.call(env) end freeze_app end)
There is no way to unfreeze a frozen object
Thank you
None