Sunteți pe pagina 1din 111

Building a Bank

with Go
Matt Heath, Monzo
Hi, Im Matt
@mattheath
monoliths
traditional dev
LICENCE WITH
RESTRICTIONS
50K MAX
DEPOSIT
WE ARE
HERE

PRE APPLICATION APPLICATION MOBILISATION LAUNCH

FEB MAR APR MAY JUN JUL AUG SEP NOV DEC JAN FEB MAR APR MAY JUN JUL AUG SEP NOV DEC JAN FEB MAR APR MAY JUN JUL
2015 2016 2017

We received a UK banking licence in August 2016!

A UK banking licence is authorised by the PRA and This is followed by a mobilisation phase during
regulated by the PRA and FCA1, allowing deposit- which final capital is raised and IT systems are
taking and balance sheet lending. Once granted, completed, before launching to the public.
it allows firms to passport across Europe, accessing
?
Application
Application

Database
Application

Database
Application

Databases
Application

Search Databases
Application

Caching
Search Databases
Application

Caching
Search Databases

CAT GIFS
ALL
HAIL
THE
MONOLITH
Application

Caching
Search Databases

CAT GIFS
APPLICATION
Application
Single Responsibility
Principle
Bounded Context
Well defined
Interfaces
Why Go?
Memory Managed
Statically Typed
Excellent Concurrency
Perfect for simple, small, network services
Lightweight
Concurrency
Goroutines
// Blocking function call

handleRequest()
// Function runs concurrently

go handleRequest()
package main

func main() {

go handleRequest()

//

}
package main main

func main() {

go handleRequest()

//

}
package main main

func main() {

go handleRequest() handleRequest

//

}
"Do not communicate by
sharing memory; instead, share
memory by communicating."
- Effective Go
Channels
Simplicity
Static Linking
Stdlib
etc
200

160

120

80

40

0
Number of services
Feb Mar
2015 2017
monzo/typhon
Service

Service
Service

Transport

Service
Service

Transport

Service Service Service


Service
Client library

Transport

Server library
Service Service Service
Service
HTTP

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

?
HTTP
Service Service Service
Service
HTTP

linkerd

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

HTTP API & Routing Layer


Load Balancer

HTTP API & Routing Layer

API
Service
/webhooks -> Webhook API
Load Balancer

HTTP API & Routing Layer

Webhook
API
Load Balancer

HTTP API & Routing Layer

Webhook
API

Auth Webhook
Service Service
Load Balancer

HTTP API & Routing Layer

Webhook
API

Auth Webhook
Database
Service Service
Load Balancer

HTTP API & Routing Layer

Webhook
API

Auth Webhook
Database
Service Service

Database
Load Balancer

HTTP API & Routing Layer

Webhook
API
External
Provider

Auth Webhook
Database
Service Service

Database
type Service func(req Request) Response
router.GET("/", List)
router.POST("/", Register)
router.DELETE("/:id", Deregister)
Making our
service reliable
+ =

Load Balancer

HTTP API & Routing Layer

Webhook
API

Webhook Webhook Webhook


Service Service Service
Load Balancer

HTTP API & Routing Layer

Webhook
API

Webhook Webhook Webhook


Service Service Service
Load Balancer

HTTP API & Routing Layer

Webhook
API Webhook
Service

Webhook Webhook Webhook


Service Service Service
Load Balancer

HTTP API & Routing Layer

Webhook
API Webhook
Service

Slow or Webhook Webhook Webhook


Errors Service Service Service
Event Driven
Architecture
Load Balancer

HTTP API & Routing Layer

API
Service

Service Service
A B
Load Balancer

HTTP API & Routing Layer

API
Service

Service Service
A B
Load Balancer

HTTP API & Routing Layer

API
Service

Service Service
A B
Load Balancer

HTTP API & Routing Layer

Service
API C
Service

Service
D

Service Service
A B
Service
E
Context
Propagation
api api.customer service.customer

api api.customer service.customer


api api.customer service.customer

api api.customer service.customer


8096820c-3b7b-47ec-bce6-1c239252ab40
api api.customer service.customer

api api.customer service.customer


api api.customer service.customer

api api.customer service.customer


package context

type Context interface {


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

type Context interface {


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

type Context interface {


Deadline() (deadline time.Time, ok bool)
Done() <-chan struct{}
Err() error
Value(key interface{}) interface{}
}
api api.customer service.customer

api api.customer service.customer


api api.customer service.customer

SEND

RECV SEND
RECV
SEND
SEND RECV

RECV

api api.customer service.customer


api api.customer service.customer

SEND

RECV SEND
RECV
SEND
SEND RECV

RECV

phosphor
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
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
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
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
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
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
Perfect for
microservice
architectures
Concurrency:
Goroutines
Channels
Small
Simple
Easy
Thanks!
@mattheath
@monzo

S-ar putea să vă placă și