Slide 1

Slide 1 text

Building a Bank with Go Matt Heath, Monzo

Slide 2

Slide 2 text

Hi, I’m Matt @mattheath

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

monoliths traditional dev

Slide 6

Slide 6 text

A UK banking licence is authorised by the PRA and regulated by the PRA and FCA1, allowing deposit- taking and balance sheet lending. Once granted, it allows firms to passport across Europe, accessing This is followed by a “mobilisation” phase during which final capital is raised and IT systems are completed, before launching to the public. We received a UK banking licence in August 2016! FEB 2015 JAN 2016 JAN 2017 MAR FEB FEB APR MAR MAR APR MAY JUN JUL MAY APR JUN MAY JUL JUN AUG JUL SEP AUG NOV SEP DEC NOV DEC PRE APPLICATION APPLICATION MOBILISATION LAUNCH LICENCE WITH RESTRICTIONS 50K MAX DEPOSIT WE ARE HERE

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

?

Slide 16

Slide 16 text

Application

Slide 17

Slide 17 text

Application Database

Slide 18

Slide 18 text

Application Database

Slide 19

Slide 19 text

Application Databases

Slide 20

Slide 20 text

Application Databases Search

Slide 21

Slide 21 text

Application Databases Search Caching

Slide 22

Slide 22 text

Application Databases Search Caching CAT GIFS

Slide 23

Slide 23 text

ALL HAIL THE MONOLITH

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Application Databases Search Caching CAT GIFS

Slide 26

Slide 26 text

APPLICATION Application

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

Single Responsibility Principle

Slide 30

Slide 30 text

Bounded Context

Slide 31

Slide 31 text

Well defined Interfaces

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Why Go? Memory Managed Statically Typed Excellent Concurrency Perfect for simple, small, network services

Slide 34

Slide 34 text

Lightweight Concurrency

Slide 35

Slide 35 text

Goroutines

Slide 36

Slide 36 text

// Blocking function call handleRequest()

Slide 37

Slide 37 text

// Function runs concurrently go handleRequest()

Slide 38

Slide 38 text

package main func main() { go handleRequest() // … }

Slide 39

Slide 39 text

package main func main() { go handleRequest() // … } main

Slide 40

Slide 40 text

package main func main() { go handleRequest() // … } handleRequest main

Slide 41

Slide 41 text

"Do not communicate by sharing memory; instead, share memory by communicating." - Effective Go

Slide 42

Slide 42 text

Channels

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

Simplicity

Slide 48

Slide 48 text

Static Linking Stdlib etc

Slide 49

Slide 49 text

0 40 80 160 120 Feb 2015 Mar 2017 200 Number of services

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

monzo/typhon

Slide 53

Slide 53 text

Service Service

Slide 54

Slide 54 text

Service Service Transport

Slide 55

Slide 55 text

Service Service Transport Service Service

Slide 56

Slide 56 text

Service Service Transport Service Service Client library Server library

Slide 57

Slide 57 text

Service Service Service Service HTTP HTTP

Slide 58

Slide 58 text

Service Discovery Load Balancing Timeouts and Expirations Retries Rate Limiting Connection Pooling Circuit Breaking Failure Detection Metrics and Tracing Interrupts Context Propagation

Slide 59

Slide 59 text

Service Service Service Service HTTP HTTP ?

Slide 60

Slide 60 text

Service Service Service Service HTTP HTTP linkerd

Slide 61

Slide 61 text

Service Discovery Load Balancing Timeouts and Expirations Retries Rate Limiting Connection Pooling Circuit Breaking Failure Detection Metrics and Tracing Interrupts Context Propagation

Slide 62

Slide 62 text

Load Balancer

Slide 63

Slide 63 text

Load Balancer HTTP API & Routing Layer

Slide 64

Slide 64 text

Load Balancer HTTP API & Routing Layer API
 Service

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

/webhooks —-> Webhook API

Slide 67

Slide 67 text

Load Balancer HTTP API & Routing Layer Webhook
 API

Slide 68

Slide 68 text

Auth
 Service Webhook
 Service Load Balancer HTTP API & Routing Layer Webhook
 API

Slide 69

Slide 69 text

Auth
 Service Webhook
 Service Load Balancer HTTP API & Routing Layer Webhook
 API Database

Slide 70

Slide 70 text

Database Auth
 Service Webhook
 Service Load Balancer HTTP API & Routing Layer Webhook
 API Database

Slide 71

Slide 71 text

External Provider Database Auth
 Service Webhook
 Service Load Balancer HTTP API & Routing Layer Webhook
 API Database

Slide 72

Slide 72 text

type Service func(req Request) Response

Slide 73

Slide 73 text

router.GET("/", List) router.POST("/", Register) router.DELETE("/:id", Deregister)

Slide 74

Slide 74 text

Making our service reliable

Slide 75

Slide 75 text

+ = ❤

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

Webhook
 Service Webhook
 Service Webhook
 Service Load Balancer HTTP API & Routing Layer Webhook
 API

Slide 78

Slide 78 text

Webhook
 Service Webhook
 Service Webhook
 Service Load Balancer HTTP API & Routing Layer Webhook
 API

Slide 79

Slide 79 text

Webhook
 Service Webhook
 Service Webhook
 Service Webhook
 Service Load Balancer HTTP API & Routing Layer Webhook
 API

Slide 80

Slide 80 text

Webhook
 Service Webhook
 Service Webhook
 Service Webhook
 Service Load Balancer HTTP API & Routing Layer Webhook
 API Slow or
 Errors

Slide 81

Slide 81 text

Event Driven Architecture

Slide 82

Slide 82 text

Service A Service B Load Balancer HTTP API & Routing Layer API Service

Slide 83

Slide 83 text

API Service Service A Service B Load Balancer HTTP API & Routing Layer

Slide 84

Slide 84 text

API Service Service A Service B Load Balancer HTTP API & Routing Layer

Slide 85

Slide 85 text

API Service Service A Service B Load Balancer HTTP API & Routing Layer Service C Service D Service E

Slide 86

Slide 86 text

Context Propagation

Slide 87

Slide 87 text

api api api.customer api.customer service.customer service.customer

Slide 88

Slide 88 text

api api api.customer api.customer service.customer service.customer

Slide 89

Slide 89 text

8096820c-3b7b-47ec-bce6-1c239252ab40

Slide 90

Slide 90 text

api api api.customer api.customer service.customer service.customer

Slide 91

Slide 91 text

api api api.customer api.customer service.customer service.customer

Slide 92

Slide 92 text

package context type Context interface { Deadline() (deadline time.Time, ok bool) Done() <-chan struct{} Err() error Value(key interface{}) interface{} }

Slide 93

Slide 93 text

package context type Context interface { Deadline() (deadline time.Time, ok bool) Done() <-chan struct{} Err() error Value(key interface{}) interface{} }

Slide 94

Slide 94 text

package context type Context interface { Deadline() (deadline time.Time, ok bool) Done() <-chan struct{} Err() error Value(key interface{}) interface{} }

Slide 95

Slide 95 text

api api api.customer api.customer service.customer service.customer

Slide 96

Slide 96 text

api api api.customer api.customer service.customer service.customer SEND RECV SEND RECV RECV SEND RECV SEND

Slide 97

Slide 97 text

api api.customer service.customer SEND RECV SEND RECV RECV SEND RECV SEND phosphor

Slide 98

Slide 98 text

No content

Slide 99

Slide 99 text

API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns

Slide 100

Slide 100 text

API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns

Slide 101

Slide 101 text

API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns

Slide 102

Slide 102 text

API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns

Slide 103

Slide 103 text

API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns

Slide 104

Slide 104 text

No content

Slide 105

Slide 105 text

API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns

Slide 106

Slide 106 text

No content

Slide 107

Slide 107 text

No content

Slide 108

Slide 108 text

Perfect for
 microservice architectures

Slide 109

Slide 109 text

Concurrency:
 Goroutines Channels

Slide 110

Slide 110 text

Small Simple Easy

Slide 111

Slide 111 text

Thanks! @mattheath @monzo