Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Froze middleware talk
Search
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
AI-DLCを現場にインストールしてみた:プロトタイプ開発で分かったこと・やめたこと
recruitengineers
PRO
2
220
mairuでつくるクレデンシャルレス開発環境 / Credential-less development environment using Mailru
mirakui
5
580
AWSに革命を起こすかもしれない新サービス・アップデートについてのお話
yama3133
0
450
IAMユーザーゼロの運用は果たして可能なのか
yama3133
2
520
CARTAのAI CoE が挑む「事業を進化させる AI エンジニアリング」 / carta ai coe evolution business ai engineering
carta_engineering
0
2.2k
AI時代の新規LLMプロダクト開発: Findy Insightsを3ヶ月で立ち上げた舞台裏と振り返り
dakuon
0
380
コンテキスト情報を活用し個社最適化されたAI Agentを実現する4つのポイント
kworkdev
PRO
1
1.8k
さくらのクラウド開発ふりかえり2025
kazeburo
2
180
アプリにAIを正しく組み込むための アーキテクチャ── 国産LLMの現実と実践
kohju
0
170
100以上の新規コネクタ提供を可能にしたアーキテクチャ
ooyukioo
0
210
Oracle Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
1
340
フィッシュボウルのやり方 / How to do a fishbowl
pauli
2
340
Featured
See All Featured
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
57
37k
Raft: Consensus for Rubyists
vanstee
141
7.2k
Fireside Chat
paigeccino
41
3.8k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
62
Making Projects Easy
brettharned
120
6.5k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.1k
Designing Experiences People Love
moore
143
24k
Into the Great Unknown - MozCon
thekraken
40
2.2k
Building the Perfect Custom Keyboard
takai
1
660
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
120
Highjacked: Video Game Concept Design
rkendrick25
PRO
0
240
The Art of Programming - Codeland 2020
erikaheidi
56
14k
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