Slide 1

Slide 1 text

Jonas Bonér CTO Typesafe @jboner Go Reactive Building Responsive, Resilient, Elastic & Message-Driven Systems

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

The rules of the game have changed

Slide 4

Slide 4 text

3 Yesterday Today

Slide 5

Slide 5 text

3 Yesterday Today Single machines Clusters of machines

Slide 6

Slide 6 text

3 Yesterday Today Single machines Clusters of machines Single core processors Multicore processors

Slide 7

Slide 7 text

3 Yesterday Today Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM

Slide 8

Slide 8 text

3 Yesterday Today Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk

Slide 9

Slide 9 text

3 Yesterday Today Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk Slow networks Fast networks

Slide 10

Slide 10 text

3 Yesterday Today Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk Slow networks Fast networks Few concurrent users Lots of concurrent users

Slide 11

Slide 11 text

3 Yesterday Today Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk Slow networks Fast networks Few concurrent users Lots of concurrent users Small data sets Large data sets

Slide 12

Slide 12 text

3 Yesterday Today Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk Slow networks Fast networks Few concurrent users Lots of concurrent users Small data sets Large data sets Latency in seconds Latency in milliseconds

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

Reactive “Readily responsive to a stimulus” - Merriam Webster

Slide 15

Slide 15 text

Reactive  Applications The Principles of Reactive Systems 6

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

http://reactivemanifesto.org

Slide 18

Slide 18 text

Responsive “Quick to respond or react appropriately” - Merriam Webster

Slide 19

Slide 19 text

9 The system should always be responsive

Slide 20

Slide 20 text

9 1. Blue skies 2. Heavy load 3. Failures The system should always be responsive

Slide 21

Slide 21 text

Resilient “The ability of a substance or object to spring back into shape” “The capacity to recover quickly from difficulties” - Merriam Webster

Slide 22

Slide 22 text

Think Vending Machine

Slide 23

Slide 23 text

Coffee Machine Programmer Think Vending Machine

Slide 24

Slide 24 text

Coffee Machine Programmer Inserts coins Think Vending Machine

Slide 25

Slide 25 text

Coffee Machine Programmer Inserts coins Add more coins Think Vending Machine

Slide 26

Slide 26 text

Coffee Machine Programmer Inserts coins Gets coffee Add more coins Think Vending Machine

Slide 27

Slide 27 text

Coffee Machine Programmer Think Vending Machine

Slide 28

Slide 28 text

Coffee Machine Programmer Inserts coins Think Vending Machine

Slide 29

Slide 29 text

Coffee Machine Programmer Inserts coins Think Vending Machine Out of coffee beans error

Slide 30

Slide 30 text

Coffee Machine Programmer Inserts coins Think Vending Machine Out of coffee beans error WRONG

Slide 31

Slide 31 text

Coffee Machine Programmer Inserts coins Think Vending Machine

Slide 32

Slide 32 text

Coffee Machine Programmer Inserts coins Out of coffee beans failure Think Vending Machine

Slide 33

Slide 33 text

Coffee Machine Programmer Service Guy Inserts coins Out of coffee beans failure Think Vending Machine

Slide 34

Slide 34 text

Coffee Machine Programmer Service Guy Inserts coins Out of coffee beans failure Adds more beans Think Vending Machine

Slide 35

Slide 35 text

Coffee Machine Programmer Service Guy Inserts coins Gets coffee Out of coffee beans failure Adds more beans Think Vending Machine

Slide 36

Slide 36 text

The Right Way Service Client

Slide 37

Slide 37 text

The Right Way Service Client Request

Slide 38

Slide 38 text

The Right Way Service Client Request Response

Slide 39

Slide 39 text

The Right Way Service Client Request Response Validation Error

Slide 40

Slide 40 text

The Right Way Service Client Request Response Validation Error Application Failure

Slide 41

Slide 41 text

The Right Way Service Client Supervisor Request Response Validation Error Application Failure

Slide 42

Slide 42 text

The Right Way Service Client Supervisor Request Response Validation Error Application Failure Manages Failure

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

Resilience Is By Design

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

1. Isolate the failure 2. Compartmentalize 3. Manage failure locally 4. Avoid cascading failures Use Bulkheads

Slide 47

Slide 47 text

1. Isolate the failure 2. Compartmentalize 3. Manage failure locally 4. Avoid cascading failures Use Bulkheads

Slide 48

Slide 48 text

Enter Supervision

Slide 49

Slide 49 text

A B Bar Foo C B E A D C Automatic and mandatory supervision Supervisor hierarchies

Slide 50

Slide 50 text

A B Bar Foo C E A D C Automatic and mandatory supervision Supervisor hierarchies B

Slide 51

Slide 51 text

19 Every single actor has a default supervisor strategy. Which is usually sufficient. But it can be overridden. Supervision in Akka

Slide 52

Slide 52 text

19 class Supervisor extends AbstractActor { private SupervisorStrategy strategy = new OneForOneStrategy( 10, Duration.create(1, TimeUnit.MINUTES), DirectiveBuilder. match(ArithmeticException.class, e -> resume()). match(NullPointerException.class, e -> restart()). matchAny( e -> escalate()). build()); … // rest of actor omitted } } Supervision in Akka

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

Resilience requires a Message-Driven Architecture

Slide 55

Slide 55 text

Elastic “Capable of ready change or easy expansion or contraction” - Merriam Webster

Slide 56

Slide 56 text

UP Scale

Slide 57

Slide 57 text

UP Scale and down

Slide 58

Slide 58 text

1. Minimize Contention 2. Maximize Locality of Reference 23 We need to

Slide 59

Slide 59 text

Common points of Application Physical contention

Slide 60

Slide 60 text

25 GO

Slide 61

Slide 61 text

Async 25 GO

Slide 62

Slide 62 text

26 Never ever

Slide 63

Slide 63 text

26 Never ever

Slide 64

Slide 64 text

Block 26 Never ever

Slide 65

Slide 65 text

27 NOTHING share

Slide 66

Slide 66 text

28 Needs to be async and non-blocking all the way down…

Slide 67

Slide 67 text

28 Needs to be async and non-blocking all the way down…

Slide 68

Slide 68 text

29 Single Writer Principle

Slide 69

Slide 69 text

29 Single Writer Principle IO device Producers SERIAL & CONTENDED

Slide 70

Slide 70 text

29 Single Writer Principle IO device Producers SERIAL & CONTENDED IO device Producers Actor or Queue BATCHED & UNCONTENDED

Slide 71

Slide 71 text

The Role of Immutable State 30

Slide 72

Slide 72 text

The Role of Immutable State 30

Slide 73

Slide 73 text

The Role of Immutable State • Great to represent facts • Messages and Events • Database snapshots • Representing the succession of time 30

Slide 74

Slide 74 text

The Role of Immutable State • Great to represent facts • Messages and Events • Database snapshots • Representing the succession of time • Mutable State is ok if local and contained • Allows Single-threaded processing • Allows single writer principle • Feels more natural • Publish the results to the world as Immutable State 30

Slide 75

Slide 75 text

Divide & Conquer 31

Slide 76

Slide 76 text

32 Pipelining

Slide 77

Slide 77 text

ON DEMAND 33 scale

Slide 78

Slide 78 text

OUT Scale

Slide 79

Slide 79 text

OUT Scale and in

Slide 80

Slide 80 text

• Mobile • Cloud Services, REST etc. • NOSQL DBs • Big Data 35 Distributed Computing is the new normal

Slide 81

Slide 81 text

What is the essence of distributed systems? 36

Slide 82

Slide 82 text

What is the essence of distributed systems? To try to overcome that 1. Information travels at the speed of light 2. Independent things fail independently 36

Slide 83

Slide 83 text

Slow node Dead node No difference 37 and a Between a

Slide 84

Slide 84 text

The network is 38

Slide 85

Slide 85 text

The network is 38 http://aphyr.com/posts/288-the-network-is-reliable Inherently Unreliable

Slide 86

Slide 86 text

39 Graveyard of distributed systems

Slide 87

Slide 87 text

39 Graveyard of distributed systems • Distributed Shared Mutable State • EVIL (where N is number of nodes) N

Slide 88

Slide 88 text

39 Graveyard of distributed systems • Distributed Shared Mutable State • EVIL (where N is number of nodes) N • Serializable Distributed Transactions

Slide 89

Slide 89 text

39 Graveyard of distributed systems • Distributed Shared Mutable State • EVIL (where N is number of nodes) N • Serializable Distributed Transactions • Synchronous RPC

Slide 90

Slide 90 text

39 Graveyard of distributed systems • Distributed Shared Mutable State • EVIL (where N is number of nodes) N • Serializable Distributed Transactions • Synchronous RPC • Guaranteed Delivery

Slide 91

Slide 91 text

39 Graveyard of distributed systems • Distributed Shared Mutable State • EVIL (where N is number of nodes) N • Serializable Distributed Transactions • Synchronous RPC • Guaranteed Delivery • Distributed Objects • “Sucks like an inverted hurricane” - Martin Fowler

Slide 92

Slide 92 text

Instead 40

Slide 93

Slide 93 text

Embrace the Network Instead 40 and be done with it Use Asynchronous Message Passing

Slide 94

Slide 94 text

TRANSPARENCY 41 location

Slide 95

Slide 95 text

42

Slide 96

Slide 96 text

42 Scaling Up and Out is essentially the same thing

Slide 97

Slide 97 text

No content

Slide 98

Slide 98 text

Elasticity requires a Message-Driven Architecture

Slide 99

Slide 99 text

No content

Slide 100

Slide 100 text

Asynchronous Message-Passing is the enabler

Slide 101

Slide 101 text

45 Typesafe Reactive Platform • Actors are lightweight, isolated and and communicate via asynchronous message passing • Supervision and clustering in support of fault tolerance • Purely asynchronous and non-blocking web framework • No container required, no inherent bottlenecks in session management • Asynchronous and immutable programming constructs • Composable abstractions enabling simpler concurrency and parallelism

Slide 102

Slide 102 text

Typesafe Activator http://typesafe.com/platform/getstarted

Slide 103

Slide 103 text

47 Finance Internet/Social Media Mfg/Hardware Government Retail

Slide 104

Slide 104 text

Jonas Bonér CTO Typesafe @jboner Go Reactive Building Responsive, Resilient, Elastic & Message-Driven Systems