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
Design for Retry (Oneshot Budapest)
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Aria Stewart
November 21, 2014
Programming
0
65
Design for Retry (Oneshot Budapest)
Aria Stewart
November 21, 2014
Tweet
Share
More Decks by Aria Stewart
See All by Aria Stewart
Nuts and Bolts of Internationalization
aredridel
0
220
Design for Retry (Nodevember)
aredridel
0
55
Other Decks in Programming
See All in Programming
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
200
AIで開発はどれくらい加速したのか?AIエージェントによるコード生成を、現場の評価と研究開発の評価の両面からdeep diveしてみる
daisuketakeda
1
2.5k
「ブロックテーマでは再現できない」は本当か?
inc2734
0
1k
SourceGeneratorのススメ
htkym
0
200
Architectural Extensions
denyspoltorak
0
290
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
460
ノイジーネイバー問題を解決する 公平なキューイング
occhi
0
110
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
7.4k
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
Package Management Learnings from Homebrew
mikemcquaid
0
230
【卒業研究】会話ログ分析によるユーザーごとの関心に応じた話題提案手法
momok47
0
200
Fluid Templating in TYPO3 14
s2b
0
130
Featured
See All Featured
Rails Girls Zürich Keynote
gr2m
96
14k
Odyssey Design
rkendrick25
PRO
1
500
Typedesign – Prime Four
hannesfritz
42
2.9k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Designing for Timeless Needs
cassininazir
0
130
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
170
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.6k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.7k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
70
ラッコキーワード サービス紹介資料
rakko
1
2.3M
Transcript
Design for Retry: Microservices, REST, and why Idempotency is the
only way to scale I'm Aria Stewart, that's @aredridel just about everywhere. I'm here thanks to PayPal. I work on the open source Kraken.js framework.
I'm going to talk about errors. It's going to be
okay.
if (err) { alert(err.message); } else { doMyThing(); }
We all know HTTP
2xx OK 3xx Go elsewhere 4xx Tell user what they
did wrong 5xx Bail out and log an error I'd call this Error avoidance
You can't avoid errors
Here's the secret Handle errors instead
4xx Tell the user what they did wrong 5xx Save
that request and do something with it later.
Retry it 5xx are errors the requestor can handle
But you can't just do things twice? We must make
operations idempotent
Idempotency Repeated actions have no effect, give the same result
This means being smart about IDs. Don't recycle! Check if things are already done. They are? Just give the same answer again.
Causes! —database down —bug in a service —Deploy in progress
—power failure —kicked a cable —Network congestion —Capacity exceeded —Microbursts
—Tree fell on the data center —earthquake —tornado —birds, snakes
and aeroplanes —Black Friday —Slashdot effect —Interns —QA tests —DoS attack
You need a queue
Lots of ways to do it Database on each node.
Maybe LevelDB? Log file Queue server
gearman Queues built in There are many alternatives, but gearmand
is very simple. The memcache of job queues.
Three statuses: —OK (Like 200) —FAIL (Like 400) —ERROR (Like
500)
design so ERROR can be retried.
gearmand automatically tries a job ERROR again. And again. And
again.
If it isn't sure it worked? Tries it again.
You cannot know if an error is a failure.
Error handling gets simpler —Exception? ERROR. —Database down? ERROR. —Downstream
service timeout? ERROR. Maybe you retry right away.
How many of you have used a job queue?
You have used a job queue
Let me tell you about one TRILLIONS of messages MILLIONS
of nodes 100% availability (at least partial) for years. 32 years. Resilient to MILLIONS of bad actors. It is attached to the most malicious network.
EMAIL. 250 OK 4xx RETRY 5xx Fail
Responsibility for messages 250 - accept responsibility 4xx - reject
responsibility 5xx - return responsibility
reject responsibility. If there's an error? Fail fast. The requester
can retry.
Fail fast. Queue work you can't reject. Reject everything you
can if there is an error.
You need a smart client. Keeps outstanding requests. Resubmit. Try
a different server! Try a second queue service. Maybe have a fallback plan.
Smart Clients on the device Toto, we're not in AWS
anymore.
Ever lose an email because you've been logged out?
Latency + Mutable state = Distributed system CAP Theorem Applies!
C = Consistency If there's state that one part knows
of that another doesn't? That's inconsistency.
Job queues are controlled inconsistency.
Ever try to write email on the web while not
on the Internet? It's cloud easy!
This is really good for offline-first design! Being offline is
the ultimate retriable error.
Some ideas
Use your queue as a place to measure for system
sizing
Queue things in localStorage
Use third-party storage
Integrate third-party services with this approach.
Use different strategies for available resources vs contended
Thank you! I hope you have lots of ideas queued
up. Save your ideas and unspool them onto Twitter when you get home. Let me know if this changed how you think about designing applications!