110
PRINCIPLES OF MICROSERVICES Sam Newman XP Days Ukraine December 2014 1

Principles of microservices XP Days Ukraine

Embed Size (px)

Citation preview

Page 1: Principles of microservices   XP Days Ukraine

PRINCIPLES OF MICROSERVICESSam Newman XP Days Ukraine December 2014

1

Page 2: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Page 3: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Accounts

Returns

Invoicing

Shipping

Inventory

Customer Service

Page 4: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Accounts

Returns

Invoicing

Shipping

Inventory

Customer Service

Small Autonomous services that work together

Page 5: Principles of microservices   XP Days Ukraine

@samnewman#xpdays4

Show Gilt, Groupon, Netflix, Amazon

Page 6: Principles of microservices   XP Days Ukraine

@samnewman#xpdays4

Show Gilt, Groupon, Netflix, Amazon

Page 7: Principles of microservices   XP Days Ukraine

@samnewman#xpdays4

Show Gilt, Groupon, Netflix, Amazon

Page 8: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Sam Newman

Building MicroservicesDESIGNING FINE-GRAINED SYSTEMS

Page 9: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Page 10: Principles of microservices   XP Days Ukraine

@samnewman#xpdays http://www.12factor.net/

Page 11: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strategic Goals Architectural

Principles Design and Delivery

Practices

Enable scalable business More customers/transactions Self-service for customers

Support entry into new markets Flexible operational processes New products and operational processes

Support innovation in existing markets Flexible operational processes New products and operational processes

Reduce inertia Make choices that favour rapid feedback and change, with reduced dependencies across teams.

Eliminate accidental complexity Aggressively retire and replace unnecessarily complex processes, systems, and integrations so that we can focus on the essential complexity.

Consistent interfaces and data flows Eliminate duplication of data and create clear systems of record, with consistent integration interfaces.

No silver bullets Off the shelf solutions deliver early value but create inertia and accidental complexity.

Standard REST/HTTP

Encapsulate legacy

Eliminate integration databases

Consolidate and cleanse data

Published integration model

Small independent Services

Continuous deployment

Minimal customisation of COTS/SAAS

Page 12: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Small Autonomous services that work together

Page 13: Principles of microservices   XP Days Ukraine

@samnewman#xpdays10

Principles Of Microservices

Page 14: Principles of microservices   XP Days Ukraine

@samnewman#xpdays10

Principles Of Microservices

Modelled Around Business Domain

Page 15: Principles of microservices   XP Days Ukraine

@samnewman#xpdays10

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation

Page 16: Principles of microservices   XP Days Ukraine

@samnewman#xpdays10

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Page 17: Principles of microservices   XP Days Ukraine

@samnewman#xpdays10

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Decentralise All The Things

Page 18: Principles of microservices   XP Days Ukraine

@samnewman#xpdays10

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Decentralise All The Things

Deploy Independently

Page 19: Principles of microservices   XP Days Ukraine

@samnewman#xpdays10

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Decentralise All The Things

Isolate Failure Deploy Independently

Page 20: Principles of microservices   XP Days Ukraine

@samnewman#xpdays10

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Decentralise All The Things

Isolate Failure Deploy Independently

Highly Observable

Page 21: Principles of microservices   XP Days Ukraine

@samnewman#xpdays10

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Decentralise All The Things

Isolate Failure Deploy Independently

Highly Observable

Page 22: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Accounts

Returns

Invoicing

Shipping

Inventory

Customer Service

Page 23: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Page 24: Principles of microservices   XP Days Ukraine

@samnewman#xpdays13

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Decentralise All The Things

Isolate Failure Deploy Independently

Highly Observable

Page 25: Principles of microservices   XP Days Ukraine

@samnewman#xpdays13

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Decentralise All The Things

Isolate Failure Deploy Independently

Highly Observable

Page 26: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Page 27: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

3 Months

2 Microservices

Page 28: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

3 Months

2 Microservices

12 Months

10 Microservices

Page 29: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

3 Months

2 Microservices

12 Months

10 Microservices

18 Months

60 Microservices

Page 30: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Infrastructure Automation

Page 31: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Infrastructure Automation

Automated Testing

Page 32: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Infrastructure Automation

Continuous Delivery

Automated Testing

Page 33: Principles of microservices   XP Days Ukraine

@samnewman#xpdays16

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Decentralise All The Things

Isolate Failure Deploy Independently

Highly Observable

✔ ✔

Page 34: Principles of microservices   XP Days Ukraine

@samnewman#xpdays16

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation

Hide Implementation Details

Decentralise All The Things

Isolate Failure Deploy Independently

Highly Observable

✔ ✔

Page 35: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

DB

Page 36: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

DB

Page 37: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

DB

Page 38: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

DB

Page 39: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

DB

HIDE YOUR DATABASE

Page 40: Principles of microservices   XP Days Ukraine

@samnewman#xpdayshttp://martinfowler.com/bliki/images/boundedContext/sketch.png

Page 41: Principles of microservices   XP Days Ukraine

@samnewman#xpdays19

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Decentralise All The Things

Isolate Failure Deploy Independently

Highly Observable

✔ ✔ ✔

Page 42: Principles of microservices   XP Days Ukraine

@samnewman#xpdays19

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Decentralise All The Things

Isolate Failure Deploy Independently

Highly Observable

✔ ✔ ✔

Page 43: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Page 44: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

What is autonomy?

Page 45: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

What is autonomy?

Giving people as much freedom as possible to do the job at hand

Page 46: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

What is autonomy?

Giving people as much freedom as possible to do the job at hand

Page 47: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

SELF-SERVICE

https://www.flickr.com/photos/katsrcool/15184711908/

Page 48: Principles of microservices   XP Days Ukraine

@samnewman#xpdayshttp://tech.gilt.com/post/102628539834/making-architecture-work-in-microservice

SHARED GOVERNANCE

Page 49: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

OWNER-OPERATOR

https://www.flickr.com/photos/stevendepolo/5939055612

Page 50: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

INTERNAL OPEN SOURCE

Page 51: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

DUMB-PIPES, SMART ENDPOINTS

Magical Mystery Bus

Page 52: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Magical Mystery Bus

Page 53: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Page 54: Principles of microservices   XP Days Ukraine

@samnewman#xpdays28

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Isolate Failure Deploy Independently

Highly Observable

✔ ✔ ✔

Decentralise All The Things ✔

Page 55: Principles of microservices   XP Days Ukraine

@samnewman#xpdays28

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Isolate Failure Deploy Independently

Highly Observable

✔ ✔ ✔

Decentralise All The Things ✔

Page 56: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

After the break!

Page 57: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

ONE SERVICE PER-HOST

Host

Service

Page 58: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

ONE SERVICE PER-HOST

Host

Service

Host

Service Service

Service Service

VS

Page 59: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

CONSUMER-DRIVEN CONTRACTS

Expectations

Prod

Shipping Inventory

Page 60: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

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

Page 61: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

CO-EXIST ENDPOINTS

Customer Service

Shipping

Page 62: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

CO-EXIST ENDPOINTS

Customer Service

Shipping

V2V1

Page 63: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

CO-EXIST ENDPOINTS

Customer Service

Shipping

V2V1

Page 64: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

CO-EXIST ENDPOINTS

Customer Service

Shipping

V2

Page 65: Principles of microservices   XP Days Ukraine

@samnewman#xpdays34

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Isolate Failure

Highly Observable

✔ ✔ ✔

Decentralise All The Things ✔

Deploy Independently✔

Page 66: Principles of microservices   XP Days Ukraine

@samnewman#xpdays34

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Isolate Failure

Highly Observable

✔ ✔ ✔

Decentralise All The Things ✔

Deploy Independently✔

Page 67: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Page 68: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

1 in 100

Page 69: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

1 in 100

Page 70: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

4 in 100

Page 71: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Page 72: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App

Legacy AppLegacy App

Page 73: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App

Legacy App

Requests

Legacy App

Page 74: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App

Legacy App

Requests

Legacy App

Page 75: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App

Legacy App

Requests

Legacy App

Page 76: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App

Legacy App

Requests

Legacy App

30 - 60 Concurrent Requests

Page 77: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App

Legacy App

Requests

Legacy App

30 - 60 Concurrent Requests

> 800 Concurrent Requests

Page 78: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App

Legacy App

Requests

Legacy App

30 - 60 Concurrent Requests

> 800 Concurrent Requests

Page 79: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App Legacy App Legacy App

Thread Pool

Page 80: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App Legacy App Legacy App

Thread Pool

Failing…slowly!

Page 81: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App Legacy App Legacy App

Thread Pool

Failing…slowly!

Page 82: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App Legacy App Legacy App

Thread Pool

Failing…slowly!

Thread-pool exhausted

Page 83: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App Legacy App Legacy App

Thread Pool

Failing…slowly!

Thread-pool exhausted

No requests to other downstream apps

Page 84: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App Legacy App Legacy App

Thread Pool

Failing…slowly!

Thread-pool exhausted

No requests to other downstream apps

Page 85: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App Legacy App Legacy App

Thread Pool

Failing…slowly!

Thread-pool exhausted

Requests Building Up

No requests to other downstream apps

Page 86: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App Legacy App Legacy App

Thread Pool

Page 87: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App Legacy App Legacy App

Fix Timeouts

Thread Pool

Page 88: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App Legacy App Legacy App

Fix Timeouts

Thread Pool

Page 89: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App Legacy App Legacy App

Fix Timeouts

Thread Pool Thread PoolThread Pool

Page 90: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App Legacy App Legacy App

Fix Timeouts

Thread Pool Thread PoolThread PoolBulkhead

Downstream Connections

Page 91: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App Legacy App Legacy App

Fix Timeouts

Thread Pool Thread PoolThread PoolBulkhead

Downstream Connections

Page 92: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Strangler App

Legacy App Legacy App Legacy App

Fix Timeouts

Thread Pool Thread PoolThread PoolBulkhead

Downstream Connections

Circuit Breakers

Page 93: Principles of microservices   XP Days Ukraine

@samnewman#xpdays39

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Highly Observable

✔ ✔ ✔

Decentralise All The Things ✔

Deploy Independently✔Isolate Failure✔

Page 94: Principles of microservices   XP Days Ukraine

@samnewman#xpdays39

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Highly Observable

✔ ✔ ✔

Decentralise All The Things ✔

Deploy Independently✔Isolate Failure✔

Page 95: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Page 96: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

AGGREGATION

Page 97: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

LOGS

AGGREGATION

Page 98: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

LOGSSTATS

AGGREGATION

Page 99: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

CORRELATION IDS

Page 100: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

CORRELATION IDS

ID 8964

Page 101: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

CORRELATION IDS

ID 8964

ID 8964

ID 8964

ID 8964

ID 8964

Page 102: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Principles Of Microservices

Page 103: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Principles Of Microservices

Modelled Around Business Domain

Page 104: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation

Page 105: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Page 106: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Decentralise All The Things

Page 107: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Decentralise All The Things

Deploy Independently

Page 108: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Decentralise All The Things

Isolate Failure Deploy Independently

Page 109: Principles of microservices   XP Days Ukraine

@samnewman#xpdays

Principles Of Microservices

Modelled Around Business Domain

Culture Of Automation Hide Implementation

Details

Decentralise All The Things

Isolate Failure Deploy Independently

Highly Observable

Page 110: Principles of microservices   XP Days Ukraine

Sam Newman @samnewman

THANKS!