SlideShare a Scribd company logo
1 of 78
Download to read offline
Handle API Failure gracefully
with Circuit Breakers
Scott Triglia
1
Jim’s
2
Yelp’s Mission:
Connecting people with great
local businesses.
Yelp Stats
As of Q2 2016
92M
monthly
users
32
countries
72% of
searches from
mobile
108M reviews
Scott Triglia
4
@scott_triglia
Work with the $$$
Let’s talk Circuit Breakers
5
6
7
8Photo by zerial, CC BY-NC 2.0
9
10
Our goals today:
introduce a basic circuit breaker
11
Our goals today:
a modular circuit breaker
12
Our goals today:
test it out on several scenarios
13
14
15
1616
1
2
3
4
the fundamental rule:
your systems will fail
what’s your response?
17
1818
1
2
1919
1
2
3
2020
1
2
3
4
21
Nygard’s circuit breaker
22
23
24
25
26
Circuit Breaker States:
* Healthy (or “closed”)
* Recovering (or “half-open”)
* Unhealthy (or “open”)
27
28
Recovery:
* Wait for recovery_timeout seconds
* Send a trial request, trust its results
29
Before a circuit breaker
30
Assume the kitchen gets slow
31
Kitchen’s backlog grows
32
Diners wait much longer to get food
33
New diners make issues worse
34
And your entire system collapses
35
And your entire system collapses
36
With a circuit breaker
37
CB sees backlog, stops orders
38
Fewer frustrated diners
39
Reduced load on the kitchen
40
A well defined failure mode
41
How can we do better?
42
Improvements
43
1) Detecting Unhealthiness
44
2) Mitigating downtime
45
3) Recovering Effectively
46
Detecting Unhealthiness
Component 1:
47
48
def signal_overload(cb):
if len(jobs) > THRESH:
cb.mark_unhealthy()
49
New Behavior:
* CB gets signals from anywhere
* Signal combining logic
50
* Allows many (many) new signals
* Must combine signals
* Adds complexity to system
51
Mitigating Downtime
Component 2:
52
53
54
55
56
New Behavior:
* Code can check in advance about
healthiness of system
* Automatic monitoring!
57
* Build features on top of system
health status
* Requires a single source of truth?
58
Recovering Effectively
Component 3:
59
60
Dark launch:
* Reject but process normally
* Dangerous with side effects
Block User
Request
Try to process anyway!
61
Synthetic:
* Dark launching with fake requests
* Not necessarily representative
Block User
Request
Process fake requests
62
New Behavior:
* Traffic determines health
* Removal of recovery timeouts
63
* Faster(?) recovery
* No timeout tuning required
* Dark launching not always possible
* Synthetic can be unrepresentative
64
in summary
65
Your system will fail, have a plan!
66
The basic CB is better than nothing
67
Questions to ask:
* What is “unhealthy” for my system?
* How should I react to unhealthiness?
* How do we recover?
68
Questions to ask:
* What is “unhealthy” for my system?
* How should I react to unhealthiness?
* How do we recover?
69
Questions to ask:
* What is “unhealthy” for my system?
* How should I react to unhealthiness?
* How do we recover?
70
Questions to ask:
* What is “unhealthy” for my system?
* How should I react to unhealthiness?
* How do we recover?
71
…and much more!
Much comes down to your use case
72
@YelpEngineering
fb.com/YelpEngineers
engineeringblog.yelp.com
github.com/yelp
striglia@yelp.com
@scott_triglia
75
Can’t we do better than
rejecting requests?
http://techblog.netflix.com/2011/12/
making-netflix-api-more-resilient.html
77
How do I safely test out a
new circuit breaker?
https://engineering.heroku.com/blogs/
2015-06-30-improved-production-
stability-with-circuit-breakers/

More Related Content

Similar to Handle API Failure with Circuit Breakers

2018 Update in Diabetes Technology: Closed Loop, CGM, and More
2018 Update in Diabetes Technology: Closed Loop, CGM, and More2018 Update in Diabetes Technology: Closed Loop, CGM, and More
2018 Update in Diabetes Technology: Closed Loop, CGM, and MoreAaron Neinstein
 
Alarm System for Medicine Reminder Based on Microcontroller
Alarm System for Medicine Reminder Based on MicrocontrollerAlarm System for Medicine Reminder Based on Microcontroller
Alarm System for Medicine Reminder Based on Microcontrollerijtsrd
 
Safe staffing and productivity through use of technology and professional jud...
Safe staffing and productivity through use of technology and professional jud...Safe staffing and productivity through use of technology and professional jud...
Safe staffing and productivity through use of technology and professional jud...NHS England
 
Using Artificial Intelligence in the field of Diagnostics_Case Studies.ppt
Using Artificial Intelligence in the field of Diagnostics_Case Studies.pptUsing Artificial Intelligence in the field of Diagnostics_Case Studies.ppt
Using Artificial Intelligence in the field of Diagnostics_Case Studies.pptRohanBorgalli
 
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)Andrey Karpov
 
UTC Telecom & Technology 2015 - Battery Backup Workshop
UTC Telecom & Technology 2015 - Battery Backup WorkshopUTC Telecom & Technology 2015 - Battery Backup Workshop
UTC Telecom & Technology 2015 - Battery Backup WorkshopDakx Turcotte
 
The Selfish Stack [FutureStack16 NYC]
The Selfish Stack [FutureStack16 NYC]The Selfish Stack [FutureStack16 NYC]
The Selfish Stack [FutureStack16 NYC]New Relic
 
Vemma World ! 2010
Vemma World ! 2010Vemma World ! 2010
Vemma World ! 2010Gloria85
 
Monitoring Complex Systems - Chicago Erlang, 2014
Monitoring Complex Systems - Chicago Erlang, 2014Monitoring Complex Systems - Chicago Erlang, 2014
Monitoring Complex Systems - Chicago Erlang, 2014Brian Troutwine
 
Making the Smart Home More Insightful
Making the Smart Home More InsightfulMaking the Smart Home More Insightful
Making the Smart Home More InsightfulVectorform
 
Acc 281 Education Organization -- snaptutorial.com
Acc 281   Education Organization -- snaptutorial.comAcc 281   Education Organization -- snaptutorial.com
Acc 281 Education Organization -- snaptutorial.comDavisMurphyB52
 
Consumer Perception of Job Seekers in updating their Job Profiles on Job Portals
Consumer Perception of Job Seekers in updating their Job Profiles on Job PortalsConsumer Perception of Job Seekers in updating their Job Profiles on Job Portals
Consumer Perception of Job Seekers in updating their Job Profiles on Job PortalsNeil Mathew
 

Similar to Handle API Failure with Circuit Breakers (15)

Mathworks CAE simulation suite – case in point from automotive and aerospace.
Mathworks CAE simulation suite – case in point from automotive and aerospace.Mathworks CAE simulation suite – case in point from automotive and aerospace.
Mathworks CAE simulation suite – case in point from automotive and aerospace.
 
Faultdec
FaultdecFaultdec
Faultdec
 
2018 Update in Diabetes Technology: Closed Loop, CGM, and More
2018 Update in Diabetes Technology: Closed Loop, CGM, and More2018 Update in Diabetes Technology: Closed Loop, CGM, and More
2018 Update in Diabetes Technology: Closed Loop, CGM, and More
 
Alarm System for Medicine Reminder Based on Microcontroller
Alarm System for Medicine Reminder Based on MicrocontrollerAlarm System for Medicine Reminder Based on Microcontroller
Alarm System for Medicine Reminder Based on Microcontroller
 
Safe staffing and productivity through use of technology and professional jud...
Safe staffing and productivity through use of technology and professional jud...Safe staffing and productivity through use of technology and professional jud...
Safe staffing and productivity through use of technology and professional jud...
 
Using Artificial Intelligence in the field of Diagnostics_Case Studies.ppt
Using Artificial Intelligence in the field of Diagnostics_Case Studies.pptUsing Artificial Intelligence in the field of Diagnostics_Case Studies.ppt
Using Artificial Intelligence in the field of Diagnostics_Case Studies.ppt
 
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
 
UTC Telecom & Technology 2015 - Battery Backup Workshop
UTC Telecom & Technology 2015 - Battery Backup WorkshopUTC Telecom & Technology 2015 - Battery Backup Workshop
UTC Telecom & Technology 2015 - Battery Backup Workshop
 
The Selfish Stack [FutureStack16 NYC]
The Selfish Stack [FutureStack16 NYC]The Selfish Stack [FutureStack16 NYC]
The Selfish Stack [FutureStack16 NYC]
 
Vemma World ! 2010
Vemma World ! 2010Vemma World ! 2010
Vemma World ! 2010
 
Monitoring Complex Systems - Chicago Erlang, 2014
Monitoring Complex Systems - Chicago Erlang, 2014Monitoring Complex Systems - Chicago Erlang, 2014
Monitoring Complex Systems - Chicago Erlang, 2014
 
Making the Smart Home More Insightful
Making the Smart Home More InsightfulMaking the Smart Home More Insightful
Making the Smart Home More Insightful
 
Making the Smart Home More Insightful
Making the Smart Home More InsightfulMaking the Smart Home More Insightful
Making the Smart Home More Insightful
 
Acc 281 Education Organization -- snaptutorial.com
Acc 281   Education Organization -- snaptutorial.comAcc 281   Education Organization -- snaptutorial.com
Acc 281 Education Organization -- snaptutorial.com
 
Consumer Perception of Job Seekers in updating their Job Profiles on Job Portals
Consumer Perception of Job Seekers in updating their Job Profiles on Job PortalsConsumer Perception of Job Seekers in updating their Job Profiles on Job Portals
Consumer Perception of Job Seekers in updating their Job Profiles on Job Portals
 

Recently uploaded

SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 

Recently uploaded (20)

Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 

Handle API Failure with Circuit Breakers