SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Downloaden Sie, um offline zu lesen
FOR FUN AND PROFIT
R E L I A B I L I T Y
PATTERNS
D E V O P S L I S B O N 1 2 . 0 3 . 2 0 18 

L I S B O N , P O RT U G A L
L U I S M I N E I R O
@voidmaze
WHAT'S THIS?
WHAT ABOUT THIS?
TYPICAL TRAFFIC BURST
What happens when the following operation fails?
Cart cart = restTemplate.getForObject(url, Cart.class);
H A N D L I N G FA U LT S
for (int i = 1; i <= numRetries; i++) {
try {
return restTemplate.getForObject(url, Cart.class);
} catch (RestClientException e) {
LOG.error("failed to get cart", e);
if (i >= numRetries) {
throw e;
}
}
}
R E T RY I N G
We should only retry if the problem is due to
a network failure or server overload
TRANSIENT FAULTS
for (int i = 1; i <= numRetries; i++) {
try {
return restTemplate.getForObject(url, Cart.class);
} catch (RestClientException e) {
LOG.error("failed to get cart", e);
if (i >= numRetries || isNonTransientFault(e)) {
throw e;
}
}
}
B E T T E R R E T RY
EVEN BETTER RET RY
long computeWaitTime(int retryNumber, int maxWaitTime) {
int delay = WAIT_TIME_MULTIPLIER * 2^retryNumber;
return min(maxWaitTime, delay + random.nextInt(delay));
}
...
for (int i = 1; i <= numRetries; i++) {
try {
return restTemplate.getForObject(url, Cart.class);
} catch (RestClientException e) {
LOG.error("failed to get cart", e);
if (i >= numRetries || isNonTransientFault(e)) {
throw e;
}
sleep(computeWaitTime(i, MAX_WAIT_TIME));
}
}
TRUNCATED EXPONENTIAL BACKOFF WITH JITTER
WHEN TRANSIENT FAULTS BECOME PERMANENT
C I R C U I T B R E A K E R PAT T E R N
The circuit breaker pattern can prevent an application from
repeatedly trying to execute an operation that's likely to fail
C I R C U I T B R E A K E R C L O S E D
Closed State

The requests from the application are forwarded to the target
TA R GET
C I R C U I T B R E A K E R C L O S E D
Closed State

The requests from the application are forwarded to the target
TA R GET
C I R C U I T B R E A K E R C L O S E D
Closed State

The requests from the application are forwarded to the target
TA R GET
C I R C U I T B R E A K E R C L O S E D
Closed State

The requests from the application are forwarded to the target
TA R GET
C I R C U I T B R E A K E R O P E N
Open State

The request from the application fails immediately and an
exception is returned to the application.
TA R GET
C I R C U I T B R E A K E R H A L F - O P E N
Half-Open State

A limited number of requests from the application are allowed
to pass through and invoke the operation.
TA R GET
C I R C U I T B R E A K E R H A L F - O P E N
Half-Open State

A limited number of requests from the application are allowed
to pass through and invoke the operation.
TA R GET
C I R C U I T B R E A K E R H A L F - O P E N
Half-Open State

A limited number of requests from the application are allowed
to pass through and invoke the operation.
TA R GET
C I R C U I T B R E A K E R O P E N
Open State

The request from the application fails immediately and an
exception is returned to the application.
TA R GET
private double doSomeMath(int result) {
if(result != 0) {
return 42 / result;
}
return Double.NaN;
}
THE MOST IMPORTANT QUESTION
PRODUCT DETAI L PAG E
PRODUCT DETAI L PAG E
PRODUCT DETAI L PAG E
circuitBreaker.call((url) -> {
for (int i = 1; i <= numRetries; i++) {
try {
return restTemplate.getForObject(url, Product.class);
} catch (RestClientException e) {
LOG.error("failed to get product details", e);
if (i >= numRetries || isNonTransientFault(e)) {
throw e;
}
sleep(computeWaitTime(i, MAX_WAIT_TIME));
}
}
throw new NoMoreRetriesException();
}).fallback(() -> "a Partner");
PUTTING IT ALL TOG ET HER
H A N D S - O N E X E R C I S E
R E T RY
C I R C U I T

BREAKER
FALLBACK
PRODUCT
D E TA I L PA G E
TA R GET
EXERCISE - PR OD UC T D ETA IL PAGE
EXERCISE - PR OD UC T D ETA IL PAGE
B R A N D D ATA
PRO DUCT DATA
WISH LIST
SI ZE RE COMME NDATION
C A R T
D E L I V E RY O P T I O N S
S IZ E SE LE CTO R
EXERCISE - PR OD UC T D ETA IL PAGE
GROUP 2: BR AN D D ATA
GROUP 3: PR OD U C T D ATA
GROUP 4: WISH LIST
GROUP 1: SI ZE R E C OMME NDAT IO N
GROUP 5: C A RT
GROUP 7: D E L I V E RY O P T I O N S
GROUP 6: SI ZE S E LE C TOR
GROUPS TASKS
1.Retries
Retryable operation?
How many times?
2.Circuit breaker
Global circuit breaker?
3.Fail fast
Type of fallback
Delegate to frontend?
2 0
MIN
THANK YOU
QUESTIONS?
WE'RE HIRING
https://jobs.zalando.com
@ZalandoTech
https://tech.zalando.com
LUIS MINEIRO
@voidmaze
luis@zalando.de
1 2 . 0 3 . 2 0 1 8

Weitere ähnliche Inhalte

Was ist angesagt?

Stack linked list
Stack linked listStack linked list
Stack linked listbhargav0077
 
Javascript Secrets - Front in Floripa 2015
Javascript Secrets - Front in Floripa 2015Javascript Secrets - Front in Floripa 2015
Javascript Secrets - Front in Floripa 2015Fernando Daciuk
 
Swift: Apple's New Programming Language for iOS and OS X
Swift: Apple's New Programming Language for iOS and OS XSwift: Apple's New Programming Language for iOS and OS X
Swift: Apple's New Programming Language for iOS and OS XSasha Goldshtein
 
Exercice.docx
Exercice.docxExercice.docx
Exercice.docximane26
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stackvaibhav2910
 
Stacks overview with its applications
Stacks overview with its applicationsStacks overview with its applications
Stacks overview with its applicationsSaqib Saeed
 
Project of data structure
Project of data structureProject of data structure
Project of data structureUmme habiba
 
RxJava applied [JavaDay Kyiv 2016]
RxJava applied [JavaDay Kyiv 2016]RxJava applied [JavaDay Kyiv 2016]
RxJava applied [JavaDay Kyiv 2016]Igor Lozynskyi
 
What's new in c# 6
What's new in c# 6What's new in c# 6
What's new in c# 6Amir Barylko
 
Risking Everything with Akka Streams
Risking Everything with Akka StreamsRisking Everything with Akka Streams
Risking Everything with Akka Streamsjohofer
 
A Spin-off: CryEngine 3 SDK Checked with CppCat
A Spin-off: CryEngine 3 SDK Checked with CppCatA Spin-off: CryEngine 3 SDK Checked with CppCat
A Spin-off: CryEngine 3 SDK Checked with CppCatAndrey Karpov
 

Was ist angesagt? (19)

CST2403 NOTES
CST2403 NOTESCST2403 NOTES
CST2403 NOTES
 
Stack linked list
Stack linked listStack linked list
Stack linked list
 
Javascript Secrets - Front in Floripa 2015
Javascript Secrets - Front in Floripa 2015Javascript Secrets - Front in Floripa 2015
Javascript Secrets - Front in Floripa 2015
 
Swift: Apple's New Programming Language for iOS and OS X
Swift: Apple's New Programming Language for iOS and OS XSwift: Apple's New Programming Language for iOS and OS X
Swift: Apple's New Programming Language for iOS and OS X
 
Exercice.docx
Exercice.docxExercice.docx
Exercice.docx
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stack
 
Stack - Operations and Applications
Stack - Operations and ApplicationsStack - Operations and Applications
Stack - Operations and Applications
 
Sorter
SorterSorter
Sorter
 
applet.docx
applet.docxapplet.docx
applet.docx
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
Stacks overview with its applications
Stacks overview with its applicationsStacks overview with its applications
Stacks overview with its applications
 
Project of data structure
Project of data structureProject of data structure
Project of data structure
 
RxJava applied [JavaDay Kyiv 2016]
RxJava applied [JavaDay Kyiv 2016]RxJava applied [JavaDay Kyiv 2016]
RxJava applied [JavaDay Kyiv 2016]
 
Loop c++
Loop c++Loop c++
Loop c++
 
What's new in c# 6
What's new in c# 6What's new in c# 6
What's new in c# 6
 
Risking Everything with Akka Streams
Risking Everything with Akka StreamsRisking Everything with Akka Streams
Risking Everything with Akka Streams
 
Stacks
StacksStacks
Stacks
 
Nested loops
Nested loopsNested loops
Nested loops
 
A Spin-off: CryEngine 3 SDK Checked with CppCat
A Spin-off: CryEngine 3 SDK Checked with CppCatA Spin-off: CryEngine 3 SDK Checked with CppCat
A Spin-off: CryEngine 3 SDK Checked with CppCat
 

Ähnlich wie Reliability Patterns for Fun and Profit

Testing TYPO3 Applications
Testing TYPO3 ApplicationsTesting TYPO3 Applications
Testing TYPO3 ApplicationsAndré Wuttig
 
iOS 개발자의 Flutter 체험기
iOS 개발자의 Flutter 체험기iOS 개발자의 Flutter 체험기
iOS 개발자의 Flutter 체험기Wanbok Choi
 
Meteor - not just for rockstars
Meteor - not just for rockstarsMeteor - not just for rockstars
Meteor - not just for rockstarsStephan Hochhaus
 
Controlling Technical Debt with Continuous Delivery
Controlling Technical Debt with Continuous DeliveryControlling Technical Debt with Continuous Delivery
Controlling Technical Debt with Continuous Deliverywalkmod
 
Microservices With Spring Boot and Spring Cloud Netflix
Microservices With Spring Boot and Spring Cloud NetflixMicroservices With Spring Boot and Spring Cloud Netflix
Microservices With Spring Boot and Spring Cloud NetflixKrzysztof Sobkowiak
 
GraphQL Relay Introduction
GraphQL Relay IntroductionGraphQL Relay Introduction
GraphQL Relay IntroductionChen-Tsu Lin
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy codeShriKant Vashishtha
 
Introduction to Compiler Development
Introduction to Compiler DevelopmentIntroduction to Compiler Development
Introduction to Compiler DevelopmentLogan Chien
 
How to tune a query - ODTUG 2012
How to tune a query - ODTUG 2012How to tune a query - ODTUG 2012
How to tune a query - ODTUG 2012Connor McDonald
 
Monitoring and Logging in Wonderland
Monitoring and Logging in WonderlandMonitoring and Logging in Wonderland
Monitoring and Logging in WonderlandPaul Seiffert
 
Formal Verification of Transactional Interaction Contract
Formal Verification of Transactional Interaction ContractFormal Verification of Transactional Interaction Contract
Formal Verification of Transactional Interaction ContractGera Shegalov
 
Kamil witecki asynchronous, yet readable, code
Kamil witecki asynchronous, yet readable, codeKamil witecki asynchronous, yet readable, code
Kamil witecki asynchronous, yet readable, codeKamil Witecki
 
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHPphp[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHPAdam Englander
 
Navigating the xDD Alphabet Soup
Navigating the xDD Alphabet SoupNavigating the xDD Alphabet Soup
Navigating the xDD Alphabet SoupDror Helper
 
Formal Verification of Web Service Interaction Contracts
Formal Verification of Web Service Interaction ContractsFormal Verification of Web Service Interaction Contracts
Formal Verification of Web Service Interaction ContractsGera Shegalov
 
How Many Ways Can I Manage Oracle GoldenGate?
How Many Ways Can I Manage Oracle GoldenGate?How Many Ways Can I Manage Oracle GoldenGate?
How Many Ways Can I Manage Oracle GoldenGate?Enkitec
 
Full accesspolicyconsolidation for event processing systems
Full accesspolicyconsolidation for event processing systemsFull accesspolicyconsolidation for event processing systems
Full accesspolicyconsolidation for event processing systemsviswanadhamsatish
 

Ähnlich wie Reliability Patterns for Fun and Profit (20)

Testing TYPO3 Applications
Testing TYPO3 ApplicationsTesting TYPO3 Applications
Testing TYPO3 Applications
 
Meteor WWNRW Intro
Meteor WWNRW IntroMeteor WWNRW Intro
Meteor WWNRW Intro
 
iOS 개발자의 Flutter 체험기
iOS 개발자의 Flutter 체험기iOS 개발자의 Flutter 체험기
iOS 개발자의 Flutter 체험기
 
Meteor - not just for rockstars
Meteor - not just for rockstarsMeteor - not just for rockstars
Meteor - not just for rockstars
 
Controlling Technical Debt with Continuous Delivery
Controlling Technical Debt with Continuous DeliveryControlling Technical Debt with Continuous Delivery
Controlling Technical Debt with Continuous Delivery
 
Microservices With Spring Boot and Spring Cloud Netflix
Microservices With Spring Boot and Spring Cloud NetflixMicroservices With Spring Boot and Spring Cloud Netflix
Microservices With Spring Boot and Spring Cloud Netflix
 
GraphQL Relay Introduction
GraphQL Relay IntroductionGraphQL Relay Introduction
GraphQL Relay Introduction
 
Intro to RX
Intro to RXIntro to RX
Intro to RX
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy code
 
C.pdf
C.pdfC.pdf
C.pdf
 
Introduction to Compiler Development
Introduction to Compiler DevelopmentIntroduction to Compiler Development
Introduction to Compiler Development
 
How to tune a query - ODTUG 2012
How to tune a query - ODTUG 2012How to tune a query - ODTUG 2012
How to tune a query - ODTUG 2012
 
Monitoring and Logging in Wonderland
Monitoring and Logging in WonderlandMonitoring and Logging in Wonderland
Monitoring and Logging in Wonderland
 
Formal Verification of Transactional Interaction Contract
Formal Verification of Transactional Interaction ContractFormal Verification of Transactional Interaction Contract
Formal Verification of Transactional Interaction Contract
 
Kamil witecki asynchronous, yet readable, code
Kamil witecki asynchronous, yet readable, codeKamil witecki asynchronous, yet readable, code
Kamil witecki asynchronous, yet readable, code
 
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHPphp[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
 
Navigating the xDD Alphabet Soup
Navigating the xDD Alphabet SoupNavigating the xDD Alphabet Soup
Navigating the xDD Alphabet Soup
 
Formal Verification of Web Service Interaction Contracts
Formal Verification of Web Service Interaction ContractsFormal Verification of Web Service Interaction Contracts
Formal Verification of Web Service Interaction Contracts
 
How Many Ways Can I Manage Oracle GoldenGate?
How Many Ways Can I Manage Oracle GoldenGate?How Many Ways Can I Manage Oracle GoldenGate?
How Many Ways Can I Manage Oracle GoldenGate?
 
Full accesspolicyconsolidation for event processing systems
Full accesspolicyconsolidation for event processing systemsFull accesspolicyconsolidation for event processing systems
Full accesspolicyconsolidation for event processing systems
 

Kürzlich hochgeladen

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Kürzlich hochgeladen (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Reliability Patterns for Fun and Profit

  • 1. FOR FUN AND PROFIT R E L I A B I L I T Y PATTERNS D E V O P S L I S B O N 1 2 . 0 3 . 2 0 18 
 L I S B O N , P O RT U G A L L U I S M I N E I R O @voidmaze
  • 5. What happens when the following operation fails? Cart cart = restTemplate.getForObject(url, Cart.class); H A N D L I N G FA U LT S
  • 6. for (int i = 1; i <= numRetries; i++) { try { return restTemplate.getForObject(url, Cart.class); } catch (RestClientException e) { LOG.error("failed to get cart", e); if (i >= numRetries) { throw e; } } } R E T RY I N G
  • 7. We should only retry if the problem is due to a network failure or server overload TRANSIENT FAULTS
  • 8. for (int i = 1; i <= numRetries; i++) { try { return restTemplate.getForObject(url, Cart.class); } catch (RestClientException e) { LOG.error("failed to get cart", e); if (i >= numRetries || isNonTransientFault(e)) { throw e; } } } B E T T E R R E T RY
  • 10. long computeWaitTime(int retryNumber, int maxWaitTime) { int delay = WAIT_TIME_MULTIPLIER * 2^retryNumber; return min(maxWaitTime, delay + random.nextInt(delay)); } ... for (int i = 1; i <= numRetries; i++) { try { return restTemplate.getForObject(url, Cart.class); } catch (RestClientException e) { LOG.error("failed to get cart", e); if (i >= numRetries || isNonTransientFault(e)) { throw e; } sleep(computeWaitTime(i, MAX_WAIT_TIME)); } } TRUNCATED EXPONENTIAL BACKOFF WITH JITTER
  • 11. WHEN TRANSIENT FAULTS BECOME PERMANENT
  • 12. C I R C U I T B R E A K E R PAT T E R N The circuit breaker pattern can prevent an application from repeatedly trying to execute an operation that's likely to fail
  • 13. C I R C U I T B R E A K E R C L O S E D Closed State
 The requests from the application are forwarded to the target TA R GET
  • 14. C I R C U I T B R E A K E R C L O S E D Closed State
 The requests from the application are forwarded to the target TA R GET
  • 15. C I R C U I T B R E A K E R C L O S E D Closed State
 The requests from the application are forwarded to the target TA R GET
  • 16. C I R C U I T B R E A K E R C L O S E D Closed State
 The requests from the application are forwarded to the target TA R GET
  • 17. C I R C U I T B R E A K E R O P E N Open State
 The request from the application fails immediately and an exception is returned to the application. TA R GET
  • 18. C I R C U I T B R E A K E R H A L F - O P E N Half-Open State
 A limited number of requests from the application are allowed to pass through and invoke the operation. TA R GET
  • 19. C I R C U I T B R E A K E R H A L F - O P E N Half-Open State
 A limited number of requests from the application are allowed to pass through and invoke the operation. TA R GET
  • 20. C I R C U I T B R E A K E R H A L F - O P E N Half-Open State
 A limited number of requests from the application are allowed to pass through and invoke the operation. TA R GET
  • 21. C I R C U I T B R E A K E R O P E N Open State
 The request from the application fails immediately and an exception is returned to the application. TA R GET
  • 22. private double doSomeMath(int result) { if(result != 0) { return 42 / result; } return Double.NaN; } THE MOST IMPORTANT QUESTION
  • 26. circuitBreaker.call((url) -> { for (int i = 1; i <= numRetries; i++) { try { return restTemplate.getForObject(url, Product.class); } catch (RestClientException e) { LOG.error("failed to get product details", e); if (i >= numRetries || isNonTransientFault(e)) { throw e; } sleep(computeWaitTime(i, MAX_WAIT_TIME)); } } throw new NoMoreRetriesException(); }).fallback(() -> "a Partner"); PUTTING IT ALL TOG ET HER
  • 27. H A N D S - O N E X E R C I S E R E T RY C I R C U I T
 BREAKER FALLBACK PRODUCT D E TA I L PA G E TA R GET
  • 28. EXERCISE - PR OD UC T D ETA IL PAGE
  • 29. EXERCISE - PR OD UC T D ETA IL PAGE B R A N D D ATA PRO DUCT DATA WISH LIST SI ZE RE COMME NDATION C A R T D E L I V E RY O P T I O N S S IZ E SE LE CTO R
  • 30. EXERCISE - PR OD UC T D ETA IL PAGE GROUP 2: BR AN D D ATA GROUP 3: PR OD U C T D ATA GROUP 4: WISH LIST GROUP 1: SI ZE R E C OMME NDAT IO N GROUP 5: C A RT GROUP 7: D E L I V E RY O P T I O N S GROUP 6: SI ZE S E LE C TOR GROUPS TASKS 1.Retries Retryable operation? How many times? 2.Circuit breaker Global circuit breaker? 3.Fail fast Type of fallback Delegate to frontend? 2 0 MIN