Slide 1

Slide 1 text

Resiliente Microservices mit Spring Boot und Failsafe Malte Pickhan @mpickhan Zalando Payments GmbH JavaLand 2018 13.03.2018

Slide 2

Slide 2 text

2 ZALANDO TECHNOLOGY HOME-BREWED, CUTTING-EDGE & SCALABLE technology solutions 1,800 employees from tech locations + HQs in Berlin 6 77 nations help our brand to WIN ONLINE

Slide 3

Slide 3 text

HANDS ON EXPERIENCE ON HOW WE BUILD RESILIENT MICROSERVICES WITH SPRING BOOT AND FAILSAFE

Slide 4

Slide 4 text

4 RESILIENCE In computer networking: resilience is the ability to provide and maintain an acceptable level of service in the face of faults and challenges to normal operation. [0]

Slide 5

Slide 5 text

5 MICROSERVICES Accept failures instead of avoiding them • Latency • Network • More clients • Maybe even unknown clients

Slide 6

Slide 6 text

6 SPRING BOOT Takes an opinionated view of building production-ready Spring applications. Spring Boot favors convention over configuration and is designed to get you up and running as quickly as possible. [1]

Slide 7

Slide 7 text

7 ACTUATOR Actuator endpoints allow you to monitor and interact with your application. Spring Boot includes a number of built-in endpoints and you can also add your own. For example the health endpoint provides basic application health information. [2]

Slide 8

Slide 8 text

8 FAILSAFE Failsafe is a lightweight, zero-dependency library for handling failures. It was designed to be as easy to use as possible, with a concise API for handling everyday use cases and the flexibility to handle everything else. [3]

Slide 9

Slide 9 text

9 FAILSAFE Calls can be put to Lambda expressions or Callbacks Execution Context Supports retries out of the box Async execution can be observed via Listener API

Slide 10

Slide 10 text

10 EXAMPLE

Slide 11

Slide 11 text

11 CIRCUIT BREAKER ● Fail fast ● Be excellent to others ● Three states ○ Closed ○ Open ○ Half Open

Slide 12

Slide 12 text

12 CIRCUIT BREAKER

Slide 13

Slide 13 text

THIS WAS GOOD, BUT WE CAN DO BETTER

Slide 14

Slide 14 text

14 FALLBACK ● Call alternative service in case primary is unavailable ● Not only be available, but also deliver valid results

Slide 15

Slide 15 text

15 ● Product detail page ● Customer might not be interested in details at all ● Why should we serve a 500 because of that and miss the sale? REAL WORLD EXAMPLE

Slide 16

Slide 16 text

16 FALLBACK EXAMPLE

Slide 17

Slide 17 text

17 RETRY ● Retry call in case of transient errors ● Try to get as much through at possible ● Every request is a paying customer

Slide 18

Slide 18 text

18 RETRY EXAMPLE

Slide 19

Slide 19 text

19 RETRY delay = backoff + jitterFactor ● backoff is growing exponentially with each retry (1 .. 5 seconds) ● jitterFactor is randomly picked in range (-10 .. 10 ms) ● retries will be equally distributed

Slide 20

Slide 20 text

20 ● Monitor Circuit Breaker to identify problems early ● Returns JSON containing the state of all registered Circuit Breaker ● Failsafe-Actuator provides this functionality ○ Spring Boot 2 support close to come MONITORING

Slide 21

Slide 21 text

21 DEMO

Slide 22

Slide 22 text

QUESTIONS?

Slide 23

Slide 23 text

23 [0] https://en.wikipedia.org/wiki/Resilience_(n etwork) [1] https://projects.spring.io/spring-boot/ [2] https://docs.spring.io/spring-boot/docs/curr ent/reference/html/production-ready-endp oints.html [3] https://github.co/mjhalterman/failsafe BIBLIOGRAPHY