203
Microservices @Steve_Upton

DSR microservices

Embed Size (px)

Citation preview

Page 1: DSR microservices

Microservices@Steve_Upton

Page 2: DSR microservices

Who am I?● Steve Upton● English / Welsh / British / Irish(?)● BSc. Computer Science (Cardiff University)● Physics & Astronomy (Open University)● IBM (6 years)

○ Messaging○ OASIS MQTT TC member○ Working with clients on Microservice systems○ London μService user group

● HERE Berlin (6 months)○ Microservices○ Robots!

Page 3: DSR microservices

Who are you?

Page 4: DSR microservices

The (2) histories of Microservices

Why you shouldn’t do Microservices

What Microservices actually look like

The future of Microservices

Page 5: DSR microservices

The (2) histories of Microservices

Page 6: DSR microservices

The standard Microservices creation story

Page 7: DSR microservices
Page 8: DSR microservices

Monolith

DBHTTP DataAccess

Component

Component

Component

Component

...

HTTP

Page 9: DSR microservices

Monolith

DBHTTP DataAccess

Component

Component

Component

Component

...

HTTP

Page 10: DSR microservices

Monolith

DBHTTP DataAccess

Component

Component

Component

Component

...

HTTP

Page 11: DSR microservices

Monolith

DBHTTP DataAccess

Component

Component

Component

Component

...

HTTP

Page 12: DSR microservices

Tightly coupled, slow to change

Sharing hardware

Page 13: DSR microservices

Tightly coupled, slow to change

Sharing hardware

Needs knowledge of other components (interfaces)

Page 14: DSR microservices

Tightly coupled, slow to change

Sharing hardware

Needs knowledge of other components (interfaces)

Sharing libraries, platform, OS etc.

Page 15: DSR microservices

Tightly coupled, slow to change

Sharing hardware

Needs knowledge of other components (interfaces)

Sharing libraries, platform, OS etc.

Difficult to upgrade without affecting other services

Page 16: DSR microservices

Tightly coupled, slow to change

Sharing hardware

Needs knowledge of other components (interfaces)

Sharing libraries, platform, OS etc.

Difficult to upgrade without affecting other services

Teams have little choice in setup

Page 17: DSR microservices

Hard to scale

Vertical scaling easy, but ineffective

Page 18: DSR microservices

Hard to scale

Vertical scaling easy, but ineffective

Horizontal scaling helpful, but slow and expensive

Page 19: DSR microservices

Hard to scale

Vertical scaling easy, but ineffective

Horizontal scaling helpful, but slow and expensive

Scaling the whole monolith can be wasteful

Page 20: DSR microservices

Scaling the monolith

DBHTTP DataAccess

Service

Service

Service

Service

Service

HTTP DataAccess

Service

Service

Service

Service

Service

HTTP DataAccess

Component

Component

Component

Component

...

HTTP

Load

bal

ance

r

Page 21: DSR microservices

“...the average server operates at no more than 12 to 18 percent of its capacity”

Natural Resources Defense Council

Page 22: DSR microservices
Page 23: DSR microservices
Page 24: DSR microservices

?

Page 25: DSR microservices

Moving to the cloud

DBHTTP DataAccess

Component

Component

Component

...

HTTP

Service DB

Page 26: DSR microservices

Microservices

HTTP

HTTPService DB

Service DB

Service DB

Service DB

Page 27: DSR microservices

Resilience to failure

Able to isolate failures

Page 28: DSR microservices

Resilience to failure

Able to isolate failures

Gracefully adapt to failures

Page 29: DSR microservices

Resilience to failure

Able to isolate failures

Gracefully adapt to failures

Page 30: DSR microservices

Resilience to failure

Able to isolate failures

Gracefully adapt to failures

Quick recovery

Page 31: DSR microservices

Loosely coupled, easy to change

Teams free to choose OS, language, libraries etc.

Page 32: DSR microservices

Loosely coupled, easy to change

Teams free to choose OS, language, libraries etc.

Share contracts, not interfaces and internals

Little to no knowledge of other services needed

Page 33: DSR microservices

Loosely coupled, easy to change

Teams free to choose OS, language, libraries etc.

Share contracts, not interfaces and internals

Little to no knowledge of other services needed

No shared state

Free to upgrade and experiment

Page 34: DSR microservices

Easy to scale

Vertical scaling easy and more effective

Page 35: DSR microservices

Easy to scale

Vertical scaling easy and more effective

Horizontal scaling also easy!

Page 36: DSR microservices

Easy to scale

Vertical scaling easy and more effective

Horizontal scaling also easy!

More efficient use of resources

Page 37: DSR microservices

Easy to scale

Vertical scaling easy and more effective

Horizontal scaling also easy!

More efficient use of resources

Auto scaling of individual services possible

Page 38: DSR microservices

Auto scaling

Page 39: DSR microservices

ServiceService

ServiceService

Service

Auto scaling

Service

Load

Page 40: DSR microservices

“Cattle not pets”Gavin McCance, CERN

Page 41: DSR microservices

“Loosely coupled service oriented architecture with bounded contexts”

Adrian Cockcroft, Architect @ Netflix

Page 42: DSR microservices

“In short, the microservice architectural style is an approach to developing a single application as a suite of small services, each running in its

own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated

deployment machinery. There is a bare minimum of centralized management of these services, which may be written in different

programming languages and use different data storage technologies.”

James Lewis and Martin Fowler, ThoughtWorks

Page 43: DSR microservices
Page 45: DSR microservices

Atlas

Page 46: DSR microservices

The other story

Page 47: DSR microservices

The other storycredit to Fred George

Page 48: DSR microservices

Project delivery cycles

1980 1990 2000 2010

Pro

ject

dur

atio

n (lo

g)

1 week

1 month

1 year

5 years Waterfall

Page 49: DSR microservices

Project delivery cycles

1980 1990 2000 2010

Pro

ject

dur

atio

n (lo

g)

1 week

1 month

1 year

5 years Waterfall

Waterfall + OO

Page 50: DSR microservices

Project delivery cycles

1980 1990 2000 2010

Pro

ject

dur

atio

n (lo

g)

1 week

1 month

1 year

5 years Waterfall

Waterfall + OO

Agile

Page 51: DSR microservices

Project delivery cycles

1980 1990 2000 2010

Pro

ject

dur

atio

n (lo

g)

1 week

1 month

1 year

5 years Waterfall

Waterfall + OO

Agile

Agile + Lean

Page 52: DSR microservices

Hardware lead times

1990 2000 2010 2015

Ord

er le

ad ti

me

(log(

ish)

)

< 1 sec

1 hour

1 week

6 months Data center

5 secs

Page 53: DSR microservices

Hardware lead times

1990 2000 2010 2015

Ord

er le

ad ti

me

(log(

ish)

)

< 1 sec

1 hour

1 week

6 months Data center

Virtual machines

5 secs

Page 54: DSR microservices

Hardware lead times

1990 2000 2010 2015

Ord

er le

ad ti

me

(log(

ish)

)

< 1 sec

1 hour

1 week

6 months Data center

Virtual machines

Commercial cloud (AWS)

5 secs

PaaS

Page 55: DSR microservices

Hardware lead times

1990 2000 2010 2015

Ord

er le

ad ti

me

(log(

ish)

)

< 1 sec

1 hour

1 week

6 months Data center

Virtual machines

Commercial cloud (AWS)

Docker

FaaS

5 secs

PaaS

Page 56: DSR microservices

Project size

1990 2000 2010 2015

Pro

ject

siz

e (li

nes

of c

ode)

1,000

10,000

100,000

1,000,000 Java

Page 57: DSR microservices

Project size

1990 2000 2010 2015

Pro

ject

siz

e (li

nes

of c

ode)

1,000

10,000

100,000

1,000,000 Java

Ruby

Page 58: DSR microservices

Project size

1990 2000 2010 2015

Pro

ject

siz

e (li

nes

of c

ode)

1,000

10,000

100,000

1,000,000 Java

Ruby

Python

Page 59: DSR microservices

Project size

1990 2000 2010 2015

Pro

ject

siz

e (li

nes

of c

ode)

1,000

10,000

100,000

1,000,000 Java

Ruby

Python

Node.js

Page 60: DSR microservices

Onboarding the new dev...

credit: https://twitter.com/moonpolysoft/status/781868129269919744

Page 61: DSR microservices

Story time

Page 62: DSR microservices

Marx on Microservices

Page 63: DSR microservices

Marx on MicroservicesEconomic and Philosophic Manuscripts of 1844

Page 64: DSR microservices

Marx on MicroservicesEconomic and Philosophic Manuscripts of 1844

Gattungswesen (species-essence)

Workers feeling a connection to their work

Page 65: DSR microservices

Marx on MicroservicesEconomic and Philosophic Manuscripts of 1844

Gattungswesen (species-essence)

Workers feeling a connection to their work

Entfremdung (alienation)

Workers feel estranged from their work

Page 66: DSR microservices

“Any piece of software reflects the organizational structure that produced it”

Conway's Law

Page 67: DSR microservices

Inverse Conway Maneuver?

Page 68: DSR microservices

What sort of organisation do you want to work in?

Page 69: DSR microservices

Why you shouldn’t do Microservices

Page 70: DSR microservices

CAP TheoremDr. Eric Brewer (2000)

Page 71: DSR microservices

CAP Theorem

Consistency

Availability

Partition tolerance

Page 72: DSR microservices

CAP Theorem

Consistency(all requests return the correct results)

Availability

Partition tolerance

Page 73: DSR microservices

CAP Theorem

Consistency(all requests return the correct results)

Availability(all requests complete)

Partition tolerance

Page 74: DSR microservices

CAP Theorem

Consistency(all requests return the correct results)

Availability(all requests complete)

Partition tolerance(the network may fail)

Page 75: DSR microservices

CAP Theorem

Consistency(all requests return the correct results)

Availability(all requests complete)

Partition tolerance(the network may fail)

Pick 2

Page 76: DSR microservices

CAP Theorem - Example 1

[x]

Data storeUser 1 User 2

Page 77: DSR microservices

CAP Theorem - Example 1

[x]

Data storeUser 1 User 2

put(40)

Page 78: DSR microservices

CAP Theorem - Example 1

[40]

Data storeUser 1 User 2

Page 79: DSR microservices

CAP Theorem - Example 1

[40]

Data storeUser 1 User 2

get

Page 80: DSR microservices

CAP Theorem - Example 1

[40]

Data storeUser 1 User 2

40

Page 81: DSR microservices

CAP Theorem - Example 1

[40]

Data storeUser 1 User 2

40

✔ Consistent (correct)✔ Available (answered)❌ Partition tolerant (no network partitions)

Page 82: DSR microservices

CAP Theorem - Example 1

[40]

Data storeUser 1 User 2

40

✔ Consistent (correct)✔ Available (answered)❌ Partition tolerant (no network partitions)

[PROBLEM] No real world system looks like this

Page 83: DSR microservices

CAP Theorem - Example 2

[40]

Data store (US)User 1 User 2

[40]

Data store (EU)

Page 84: DSR microservices

CAP Theorem - Example 2

[40]

Data store (US)User 1 User 2

put(60) [40]

Data store (EU)

Page 85: DSR microservices

CAP Theorem - Example 2

[60]

Data store (US)User 1 User 2

[40]

Data store (EU)

Page 86: DSR microservices

CAP Theorem - Example 2

[60]

Data store (US)User 1 User 2

[40]

Data store (EU)

Page 87: DSR microservices

CAP Theorem - Example 2

[60]

Data store (US)User 1 User 2

[40]

Data store (EU)

get

What now?

Page 88: DSR microservices

CAP Theorem - Example 2

[60]

Data store (US)User 1

User 2

[40]

Data store (EU)

get ⟶ 40

Page 89: DSR microservices

CAP Theorem - Example 2

[60]

Data store (US)User 1

User 2

[40]

Data store (EU)

get ⟶ 40

❌ Consistent (incorrect)✔ Available (answered)✔ Partition tolerant

Page 90: DSR microservices

CAP Theorem - Example 2

[60]

Data store (US)User 1

User 2

[40]

Data store (EU)

get ⟶ 40

❌ Consistent (incorrect)✔ Available (answered)✔ Partition tolerant

User 2

wait

Page 91: DSR microservices

CAP Theorem - Example 2

[60]

Data store (US)User 1

User 2

[40]

Data store (EU)

get ⟶ 40

❌ Consistent (incorrect)✔ Available (answered)✔ Partition tolerant

User 2

wait

✔ Consistent (correct)❌ Available (not answered)✔ Partition tolerant

Page 92: DSR microservices
Page 93: DSR microservices

Profile picture?

Page 94: DSR microservices

Profile picture?

Bank balance?

Page 95: DSR microservices

Profile picture?

Bank balance?

Real time chat?

Page 96: DSR microservices

Profile picture?

Bank balance?

Real time chat?

Football scores?

Page 97: DSR microservices

Profile picture?

Bank balance?

Real time chat?

Football scores?

Parcel tracker?

Page 98: DSR microservices

Pick 2

Page 99: DSR microservices

Pick 2

Page 100: DSR microservices

Pick 2

Understand the tradeoffs

Page 101: DSR microservices

All distributed systems have to deal with CAP

Page 102: DSR microservices

All distributed systems have to deal with CAP

Microservices add CAP where it wasn’t before

Page 103: DSR microservices

What Microservices actually look like

Page 104: DSR microservices

Continuous Delivery

Page 105: DSR microservices

“If you have more meetings than releases, you’re an enterprise company”

Clifton Cunningham, CTO @ TES Global

Page 106: DSR microservices

Containers

Page 107: DSR microservices

Containerscredit to Anne Currie

Page 108: DSR microservices

Bare Metal

Page 109: DSR microservices

Bare Metal

✔ Powerful

✔ Simple

Page 110: DSR microservices

Bare Metal

✔ Powerful

✔ Simple

❌ Brittle

❌ Inflexible

Page 111: DSR microservices

Bare Metal

✔ Powerful

✔ Simple

❌ Brittle

❌ Inflexible

Page 112: DSR microservices

Virtual Machines

Page 113: DSR microservices

Virtual Machines

✔ Flexible

✔ Networking

✔ Security

Page 114: DSR microservices

Virtual Machines

✔ Flexible

✔ Networking

✔ Security

❌ Overweight

Page 115: DSR microservices

Virtual Machines

✔ Flexible

✔ Networking

✔ Security

❌ Overweight

Page 116: DSR microservices

Virtual Machines

✔ Flexible

✔ Networking

✔ Security

❌ Overweight

Page 117: DSR microservices

Containers

Page 118: DSR microservices

Containers

✔ Lightweight

✔ Agile

Page 119: DSR microservices

Containers

✔ Lightweight

✔ Agile

❌ Untested

❌ Networking

❌ Security

Page 120: DSR microservices

Containers

✔ Lightweight

✔ Agile

❌ Untested

❌ Networking

❌ Security

Page 121: DSR microservices

Containers

✔ Lightweight

✔ Agile

❌ Untested

❌ Networking

❌ Security

Page 122: DSR microservices
Page 123: DSR microservices

Exercise

Page 124: DSR microservices

Configuration Management

Page 125: DSR microservices
Page 126: DSR microservices
Page 127: DSR microservices
Page 128: DSR microservices

Inter-service communication

Page 129: DSR microservices

Build TestHTTP

Page 130: DSR microservices

Build Test

Email

Page 131: DSR microservices

Build Test

Email

Slack

Page 132: DSR microservices

Build Test

Email

Slack

Fireworks

Page 133: DSR microservices

Build Test

Email

Slack

Fireworks

Page 134: DSR microservices

Build Test

Email

Slack

Fireworks

Page 135: DSR microservices
Page 136: DSR microservices

“Service Discoveryis an anti-pattern”

Page 137: DSR microservices

“Service Discoveryis an anti-pattern”

Richard Rodger, CTO @ nearForm

Page 138: DSR microservices

MQ Light

Messaging!

Page 139: DSR microservices

Build Test

Email

Slack

Fireworks

RabbitMQ

Page 140: DSR microservices

Build Testpublish

Email

Slack

Fireworks

RabbitMQ

Page 141: DSR microservices

Build Testpublish

Email

Slack

Fireworks

RabbitMQ

subscribe

Page 142: DSR microservices

“Publish everything!”Tim Livesey, Droplet

Page 143: DSR microservices
Page 144: DSR microservices

Exercise

Page 145: DSR microservices
Page 146: DSR microservices

Lots of data sources

Page 147: DSR microservices

Lots of data sources

Lots of data consumers

Page 148: DSR microservices

Lots of data sources

Lots of data consumers

Lots of integrations

Page 149: DSR microservices

LinkedIn before

Page 150: DSR microservices

LinkedIn after

Page 151: DSR microservices

Up close

Page 152: DSR microservices

The log

Append only

Time ordered

Page 153: DSR microservices

Distributed logging

Page 154: DSR microservices
Page 155: DSR microservices

add(20)

add(5)

subtract(10)

add(15)

Page 156: DSR microservices

add(20)

add(5)

subtract(10)

add(15)

Page 157: DSR microservices

add(20)

add(5)

subtract(10)

add(15)

Page 158: DSR microservices

?

add(20)

add(5)

subtract(10)

add(15)

Page 159: DSR microservices

“If two identical, deterministic processes begin in the same state and get the same inputs in the

same order, they will produce the same output and end in the same state.”

State Machine Replication Principle, Jay Kreps, LinkedIn

Page 160: DSR microservices

30

add(20)

add(5)

subtract(10)

add(15)

?

Page 161: DSR microservices

Log as source of Truth

Page 162: DSR microservices

Event Sourcing

Page 163: DSR microservices

“We don’t care if our production system crashes.”Valerii Vasylkov, William Hill

Page 164: DSR microservices

Testing Microservices

Page 165: DSR microservices
Page 166: DSR microservices
Page 167: DSR microservices
Page 168: DSR microservices

Chaos Gorilla

Page 169: DSR microservices

Security Monkey

Page 170: DSR microservices

Janitor Monkey

Page 171: DSR microservices

Latency Monkey

Page 172: DSR microservices

Monitoring = Testing

Page 173: DSR microservices
Page 174: DSR microservices

“How big should my Microservice be?”Everyone

Page 175: DSR microservices

“The first draft of anything is shit”Ernest Hemingway

Page 176: DSR microservices

Monolith first?

Page 177: DSR microservices

The future of Microservices

Page 178: DSR microservices
Page 179: DSR microservices

Hardware lead times

1990 2000 2010 2015

Ord

er le

ad ti

me

(log(

ish)

)

< 1 sec

1 hour

1 week

6 months Data center

Virtual machines

Commercial cloud (AWS)

Docker

FaaS

5 secs

PaaS

Page 180: DSR microservices

Hardware lead times

1990 2000 2010 2015

Ord

er le

ad ti

me

(log(

ish)

)

< 1 sec

1 hour

1 week

6 months Data center

Virtual machines

Commercial cloud (AWS)

Docker

FaaS

5 secs

PaaS

Page 181: DSR microservices

Amazon Lambda

Serverless

‘Serverless’ (not really)

Function as a Service (FaaS)

No persistence, no upkeep costs

200 ms startup time (Node.js)

Page 182: DSR microservices

What is the role of a manager?

Page 183: DSR microservices

Managers

Provide guidance

Keep things ‘safe’

Organise the team

Page 184: DSR microservices

Managers Microservices

Provide guidance

Keep things ‘safe’

Organise the team

Explore new tech

Experiment

Enables self-organisation

Page 185: DSR microservices
Page 186: DSR microservices

“Microservices are hard. Some things you get for free, but you have to work for the good stuff. If you won’t put in the work, you shouldn’t be doing Microservices. (You should be doing that stuff

anyway!)”Steve Upton

Page 187: DSR microservices

“Microservices are hard. Some things you get for free, but you have to work for the good stuff. If you won’t put in the work, you shouldn’t be doing Microservices. (You should be doing that stuff

anyway!)”Steve Upton

Page 188: DSR microservices

“Microservices are hard. Some things you get for free, but you have to work for the good stuff. If you won’t put in the work, you shouldn’t be doing Microservices. (You should be doing that stuff

anyway!)”Steve Upton

Page 189: DSR microservices

“Microservices are hard. Some things you get for free, but you have to work for the good stuff. If you won’t put in the work, you shouldn’t be doing Microservices. (You should be doing that stuff

anyway!)”Steve Upton

Page 190: DSR microservices

“Microservices are hard. Some things you get for free, but you have to work for the good stuff. If you won’t put in the work, you shouldn’t be doing Microservices. (You should be doing that stuff

anyway!)”Steve Upton

Page 191: DSR microservices

“Microservices are hard. Some things you get for free, but you have to work for the good stuff. If you won’t put in the work, you shouldn’t be doing Microservices. (You should be doing that stuff

anyway!)”Steve Upton

Page 192: DSR microservices

Questions?@Steve_Uptonsteveupton.io

Page 196: DSR microservices

Extra material

Page 197: DSR microservices

Blue-Green deployment

Page 198: DSR microservices

User

Router

V1.0

V1.0

Page 199: DSR microservices

User

Router

V1.0

V1.1

Page 200: DSR microservices

User

Router

V1.0

V1.1

Page 201: DSR microservices

User

Router

V1.0

V1.1

Page 202: DSR microservices

User

Router

V1.0

V1.1

Page 203: DSR microservices

Possible with monoliths, just much harder!