Circuit breaker YoungBlood @Paris Jug

Preview:

Citation preview

LE CIRCUIT BREAKER PATTERN

Tolérance Aux PannesAvec

1

 Mouhcine Moulou 

@mouloumouhcine

Consultant Scala

2

3

Service 1 Service 2

PROBLÈME

4

PROBLÈME

Service 1 Service 2

Gaspillage des Resources VM (Thread, Mémoire, etc.)

5

PROBLÈME

Service 1 Service 2timeout

6

PROBLÈME

Service 1 Service 2timeout

7

Performance

PROBLÈME

Service 1

Service 3

Service 2

8

PROBLÈME

Service 1

Service 3

Service 2

9

PROBLÈME

Service 1

Service 3

Service 2

10

PROBLÈME

Service 1

Service 3

Service 2

11

CASCADING FAILURES

12

SOLUTION

13

SOLUTION

14

« Let It Crash & Handle with Grace. »

15

Service 1 Service 2

CIRCUIT BREAKER

16

Service 1 Service 2

CIRCUIT BREAKER

17

Service 1 Service 2

CIRCUIT BREAKER

Closed

18

Service 1 Service 2

CIRCUIT BREAKER

Open

19

CIRCUIT BREAKER

Closed

20

CIRCUIT BREAKER

Closed Open

Max Failures

21

CIRCUIT BREAKER

Closed Open

Half Open

?

Reset Timeout

Max Failures

22

CIRCUIT BREAKER

Closed Open

Half Open

?

Reset TimeoutKO

OK

Max Failures

23

EXEMPLE (AKKA IMPLEMENTATION)

CircuitBreaker breaker = new CircuitBreaker( getContext().dispatcher(), // L'actor System getContext().system().scheduler(), // Scheduler 50, // maxFailures Duration.create(10, "s"), // Call Timeout Duration.create(1, "m") // Reset Timeout);

24

EXEMPLE (AKKA IMPLEMENTATION)

// Sans Circuit Breaker return dangerousCall();

25

EXEMPLE (AKKA IMPLEMENTATION)

// Callable new Callable<String>() { public String call() throws Exception { return dangerousCall(); } }

26

EXEMPLE (AKKA IMPLEMENTATION)

// Avec Circuit Breaker // Appel Javabreaker.callWithSyncCircuitBreaker( new Callable<String>() { public String call() throws Exception { return dangerousCall(); } });

27

EXEMPLE (AKKA IMPLEMENTATION)

// Avec Circuit Breaker // Appel Scalabreaker.callWithCircuitBreaker( Future( dangerousCall()))

28

CIRCUIT BREAKER

29

Avantages•Réponse rapide.•Meilleur utilisation des resources.•Cascading failures.•Monitoring.

CIRCUIT BREAKER

30

Avantages•Réponse rapide.•Meilleur utilisation des resources.•Cascading failures.•Monitoring.

Inconvénients• Impossibilité de filtrer les exceptions

CIRCUIT BREAKER

31

ESSAYEZ LE !

Avantages•Réponse rapide.•Meilleur utilisation des resources.•Cascading failures.•Monitoring.

Inconvénients• Impossibilité de filtrer les exceptions

32

Recommended