building a bank out of microservices (ndc sydney, august 2016)

279
Building a Bank out of Microservices

Upload: graham-lea

Post on 10-Jan-2017

6.992 views

Category:

Software


3 download

TRANSCRIPT

Page 1: Building a Bank out of Microservices (NDC Sydney, August 2016)

Building a

Bank out of

Microservices

Page 2: Building a Bank out of Microservices (NDC Sydney, August 2016)

Microservices is a stupid word

‘Stupid V’ by Laura Lewis

Page 3: Building a Bank out of Microservices (NDC Sydney, August 2016)

What are we doing?

Page 4: Building a Bank out of Microservices (NDC Sydney, August 2016)

What are you doing?

Page 5: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 6: Building a Bank out of Microservices (NDC Sydney, August 2016)

James Lewis

Page 7: Building a Bank out of Microservices (NDC Sydney, August 2016)

James Lewis

Stefan Tilkov

Page 8: Building a Bank out of Microservices (NDC Sydney, August 2016)

James Lewis

Stefan Tilkov

Page 9: Building a Bank out of Microservices (NDC Sydney, August 2016)

James Lewis

Stefan TilkovMark Hibberd

Page 10: Building a Bank out of Microservices (NDC Sydney, August 2016)

James Lewis

Stefan TilkovMark Hibberd

Twitter

Page 11: Building a Bank out of Microservices (NDC Sydney, August 2016)

James Lewis

Stefan TilkovMark Hibberd

Twitter

Fred George

Page 12: Building a Bank out of Microservices (NDC Sydney, August 2016)

James Lewis

Stefan TilkovMark Hibberd

Twitter

Fred George

Adrian Cockcroft

Page 13: Building a Bank out of Microservices (NDC Sydney, August 2016)

James Lewis

Stefan TilkovMark Hibberd

Twitter

Fred George

Adrian Cockcroft

PricewaterhouseCoopers

Page 14: Building a Bank out of Microservices (NDC Sydney, August 2016)

James Lewis

Stefan TilkovMark Hibberd

Twitter

Fred George

Adrian Cockcroft

PricewaterhouseCoopers

Martin Fowler

Page 15: Building a Bank out of Microservices (NDC Sydney, August 2016)

James Lewis

Stefan TilkovMark Hibberd

Twitter

Fred George

Adrian Cockcroft

PricewaterhouseCoopers

Martin Fowler

Yamen Sader

Page 16: Building a Bank out of Microservices (NDC Sydney, August 2016)

James Lewis

Stefan TilkovMark Hibberd

Twitter

Fred George

Adrian Cockcroft

PricewaterhouseCoopers

Martin Fowler

Yamen Sader

Alvaro Sanchez

Page 17: Building a Bank out of Microservices (NDC Sydney, August 2016)

James Lewis

Stefan TilkovMark Hibberd

Twitter

Fred George

Adrian Cockcroft

PricewaterhouseCoopers

Martin Fowler

Yamen Sader

Alvaro Sanchez

Page 18: Building a Bank out of Microservices (NDC Sydney, August 2016)

Microservices?

Page 19: Building a Bank out of Microservices (NDC Sydney, August 2016)

micro - services

Page 20: Building a Bank out of Microservices (NDC Sydney, August 2016)

very small services

Page 21: Building a Bank out of Microservices (NDC Sydney, August 2016)

What’s a service?

Page 22: Building a Bank out of Microservices (NDC Sydney, August 2016)

W3C Web Services Architecture

Page 23: Building a Bank out of Microservices (NDC Sydney, August 2016)

W3C Web Services Architecture

RESTful services

Page 24: Building a Bank out of Microservices (NDC Sydney, August 2016)

W3C Web Services Architecture

RESTful services

Page 25: Building a Bank out of Microservices (NDC Sydney, August 2016)

W3C Web Services Architecture

RESTful services

Something entirely different?

Page 26: Building a Bank out of Microservices (NDC Sydney, August 2016)

How small?

Page 27: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 28: Building a Bank out of Microservices (NDC Sydney, August 2016)

“small enough and no smaller” - Sam Newman

Page 29: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 30: Building a Bank out of Microservices (NDC Sydney, August 2016)

We all agree on one thing…

Page 31: Building a Bank out of Microservices (NDC Sydney, August 2016)

Kenn

y Ba

stan

i ke

nnyb

asta

ni.c

om

Rod

Cur

rie

open

softw

ares

olut

ions

.com

Kenn

y Ba

stan

i ds

guid

e.bi

z

Susa

n H

all

then

ewst

ack.

io

Gra

ham

Lea

gr

aham

lea.

com

Jaso

n C

ham

bers

m

icro

svcs

.io

Sam

New

man

sa

mne

wm

an.io

Page 32: Building a Bank out of Microservices (NDC Sydney, August 2016)

Striving for microservices is stupid

Page 33: Building a Bank out of Microservices (NDC Sydney, August 2016)

“Cra

nes

near

the

Alex

ande

rpla

tz in

Ber

lin” b

y Ti

ll Kr

ech

Building a

Bank out of

Microservices

Page 34: Building a Bank out of Microservices (NDC Sydney, August 2016)

Some experts might think we’re stupid

‘Stupid V’ by Laura Lewis

Page 35: Building a Bank out of Microservices (NDC Sydney, August 2016)

Adrian Cockcroft - Battery Ventures

Page 36: Building a Bank out of Microservices (NDC Sydney, August 2016)

‘Kevin Rudd official portrait’ by Australian Department of Foreign Affairs and Trade

Questions

Page 37: Building a Bank out of Microservices (NDC Sydney, August 2016)

‘Kevin Rudd official portrait’ by Australian Department of Foreign Affairs and Trade

QuestionsWho are we, and why are we building a bank?

What exactly are we building?

How are we building it, and why that way?

What’s going well and what lessons have we learned?

Where have we got to?

Page 38: Building a Bank out of Microservices (NDC Sydney, August 2016)

Other questions welcome at the end

Page 39: Building a Bank out of Microservices (NDC Sydney, August 2016)

Who are we, and why are we building a bank?

What exactly are we building?

How are we building it, and why that way?

What’s going well and what lessons have we learned?

Where have we got to?

Page 40: Building a Bank out of Microservices (NDC Sydney, August 2016)

2003:

Page 41: Building a Bank out of Microservices (NDC Sydney, August 2016)

“Specialist Credit Card Institution” license

In-store Payments Competition

Page 42: Building a Bank out of Microservices (NDC Sydney, August 2016)

Revolutionise banking in Australia for small & medium businesses

“Home Market: 1941 in Worthington, Ohio” - Don O’Brien

Page 43: Building a Bank out of Microservices (NDC Sydney, August 2016)

2007: ……

Page 44: Building a Bank out of Microservices (NDC Sydney, August 2016)

2007: ……

First product launched

Page 45: Building a Bank out of Microservices (NDC Sydney, August 2016)

2007: ……

First product launched

Page 46: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 47: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 48: Building a Bank out of Microservices (NDC Sydney, August 2016)

Increasing revenue

Page 49: Building a Bank out of Microservices (NDC Sydney, August 2016)

Profitable!

Break-even took a while

Six years of losses

Page 50: Building a Bank out of Microservices (NDC Sydney, August 2016)

“I want my money sooner.”

Page 51: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 52: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 53: Building a Bank out of Microservices (NDC Sydney, August 2016)

Experiments!

Page 54: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 55: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 56: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 57: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 58: Building a Bank out of Microservices (NDC Sydney, August 2016)

Early 2014

Boss: “We’d like to start building a bank.

Page 59: Building a Bank out of Microservices (NDC Sydney, August 2016)

Early 2014

Boss: “We’d like to start building a bank.

Can your team start on that next week?”

Page 60: Building a Bank out of Microservices (NDC Sydney, August 2016)

Me: “Okay”

Page 61: Building a Bank out of Microservices (NDC Sydney, August 2016)

Who are we, and why are we building a bank?

What exactly are we building?

How are we building it, and why that way?

What’s going well and what lessons have we learned?

Where have we got to?

Page 62: Building a Bank out of Microservices (NDC Sydney, August 2016)

Core banking system for deposit accounts

Page 63: Building a Bank out of Microservices (NDC Sydney, August 2016)

Core banking system for deposit accounts

Interest-bearing

Page 64: Building a Bank out of Microservices (NDC Sydney, August 2016)

Core banking system for deposit accounts

Interest-bearing

Integrated with EFTPOS settlements

Page 65: Building a Bank out of Microservices (NDC Sydney, August 2016)

Core banking system for deposit accounts

Interest-bearing

Integrated with EFTPOS settlements

Xero integration: reconciliation & bill payments

Page 66: Building a Bank out of Microservices (NDC Sydney, August 2016)

Core banking system for deposit accounts

Interest-bearing

Integrated with EFTPOS settlements

Xero integration: reconciliation & bill payments

Mobile app for approving bills and other stuff

Page 67: Building a Bank out of Microservices (NDC Sydney, August 2016)

Who are we, and why are we building a bank?

What exactly are we building?

How are we building it, and why that way?

What’s going well and what lessons have we learned?

Where have we got to?

Page 68: Building a Bank out of Microservices (NDC Sydney, August 2016)

AWS

AngularJS React.js

HaskellScala

GoNodeJS

GitHub TravisCI Docker

MongoDB Cassandra

Hadoop

Spark

Euereka< 1,000 line

services!

Page 69: Building a Bank out of Microservices (NDC Sydney, August 2016)

AWS

AngularJS React.js

HaskellScala

GoNodeJS

GitHub TravisCI Docker

MongoDB Cassandra

Hadoop

Spark

Euereka

NOT< 1,000 line

services!

Page 70: Building a Bank out of Microservices (NDC Sydney, August 2016)

Our hardware in our racks at HA data centres

JS / jQuery

JavaGit

Jenkins

VMWare

MySQL

Spring + Spring MVC

Deployment Control

RabbitMQ

AndroidiOS C C#.NET

Page 71: Building a Bank out of Microservices (NDC Sydney, August 2016)

Tech stack != How are we building it?

Page 72: Building a Bank out of Microservices (NDC Sydney, August 2016)

Microservices!

Page 73: Building a Bank out of Microservices (NDC Sydney, August 2016)

Distributed system

Software SoftwareNetwork

Page 74: Building a Bank out of Microservices (NDC Sydney, August 2016)

Single-responsibility services

Page 75: Building a Bank out of Microservices (NDC Sydney, August 2016)

Single-responsibility services

An autonomous piece of software that interacts with other software

Page 76: Building a Bank out of Microservices (NDC Sydney, August 2016)

Single-responsibility services

Page 77: Building a Bank out of Microservices (NDC Sydney, August 2016)

‘Good work guys, why don't you take a break’ by Meme Binge

Page 78: Building a Bank out of Microservices (NDC Sydney, August 2016)

Single-responsibility services

Define the responsibility up front, document it

Page 79: Building a Bank out of Microservices (NDC Sydney, August 2016)

Single-responsibility services

Cohesion at the architecture level

Page 80: Building a Bank out of Microservices (NDC Sydney, August 2016)

Well-named services

“What is this service responsible for?”

Page 81: Building a Bank out of Microservices (NDC Sydney, August 2016)

Well-named services

Self-documenting code at the architecture level

Page 82: Building a Bank out of Microservices (NDC Sydney, August 2016)

Responsible (Autonomous) Services

Page 83: Building a Bank out of Microservices (NDC Sydney, August 2016)

Design services to maximise their chance

of completing their responsibility despite what’s going on around them.

Page 84: Building a Bank out of Microservices (NDC Sydney, August 2016)

Design services to minimise their dependency

on other services while doing work.

Page 85: Building a Bank out of Microservices (NDC Sydney, August 2016)

Responsible (Autonomous) Services

Agents at the architecture level

Page 86: Building a Bank out of Microservices (NDC Sydney, August 2016)

Data-owning services

Page 87: Building a Bank out of Microservices (NDC Sydney, August 2016)

Data-owning services

Encapsulation at the architecture level

Page 88: Building a Bank out of Microservices (NDC Sydney, August 2016)

Limited communication options

RabbitMQ for asynchronousREST for synchronous

Page 89: Building a Bank out of Microservices (NDC Sydney, August 2016)

Limited communication options

RabbitMQ for asynchronousREST for synchronous

Coding standards at the architecture level?

Page 90: Building a Bank out of Microservices (NDC Sydney, August 2016)

Preference for asynchronous comms

Page 91: Building a Bank out of Microservices (NDC Sydney, August 2016)

Preference for asynchronous comms

Background processing at the architecture level

Page 92: Building a Bank out of Microservices (NDC Sydney, August 2016)

Live-live redundancy is table stakes

Page 93: Building a Bank out of Microservices (NDC Sydney, August 2016)

Live-live redundancy is table stakes

Multi-threading at the architecture level

Page 94: Building a Bank out of Microservices (NDC Sydney, August 2016)

Deploys happen duringbusiness hours on weekdays

Page 95: Building a Bank out of Microservices (NDC Sydney, August 2016)

Deploys happen duringbusiness hours on weekdays

Page 96: Building a Bank out of Microservices (NDC Sydney, August 2016)

Deploys happen duringbusiness hours on weekdays

Architected for work/life balance

Page 97: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 98: Building a Bank out of Microservices (NDC Sydney, August 2016)

Deployed Incrementally

Page 99: Building a Bank out of Microservices (NDC Sydney, August 2016)

Some things we don’t have…

Page 100: Building a Bank out of Microservices (NDC Sydney, August 2016)

Continuous Delivery

(Fortnightly deploy)

Page 101: Building a Bank out of Microservices (NDC Sydney, August 2016)

Continuous Delivery

(Fortnightly deploy)

Stupid?

Page 102: Building a Bank out of Microservices (NDC Sydney, August 2016)

Service Discovery

(Host names in properties files)

Page 103: Building a Bank out of Microservices (NDC Sydney, August 2016)

Service Discovery

(Host names in properties files)

Stupid?

Page 104: Building a Bank out of Microservices (NDC Sydney, August 2016)

Strong service ownership

(Collective Code Ownership)

Page 105: Building a Bank out of Microservices (NDC Sydney, August 2016)

Strong service ownership

(Collective Code Ownership)

Stupid!

Page 106: Building a Bank out of Microservices (NDC Sydney, August 2016)

Non-Java services

(i.e.“best tool for the job” isn’t easy)

Page 107: Building a Bank out of Microservices (NDC Sydney, August 2016)

Non-Java services

(i.e.“best tool for the job” isn’t easy)

Missed the point?

Page 108: Building a Bank out of Microservices (NDC Sydney, August 2016)

Lots of production incidents

Page 109: Building a Bank out of Microservices (NDC Sydney, August 2016)

Why are we buildingthings this way?

Page 110: Building a Bank out of Microservices (NDC Sydney, August 2016)

Distributed system since 2006

Page 111: Building a Bank out of Microservices (NDC Sydney, August 2016)

2011

Backoffice webapp too big

Page 112: Building a Bank out of Microservices (NDC Sydney, August 2016)

Solution:

Smaller, more specific webapps for

new work

Page 113: Building a Bank out of Microservices (NDC Sydney, August 2016)

Backoffice webapp had too many responsibilities

Page 114: Building a Bank out of Microservices (NDC Sydney, August 2016)

Early 2013

Transaction switch deployed with links

Page 115: Building a Bank out of Microservices (NDC Sydney, August 2016)

Solution:

Links as separate services

Page 116: Building a Bank out of Microservices (NDC Sydney, August 2016)

Transaction switch + links =

too many responsibilities

Page 117: Building a Bank out of Microservices (NDC Sydney, August 2016)

Late 2013

Backend monolith

causing a lot of pain

Page 118: Building a Bank out of Microservices (NDC Sydney, August 2016)

Rapidly Growing Team

50% growth in a year … and more planned

Page 119: Building a Bank out of Microservices (NDC Sydney, August 2016)

Backend monolith had too many responsibilities

Page 120: Building a Bank out of Microservices (NDC Sydney, August 2016)

Solution:

No new responsibilities in the monolith

Page 121: Building a Bank out of Microservices (NDC Sydney, August 2016)

More webapps +More links +More backends +————————

Page 122: Building a Bank out of Microservices (NDC Sydney, August 2016)

More webapps +More links +More backends +————————Operations pain

Page 123: Building a Bank out of Microservices (NDC Sydney, August 2016)

First step:

Sit down and talk to each other

Retrospective on “First Deploys”

Page 124: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 125: Building a Bank out of Microservices (NDC Sydney, August 2016)

TRADE-OFF WARNING!

Page 126: Building a Bank out of Microservices (NDC Sydney, August 2016)

http://xkcd.com/1205/

Page 127: Building a Bank out of Microservices (NDC Sydney, August 2016)

Solution:

Automation for some things +

Repeatable manual processes

Page 128: Building a Bank out of Microservices (NDC Sydney, August 2016)

Early 2014

Let’s build a bank!

Page 129: Building a Bank out of Microservices (NDC Sydney, August 2016)

Early 2014

Let’s build a bank!

… with dozens of features and many teams all working

on it at the same time

Page 130: Building a Bank out of Microservices (NDC Sydney, August 2016)

Sounds great

Page 131: Building a Bank out of Microservices (NDC Sydney, August 2016)

Microservices can work for large greenfield projects

Page 132: Building a Bank out of Microservices (NDC Sydney, August 2016)

But…

maybe you need to

already be well along the

road to microservices?

‘Sherwin Range, Benton Crossing’ by “TheDailyNathan”

Page 133: Building a Bank out of Microservices (NDC Sydney, August 2016)

We got there in stages

Page 134: Building a Bank out of Microservices (NDC Sydney, August 2016)

Micro(?)servicesSmaller Services

DistributedMonolith

‘Hum

an e

volu

tion

sche

me’

by

José

-Man

uel B

enito

s

Page 135: Building a Bank out of Microservices (NDC Sydney, August 2016)

Key to progress:

Kill your monolith addiction

Adding to monoliths is easy Do the hard thing!

Page 136: Building a Bank out of Microservices (NDC Sydney, August 2016)

Who are we, and why are we building a bank?

What exactly are we building?

How are we building it, and why that way?

What’s going well and what lessons have we learned?

Where have we got to?

Page 137: Building a Bank out of Microservices (NDC Sydney, August 2016)

Small services + small teams =

productivity

Page 138: Building a Bank out of Microservices (NDC Sydney, August 2016)

Small services + small teams =

productivityLimited in responsibility

Page 139: Building a Bank out of Microservices (NDC Sydney, August 2016)

Small services + small teams =

productivityLimited in responsibility

3 pairs + tester + lead

Page 140: Building a Bank out of Microservices (NDC Sydney, August 2016)

Is this small?

Median about 2,500 LOC

Page 141: Building a Bank out of Microservices (NDC Sydney, August 2016)

Data ownership

Smaller, easier to understand schemas

Page 142: Building a Bank out of Microservices (NDC Sydney, August 2016)

Data ownership

Prevents inappropriate joining and data re-purposing

Page 143: Building a Bank out of Microservices (NDC Sydney, August 2016)

Preference for asynchronous comms

Page 144: Building a Bank out of Microservices (NDC Sydney, August 2016)

Why should your process wait for a response if no one is waiting for your

process?

Page 145: Building a Bank out of Microservices (NDC Sydney, August 2016)

Why should your process wait for a response if no one is waiting for your

process?

Temporal Coupling

Page 146: Building a Bank out of Microservices (NDC Sydney, August 2016)

Synchronous comms seem simple, but that’s an illusion

Page 147: Building a Bank out of Microservices (NDC Sydney, August 2016)

Increase service autonomy (and decrease temporal coupling) by caching data where processing

happens

Page 148: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 149: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 150: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 151: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 152: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 153: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 154: Building a Bank out of Microservices (NDC Sydney, August 2016)

TRADE-OFF WARNING!

We just increased service autonomy.

Page 155: Building a Bank out of Microservices (NDC Sydney, August 2016)

TRADE-OFF WARNING!

We just increased service autonomy.

We also introduced eventual consistency.

Page 156: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 157: Building a Bank out of Microservices (NDC Sydney, August 2016)

Has to be okay if this is not 100% up to date.

Page 158: Building a Bank out of Microservices (NDC Sydney, August 2016)

Data duplication becomes the norm

Synchronisation becomes a concern

Page 159: Building a Bank out of Microservices (NDC Sydney, August 2016)

Sometimes it’s better to move processing to where the data is

Page 160: Building a Bank out of Microservices (NDC Sydney, August 2016)

Whole tables of data?

Page 161: Building a Bank out of Microservices (NDC Sydney, August 2016)

Whole tables of data?

Page 162: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 163: Building a Bank out of Microservices (NDC Sydney, August 2016)

Distinguishing betweencommand messages and event messages

Use both to managecoupling of bounded contexts

Page 164: Building a Bank out of Microservices (NDC Sydney, August 2016)

When should I send a command?

When should I send an event?

Page 165: Building a Bank out of Microservices (NDC Sydney, August 2016)

How can I decide whether to send a command or an event?

Page 166: Building a Bank out of Microservices (NDC Sydney, August 2016)

Domain Coupling =

Knowledge of existence, responsibilities and domain language

of other components

Page 167: Building a Bank out of Microservices (NDC Sydney, August 2016)

What’s the difference between a Command and an Event?

Page 168: Building a Bank out of Microservices (NDC Sydney, August 2016)

What’s the difference between a Command and an Event?

The direction of the Domain Coupling

Page 169: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 170: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 171: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 172: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 173: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 174: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 175: Building a Bank out of Microservices (NDC Sydney, August 2016)

Heuristics• Cardinality • Responsibility Cohesion • Weight of Responsibility • Architectural Layers

Page 176: Building a Bank out of Microservices (NDC Sydney, August 2016)

Heuristics• Cardinality • Responsibility Cohesion • Weight of Responsibility • Architectural LayersTRA

DE-OFF

WARNING

!

Page 177: Building a Bank out of Microservices (NDC Sydney, August 2016)

Use commands and events.

Careful decisions can be used to control domain coupling.

Page 178: Building a Bank out of Microservices (NDC Sydney, August 2016)

Avoid distributed transactions

Be on the lookout for them!

Page 179: Building a Bank out of Microservices (NDC Sydney, August 2016)

Example of a distributed transaction hiding in plain sight

MessageBroker

TyroService

Business data Messages

Page 180: Building a Bank out of Microservices (NDC Sydney, August 2016)

Avoiding distributed transactions, preventing data loss with “Async Rabbit” pattern

TyroService

1. Business data & messages

2a. Messages 2b. Messages

MessageBroker

Page 181: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 182: Building a Bank out of Microservices (NDC Sydney, August 2016)

Idempotence

Page 183: Building a Bank out of Microservices (NDC Sydney, August 2016)

Idempotence

“Doing it twice = doing it once” - Graham Lea

Page 184: Building a Bank out of Microservices (NDC Sydney, August 2016)

Idempotence in Software Systems

Service A MessageBroker Service B

Receive ACK timeout & re-transmit

?

Page 185: Building a Bank out of Microservices (NDC Sydney, August 2016)

Service A MessageBroker Service B

Send ACK timeout & re-transmit

?

Idempotence in Software Systems

Page 186: Building a Bank out of Microservices (NDC Sydney, August 2016)

Service A MessageBroker Service B

Batch job re-run

Idempotence in Software Systems

Page 187: Building a Bank out of Microservices (NDC Sydney, August 2016)

Service A

MessageBroker

Service B

Redundant delivery

MessageBroker

Idempotence in Software Systems

Page 188: Building a Bank out of Microservices (NDC Sydney, August 2016)

Service

Many similar scenarios with REST

?

Idempotence in Software Systems

Page 189: Building a Bank out of Microservices (NDC Sydney, August 2016)

Hint: Duplicate detection counts

Page 190: Building a Bank out of Microservices (NDC Sydney, August 2016)

Deploy Independence

Let’s change this and deploy it!

Page 191: Building a Bank out of Microservices (NDC Sydney, August 2016)

Deploy Independence

Hope none of these break!

😬

Page 192: Building a Bank out of Microservices (NDC Sydney, August 2016)

Backwards Compatibility Testing

Page 193: Building a Bank out of Microservices (NDC Sydney, August 2016)

Backwards Compatibility Testing

Got a tester who can regression test every flow

that goes through here?

Page 194: Building a Bank out of Microservices (NDC Sydney, August 2016)

Backwards Compatibility Testing

(Do you even know every

activity that flows through here?!)

Page 195: Building a Bank out of Microservices (NDC Sydney, August 2016)

Backwards Compatibility Testing

It’s crucial

Automate it

Page 196: Building a Bank out of Microservices (NDC Sydney, August 2016)

Backwards Compatibility Testing

How?

For REST: Pact (& variants)

“Consumer-driven contracts”

Page 197: Building a Bank out of Microservices (NDC Sydney, August 2016)

Backwards Compatibility Testing with Pact

Source: https://github.com/realestate-com-au/pact

Page 198: Building a Bank out of Microservices (NDC Sydney, August 2016)

Backwards Compatibility Testing with Pact

Source: https://github.com/realestate-com-au/pact

Page 199: Building a Bank out of Microservices (NDC Sydney, August 2016)

Backwards Compatibility Testing with Pact

Polyglot implementations

Ruby, JVM, JS, growing…

https://github.com/realestate-com-au/pact

Page 200: Building a Bank out of Microservices (NDC Sydney, August 2016)

Backwards Compatibility Testing for message brokers

It’s hard!

Page 201: Building a Bank out of Microservices (NDC Sydney, August 2016)

Backwards Compatibility Testing for message brokers

Layer of indirection

Service A MessageBroker Service B

Messaging

Page 202: Building a Bank out of Microservices (NDC Sydney, August 2016)

Backwards Compatibility Testing for message brokers

https://www.flickr.com/photos/sydneyhistory/6899990333MessagingREST

Page 203: Building a Bank out of Microservices (NDC Sydney, August 2016)

Backwards Compatibility Testing for message brokers

Command: Senders are the “consumers”

Event:Receivers are the “consumers”

Page 204: Building a Bank out of Microservices (NDC Sydney, August 2016)

Who are we, and why are we building a bank?

What exactly are we building?

How are we building it, and why that way?

What’s going well and what lessons have we learned?

Where have we got to?

Page 205: Building a Bank out of Microservices (NDC Sydney, August 2016)

Do your own testing &

benchmarking of middleware

in your environment

https://www.flickr.com/photos/r00s/22248842680

Page 206: Building a Bank out of Microservices (NDC Sydney, August 2016)

Don’t have 2 - 3 different teams working in one

single-page webapp

‘Another rolling maul gets going’ by “Charlie”

Page 207: Building a Bank out of Microservices (NDC Sydney, August 2016)

Organise the work so that different

teams aren’t messing in the

same part of the codebase

Page 208: Building a Bank out of Microservices (NDC Sydney, August 2016)

Alternatively, organise the teams around the work or architecture

(“Inverse Conway Manoeuvre”)

Page 209: Building a Bank out of Microservices (NDC Sydney, August 2016)

Should You Do Integration Tests?

Page 210: Building a Bank out of Microservices (NDC Sydney, August 2016)

Should You Do Integration Tests?

(Cross-System Tests)

Page 211: Building a Bank out of Microservices (NDC Sydney, August 2016)

Contract

Page 212: Building a Bank out of Microservices (NDC Sydney, August 2016)

Contract

Journey

Page 213: Building a Bank out of Microservices (NDC Sydney, August 2016)

Cross System testsare always expensive

Page 214: Building a Bank out of Microservices (NDC Sydney, August 2016)

Cross System testsare always expensive

Some can be highly valuable

‘Gol

d-Ba

rs’ b

y M

ark

Her

pel

Page 215: Building a Bank out of Microservices (NDC Sydney, August 2016)

Cross System testsare always expensive

Some can be highly valuableTRA

DE-OFF W

ARNING!

TRADE-O

FF WARN

ING!

‘Gol

d-Ba

rs’ b

y M

ark

Her

pel

Page 216: Building a Bank out of Microservices (NDC Sydney, August 2016)

Mean time between failure

Mean time to recover

Page 217: Building a Bank out of Microservices (NDC Sydney, August 2016)

Mean time between failure

Mean time to recover

Merchantstaking payments

Page 218: Building a Bank out of Microservices (NDC Sydney, August 2016)

Mean time between failure

Mean time to recover

Cross-system tests

Merchantstaking payments

Page 219: Building a Bank out of Microservices (NDC Sydney, August 2016)

Mean time between failure

Mean time to recover

Cross-system tests

Merchantstaking payments

Financerunning a report

Page 220: Building a Bank out of Microservices (NDC Sydney, August 2016)

Mean time between failure

Mean time to recover

Cross-system tests Cheaper tests

Merchantstaking payments

Financerunning a report

Page 221: Building a Bank out of Microservices (NDC Sydney, August 2016)

Heuristic:

If we’d all be in serious trouble if it broke in Production, write a Cross-System Test

Page 222: Building a Bank out of Microservices (NDC Sydney, August 2016)

Heuristic:

If we’d all be in serious trouble if it broke in Production, write a Cross-System Test

Otherwise use unit testing, Pact testing and great monitoring for fast recovery

Page 223: Building a Bank out of Microservices (NDC Sydney, August 2016)

Keep reviewing your services’ responsibilities

Some may get “too big”

Some may be so small they cause issues

Page 224: Building a Bank out of Microservices (NDC Sydney, August 2016)

If Ops appears slow, don’t complain

Do something to help

‘Pushing the Car’ by Marina del Castell

Page 225: Building a Bank out of Microservices (NDC Sydney, August 2016)

Fortnightly deploys start to feel too slow

Page 226: Building a Bank out of Microservices (NDC Sydney, August 2016)

Get serious about security early

“Banksy Feb2011 131” by Lord Jim

Page 227: Building a Bank out of Microservices (NDC Sydney, August 2016)

Get expert help with security

Page 228: Building a Bank out of Microservices (NDC Sydney, August 2016)

Get expert help with security

Unless you do security full-time, you are not an expert

Page 229: Building a Bank out of Microservices (NDC Sydney, August 2016)

Layer Method Granularity

Application Message Authentication Message

Application Resource Authorisation User + Resource

Application User Authorisation Resource Type*

Application User Authentication User

Application Client Authorisation Resource Type*

Transport Encryption Connection

Transport Client Authentication Client

Transport Server Authentication vHost

Network Firewalling vHost

Physical Physical Security Rack

*Resource Type = URL pattern, e.g. /customers/{id}/transactions

UnauthorisedAccess

Eavesdropping

Message Tampering

Message Replay

How Do You Secure a Banking Service?

Page 230: Building a Bank out of Microservices (NDC Sydney, August 2016)

Bake security into your development process

Page 231: Building a Bank out of Microservices (NDC Sydney, August 2016)

Automate testing of security

‘Application field automotive’ by KUKA Systems GmbH

Page 232: Building a Bank out of Microservices (NDC Sydney, August 2016)

Automate testing of security

Best Option:

Failing test:“exploit possible!”

Page 233: Building a Bank out of Microservices (NDC Sydney, August 2016)

Automate testing of security

Second-Best Option:

Failing test: “protective tool is not integrated

correctly!”

Page 234: Building a Bank out of Microservices (NDC Sydney, August 2016)

Don’t expect much help on security from the web!

Page 235: Building a Bank out of Microservices (NDC Sydney, August 2016)

Don’t expect much help on security from the web!

Google: “microservices security questions”

Page 236: Building a Bank out of Microservices (NDC Sydney, August 2016)

Just assume villains are already inside your infrastructure

“Anonymous Hacker” by Brian Klug

Page 237: Building a Bank out of Microservices (NDC Sydney, August 2016)

Who are we, and why are we building a bank?

What exactly are we building?

How are we building it, and why that way?

What’s going well and what lessons have we learned?

Where have we got to?

Page 238: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 239: Building a Bank out of Microservices (NDC Sydney, August 2016)

18months

Page 240: Building a Bank out of Microservices (NDC Sydney, August 2016)

18months

7teams (by the end)

Page 241: Building a Bank out of Microservices (NDC Sydney, August 2016)

18months

7teams (by the end)

300Klines of code

Page 242: Building a Bank out of Microservices (NDC Sydney, August 2016)

18months

7teams (by the end)

300Klines of code

6,500automated tests

Page 243: Building a Bank out of Microservices (NDC Sydney, August 2016)

18months

7teams (by the end)

300Klines of code

6,500automated tests

21new services

Page 244: Building a Bank out of Microservices (NDC Sydney, August 2016)

18months

7teams (by the end)

300Klines of code

6,500automated tests

41person years of dev

21new services

Page 245: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 246: Building a Bank out of Microservices (NDC Sydney, August 2016)

August 2015

banking license

Page 247: Building a Bank out of Microservices (NDC Sydney, August 2016)

October 2015

product launched

August 2015

banking license

Page 248: Building a Bank out of Microservices (NDC Sydney, August 2016)

October 2015

product launchedDecember 2015

$100m investment

August 2015

banking license

Page 249: Building a Bank out of Microservices (NDC Sydney, August 2016)

October 2015

product launchedDecember 2015

$100m investment

August 2015

banking license

Page 250: Building a Bank out of Microservices (NDC Sydney, August 2016)

Can we build on top of it?

Page 251: Building a Bank out of Microservices (NDC Sydney, August 2016)

Can we build on top of it?

Yes we can!

‘Bob the Builder’ by OpenCage Systems

Page 252: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 253: Building a Bank out of Microservices (NDC Sydney, August 2016)

February 2016

lending kick-off

Page 254: Building a Bank out of Microservices (NDC Sydney, August 2016)

May 2016

pilot ready

February 2016

lending kick-off

Page 255: Building a Bank out of Microservices (NDC Sydney, August 2016)

May 2016

pilot readyJuly 1, 2016

first loan accepted

February 2016

lending kick-off

Page 256: Building a Bank out of Microservices (NDC Sydney, August 2016)

Summary

Page 257: Building a Bank out of Microservices (NDC Sydney, August 2016)

Summaryhexagons

Stupid!loosely coupled

bounded contexthoneycomb

distributed

single responsibility

well-named

autonomousdata encapsulation

asynchronous comms

operations painautomationmonolith

eventual consistency

domain coupling

commands & events

heuristicsidempotence

backwards compatibility

Pact

benchmarking

cross-system tests

security

Page 258: Building a Bank out of Microservices (NDC Sydney, August 2016)

One last question…

Page 259: Building a Bank out of Microservices (NDC Sydney, August 2016)

Should you copy us?

Page 260: Building a Bank out of Microservices (NDC Sydney, August 2016)

NO

Page 261: Building a Bank out of Microservices (NDC Sydney, August 2016)

Learn from us, but…

Page 262: Building a Bank out of Microservices (NDC Sydney, August 2016)

Context

Page 263: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 264: Building a Bank out of Microservices (NDC Sydney, August 2016)

Context!

2011: More webapps

2013: More links

2013: More backends

Operational scaling addressed

Page 265: Building a Bank out of Microservices (NDC Sydney, August 2016)

Monolith first?

Page 266: Building a Bank out of Microservices (NDC Sydney, August 2016)

Monolith first?

TRADE-OFF WARNING!

Page 267: Building a Bank out of Microservices (NDC Sydney, August 2016)

Growing teams and growing products

are threatened by monoliths

Page 268: Building a Bank out of Microservices (NDC Sydney, August 2016)

Microservices is…

Page 269: Building a Bank out of Microservices (NDC Sydney, August 2016)

Microservices is…

a collection of approaches

Page 270: Building a Bank out of Microservices (NDC Sydney, August 2016)

Microservices is…

a collection of approachesto modern problems

Page 271: Building a Bank out of Microservices (NDC Sydney, August 2016)

Microservices is…

a collection of approachesto modern problems

in distributed computing

Page 272: Building a Bank out of Microservices (NDC Sydney, August 2016)

Microservices is…

a collection of approachesto modern problems

in distributed computingand organising collaborative work.

Page 273: Building a Bank out of Microservices (NDC Sydney, August 2016)

Do you have the right problems?

Page 274: Building a Bank out of Microservices (NDC Sydney, August 2016)

Startup?

Microservices probably doesn’t solve your problems!

Page 275: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 276: Building a Bank out of Microservices (NDC Sydney, August 2016)
Page 277: Building a Bank out of Microservices (NDC Sydney, August 2016)

Microservices techniques are not a package deal

Use them selectively depending on your current problems

Page 278: Building a Bank out of Microservices (NDC Sydney, August 2016)

You’re not stupid for doing something different

if it works in your context

Page 279: Building a Bank out of Microservices (NDC Sydney, August 2016)

More questions?

Graham Lea @evolvable http://www.grahamlea.com/

Tyro Payments @tyro

http://www.tyro.com/