Top Banner
Microservice Scars: Lessons we learnt Abhaya Chauhan @AbhayaChauhan www.abhayachauhan.com Joshua Toth @TothJoshuaJ
146

[DDD] Microservice scars

Jan 12, 2017

Download

Technology

Joshua Toth
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: [DDD] Microservice scars

Microservice Scars:Lessons we learnt

Abhaya Chauhan@AbhayaChauhan

www.abhayachauhan.comJoshua Toth@TothJoshuaJ

Page 2: [DDD] Microservice scars

Question Policy

Page 3: [DDD] Microservice scars

Let’s go on a Journey

Page 4: [DDD] Microservice scars

Context

Page 5: [DDD] Microservice scars

PageUp

Context

Page 6: [DDD] Microservice scars

19 years

Context

Page 7: [DDD] Microservice scars

The Monolith

Context

Page 8: [DDD] Microservice scars

Fragility

The Monolith

Context

Page 9: [DDD] Microservice scars

Agility

The Monolith

Context

Page 10: [DDD] Microservice scars

Complexity

The Monolith

Context

Page 11: [DDD] Microservice scars

Innovation

The Monolith

Context

Page 12: [DDD] Microservice scars

#Scale

Context

Page 13: [DDD] Microservice scars

If you can’t build a monolith, what makes you think

microservices are the answer?

Simon Brown

Context

Page 14: [DDD] Microservice scars

First rule of Distributed Computing

Context

Page 15: [DDD] Microservice scars

Don’t do it.

Context

Page 16: [DDD] Microservice scars

Why Microservices?

Context

Page 17: [DDD] Microservice scars

Reduce time to market

Context

Page 18: [DDD] Microservice scars

Autonomous Services

Context

Page 19: [DDD] Microservice scars

EnableEvolutionary Architecture

Context

Page 20: [DDD] Microservice scars
Page 21: [DDD] Microservice scars

Sprint Zero

Page 22: [DDD] Microservice scars

Decisions

Sprint Zero

Page 23: [DDD] Microservice scars

The stack

Sprint Zero

Page 24: [DDD] Microservice scars

Sprint Zero

Page 25: [DDD] Microservice scars

Sprint Zero

Frontend

Page 26: [DDD] Microservice scars

Sprint Zero

Backend

Frontend

Page 27: [DDD] Microservice scars

Sprint Zero

Backend

DB

Frontend

Page 28: [DDD] Microservice scars

Sprint Zero

Elastic Beanstalk

S3

Page 29: [DDD] Microservice scars

Self hosted

Sprint Zero

Page 30: [DDD] Microservice scars

Pact

Sprint Zero

Page 31: [DDD] Microservice scars
Page 32: [DDD] Microservice scars
Page 33: [DDD] Microservice scars

Infancy

Sprint Zero

Page 34: [DDD] Microservice scars

Limitations

Sprint Zero

Page 35: [DDD] Microservice scars

Investment

Sprint Zero

Page 36: [DDD] Microservice scars

Deployment

Sprint Zero

Page 37: [DDD] Microservice scars

Continuous

Sprint Zero

Page 38: [DDD] Microservice scars

Phabricator

Sprint Zero

Page 39: [DDD] Microservice scars

Sprint Zero

Page 40: [DDD] Microservice scars

Pipeline

Sprint Zero

Page 41: [DDD] Microservice scars

Sprint Zero

Page 42: [DDD] Microservice scars

A first

Sprint Zero

Page 43: [DDD] Microservice scars

F# Make (Fake)

Sprint Zero

Page 44: [DDD] Microservice scars

Monolith Deployment

Scripts

Sprint Zero

Page 45: [DDD] Microservice scars

Sharing != caring

Sprint Zero

Page 46: [DDD] Microservice scars

Sprint Zero

Page 47: [DDD] Microservice scars

Sprint Zero

Page 48: [DDD] Microservice scars

Clear separation

Sprint Zero

Page 49: [DDD] Microservice scars

Development Practices

Sprint Zero

Page 50: [DDD] Microservice scars

TDD

Sprint Zero

Page 51: [DDD] Microservice scars

BDD

Sprint Zero

Page 52: [DDD] Microservice scars

Sprint Zero

Page 53: [DDD] Microservice scars
Page 54: [DDD] Microservice scars

Elastic Beanstalk

Page 55: [DDD] Microservice scars
Page 56: [DDD] Microservice scars

Full stack

Elastic Beanstalk

Page 57: [DDD] Microservice scars

Visualization

Elastic Beanstalk

Page 58: [DDD] Microservice scars

Monitoring

Elastic Beanstalk

Page 59: [DDD] Microservice scars

Monitoring

Elastic Beanstalk

Page 60: [DDD] Microservice scars

Monitoring

Elastic Beanstalk

Page 61: [DDD] Microservice scars

Elastic Beanstalk

Page 62: [DDD] Microservice scars

No Downtime

Elastic Beanstalk

Page 63: [DDD] Microservice scars

50 shades of “fuck we can’t roll this back”

Grey

Elastic Beanstalk

Page 64: [DDD] Microservice scars

Authentication

Page 65: [DDD] Microservice scars

IdentityServer3(Locksmith)

OAuth2

Page 66: [DDD] Microservice scars

Immediate return

OAuth2

Page 67: [DDD] Microservice scars

Messaging

Page 68: [DDD] Microservice scars
Page 69: [DDD] Microservice scars

Messaging

Page 70: [DDD] Microservice scars

Messaging

Page 71: [DDD] Microservice scars

Messaging

Page 72: [DDD] Microservice scars

Request Response Pain

Messaging

Page 73: [DDD] Microservice scars

Resource intensive

Messaging

Page 74: [DDD] Microservice scars

Fault Tolerance

Messaging

Page 75: [DDD] Microservice scars

1 to 1 communication

Messaging

Page 76: [DDD] Microservice scars

Event Driven Architecture

Messaging

Page 77: [DDD] Microservice scars

Queuing (SQS)

Messaging

Page 78: [DDD] Microservice scars

Not Resource Intensive

Fault Tolerant

1 - many Communication

Messaging

Page 79: [DDD] Microservice scars

Not Resource Intensive

Fault Tolerant

1 - many Communication

Messaging

Page 80: [DDD] Microservice scars

Not Resource Intensive

Fault Tolerant

1 - many Communication

Messaging

Page 81: [DDD] Microservice scars

Not Resource Intensive

Fault Tolerant

1 - many Communication

Messaging

Page 82: [DDD] Microservice scars

Simple Notification Service (SNS)

Messaging

Page 83: [DDD] Microservice scars

Push messages

Messaging

Page 84: [DDD] Microservice scars

Mobile Devices

Messaging

Page 85: [DDD] Microservice scars

Mobile DevicesSMS

Messaging

Page 86: [DDD] Microservice scars

Mobile DevicesSMS

Emails

Messaging

Page 87: [DDD] Microservice scars

Mobile DevicesSMS

EmailsHTTP Endpoints

Messaging

Page 88: [DDD] Microservice scars

Mobile DevicesSMS

EmailsHTTP Endpoints

Lambda

Messaging

Page 89: [DDD] Microservice scars

Mobile DevicesSMS

EmailsHTTP Endpoints

LambdaQueues

Messaging

Page 90: [DDD] Microservice scars

Messaging

Page 91: [DDD] Microservice scars

Messaging

Page 92: [DDD] Microservice scars

Messaging

Page 93: [DDD] Microservice scars

Messaging

SNS + SQS = Amazing Service Bus

Page 94: [DDD] Microservice scars

Not Resource Intensive

Fault Tolerant

1 - many Communication

Messaging

Page 95: [DDD] Microservice scars

Circuit Breaker

Messaging

Page 96: [DDD] Microservice scars

Messaging

Page 97: [DDD] Microservice scars

CloudWatch

Messaging

Page 98: [DDD] Microservice scars

Historical Events

Messaging

Page 99: [DDD] Microservice scars

A store for events

Messaging

Page 100: [DDD] Microservice scars

Client subscriptions

Messaging

Page 101: [DDD] Microservice scars

DynamoDb

Page 102: [DDD] Microservice scars

Fully Managed NoSQL DB

DynamoDb

Page 103: [DDD] Microservice scars

Fully Managed NoSQL DB

DynamoDb

Page 104: [DDD] Microservice scars

Fast and Predictable

DynamoDb

Page 105: [DDD] Microservice scars

Distributed

DynamoDb

Page 106: [DDD] Microservice scars

Key-ValueDocument

DynamoDb

Page 107: [DDD] Microservice scars

Hash (Range)

Partition 1 Partition 2 Partition 3 Partition N

Read & Write capacity equally distributed

Max 400kb

DynamoDb

Page 108: [DDD] Microservice scars

1 Read unit = 4KB/s1 Write unit = 1KB/s

DynamoDb

Page 109: [DDD] Microservice scars

CQRS

DynamoDb

Page 110: [DDD] Microservice scars

DynamoDb

Page 111: [DDD] Microservice scars

Oh shit!

DynamoDb

Page 112: [DDD] Microservice scars

Write is 20x more expensive

DynamoDb

Page 113: [DDD] Microservice scars

DynamoDb

{"Key":"Mauritania","Value":"42803"},{"Key":"Mauritius","Value":"42804"},{"Key":"Mexico","Value":"42805"},{"Key":"Micronesia","Value":"42806"},{"Key":"Monaco","Value":"42807"},{"Key":"Mongolia","Value":"42808"},{"Key":"Montenegro","Value":"42809"},{"Key":"Montserrat","Value":"42810"},{"Key":"Morocco","Value":"42811"},{"Key":"Mozambique","Value":"42812"},{"Key":"Namibia","Value":"42813"},{"Key":"Nauru","Value":"42814"},{"Key":"Nepal","Value":"42815"},{"Key":"Netherlands","Value":"42816"},{"Key":"Netherlands Antilles","Value":"42817"},{"Key":"New Caledonia","Value":"42818"},{"Key":"New Zealand","Value":"42819"},{"Key":"Nicaragua","Value":"42820"},{"Key":"Niger","Value":"42821"},{"Key":"Nigeria","Value":"42822"},{"Key":"Niue","Value":"42823"},{"Key":"Northern Mariana Islands","Value":"42824"},{"Key":"Norway","Value":"42825"},{"Key":"Oman","Value":"42826"},{"Key":"Pakistan","Value":"42827"},{"Key":"Palau, Republic Of","Value":"42828"},{"Key":"Palestine","Value":"42829"},{"Key":"Panama","Value":"42830"},{"Key":"Papua New Guinea","Value":"42831"},{"Key":"Paraguay","Value":"42832"},{"Key":"Peru","Value":"42833"},{"Key":"Philippines","Value":"42834"},{"Key":"Poland","Value":"42835"},{"Key":"Portugal","Value":"42836"},{"Key":"Puerto Rico","Value":"42837"},{"Key":"Qatar","Value":"42838"},{"Key":"Republic Of Korea","Value":"42839"},{"Key":"Republic Of Moldova","Value":"42840"},{"Key":"Republic Of Yemen","Value":"42841"},{"Key":"Reunion","Value":"42842"},{"Key":"Romania","Value":"42843"},{"Key":"Russian Federation","Value":"42844"},{"Key":"Rwanda","Value":"42845"},{"Key":"Saint Kitts And Nevis","Value":"42846"},{"Key":"Saint Lucia","Value":"42847"},{"Key":"Sao Tome & Principe","Value":"42848"},{"Key":"Saudi Arabia","Value":"42849"},{"Key":"Senegal","Value":"42850"},{"Key":"Serbia","Value":"42851"},{"Key":"Serbia & Monten","Value":"42852"},{"Key":"Seychelles","Value":"42853"},{"Key":"Sierra Leone","Value":"42854"},{"Key":"Singapore","Value":"42855"},{"Key":"Slovakia","Value":"42856"},{"Key":"Slovenia","Value":"42857"},{"Key":"Solomon Islands","Value":"42858"},{"Key":"Somalia","Value":"42859"},{"Key":"South Africa","Value":"42860"},{"Key":"South Sudan","Value":"42861"},{"Key":"Spain","Value":"42862"},{"Key":"Sri Lanka","Value":"42863"},{"Key":"St. Vincent And The Grena","Value":"42864"},{"Key":"Sudan","Value":"42865"},{"Key":"Surinam","Value":"42866"},{"Key":"Swaziland","Value":"42867"},{"Key":"Sweden","Value":"42868"},{"Key":"Switzerland","Value":"42869"},{"Key":"Syrian Arab Republic","Value":"42870"},{"Key":"Tajikistan","Value":"42871"},{"Key":"Tanzania, United Rep. Of","Value":"42872"},{"Key":"Tfyr Of Macedonia","Value":"42873"},{"Key":"Thailand","Value":"42874"},{"Key":"Timor-Leste","Value":"42875"},{"Key":"Togo","Value":"42876"},{"Key":"Tokelau Islands","Value":"42877"},{"Key":"Tonga","Value":"42878"},{"Key":"Trinidad And Tobago","Value":"42879"},{"Key":"Tunisia","Value":"42880"},{"Key":"Turkey","Value":"42881"},{"Key":"Turkmenistan","Value":"42882"},{"Key":"Turks And Caicos Island","Value":"42883"},{"Key":"Mauritania","Value":"42803"},{"Key":"Mauritius","Value":"42804"},{"Key":"Mexico","Value":"42805"},{"Key":"Micronesia","Value":"42806"},{"Key":"Monaco","Value":"42807"},{"Key":"Mongolia","Value":"42808"},{"Key":"Montenegro","Value":"42809"},{"Key":"Montserrat","Value":"42810"},{"Key":"Morocco","Value":"42811"},{"Key":"Mozambique","Value":"42812"},{"Key":"Namibia","Value":"42813"},{"Key":"Nauru","Value":"42814"},{"Key":"Nepal","Value":"42815"},{"Key":"Netherlands","Value":"42816"},{"Key":"Netherlands Antilles","Value":"42817"},{"Key":"New Caledonia","Value":"42818"},{"Key":"New Zealand","Value":"42819"},{"Key":"Nicaragua","Value":"42820"},{"Key":"Niger","Value":"42821"},{"Key":"Nigeria","Value":"42822"},{"Key":"Niue","Value":"42823"},{"Key":"Northern Mariana Islands","Value":"42824"},{"Key":"Norway","Value":"42825"},{"Key":"Oman","Value":"42826"},{"Key":"Pakistan","Value":"42827"},{"Key":"Palau, Republic Of","Value":"42828"},{"Key":"Palestine","Value":"42829"},{"Key":"Panama","Value":"42830"},{"Key":"Papua New Guinea","Value":"42831"},{"Key":"Paraguay","Value":"42832"},{"Key":"Peru","Value":"42833"},{"Key":"Philippines","Value":"42834"},{"Key":"Poland","Value":"42835"},{"Key":"Portugal","Value":"42836"},{"Key":"Puerto Rico","Value":"42837"},{"Key":"Qatar","Value":"42838"},{"Key":"Republic Of Korea","Value":"42839"},{"Key":"Republic Of Moldova","Value":"42840"},{"Key":"Republic Of Yemen","Value":"42841"},{"Key":"Reunion","Value":"42842"},{"Key":"Romania","Value":"42843"},{"Key":"Russian Federation","Value":"42844"},{"Key":"Rwanda","Value":"42845"},{"Key":"Saint Kitts And Nevis","Value":"42846"},{"Key":"Saint Lucia","Value":"42847"},{"Key":"Sao Tome & Principe","Value":"42848"},{"Key":"Saudi Arabia","Value":"42849"},{"Key":"Senegal","Value":"42850"},{"Key":"Serbia","Value":"42851"},{"Key":"Serbia & Monten","Value":"42852"},{"Key":"Seychelles","Value":"42853"},{"Key":"Sierra Leone","Value":"42854"},{"Key":"Singapore","Value":"42855"},{"Key":"Slovakia","Value":"42856"},{"Key":"Slovenia","Value":"42857"}

Page 114: [DDD] Microservice scars

DynamoDb

{"Key":"Mauritania","Value":"42803"},{"Key":"Mauritius","Value":"42804"},{"Key":"Mexico","Value":"42805"},{"Key":"Micronesia","Value":"42806"},{"Key":"Monaco","Value":"42807"},{"Key":"Mongolia","Value":"42808"},{"Key":"Montenegro","Value":"42809"},{"Key":"Montserrat","Value":"42810"},{"Key":"Morocco","Value":"42811"},{"Key":"Mozambique","Value":"42812"},{"Key":"Namibia","Value":"42813"},{"Key":"Nauru","Value":"42814"},{"Key":"Nepal","Value":"42815"},{"Key":"Netherlands","Value":"42816"},{"Key":"Netherlands Antilles","Value":"42817"},{"Key":"New Caledonia","Value":"42818"},{"Key":"Nicaragua","Value":"42820"},{"Key":"Niger","Value":"42821"},{"Key":"Nigeria","Value":"42822"},{"Key":"Niue","Value":"42823"},{"Key":"Northern Mariana Islands","Value":"42824"},{"Key":"Norway","Value":"42825"},{"Key":"Oman","Value":"42826"},{"Key":"Pakistan","Value":"42827"},{"Key":"Palau, Republic Of","Value":"42828"},{"Key":"Palestine","Value":"42829"},{"Key":"Panama","Value":"42830"},{"Key":"Papua New Guinea","Value":"42831"},{"Key":"Paraguay","Value":"42832"},{"Key":"Peru","Value":"42833"},{"Key":"Philippines","Value":"42834"},{"Key":"Poland","Value":"42835"},{"Key":"Portugal","Value":"42836"},{"Key":"Puerto Rico","Value":"42837"},{"Key":"Qatar","Value":"42838"},{"Key":"Republic Of Korea","Value":"42839"},{"Key":"Republic Of Moldova","Value":"42840"},{"Key":"Republic Of Yemen","Value":"42841"},{"Key":"Romania","Value":"42843"},{"Key":"Russian Federation","Value":"42844"},{"Key":"Rwanda","Value":"42845"},{"Key":"Saint Kitts And Nevis","Value":"42846"},{"Key":"Saint Lucia","Value":"42847"},{"Key":"Sao Tome & Principe","Value":"42848"},{"Key":"Saudi Arabia","Value":"42849"},{"Key":"Senegal","Value":"42850"},{"Key":"Serbia","Value":"42851"},{"Key":"Serbia & Monten","Value":"42852"},{"Key":"Seychelles","Value":"42853"},{"Key":"Sierra Leone","Value":"42854"},{"Key":"Singapore","Value":"42855"},{"Key":"Slovakia","Value":"42856"},{"Key":"Slovenia","Value":"42857"},{"Key":"Solomon Islands","Value":"42858"},{"Key":"Somalia","Value":"42859"},{"Key":"South Africa","Value":"42860"},{"Key":"South Sudan","Value":"42861"},{"Key":"Spain","Value":"42862"},{"Key":"St. Vincent And The Grena","Value":"42864"},{"Key":"Sudan","Value":"42865"},{"Key":"Surinam","Value":"42866"},{"Key":"Swaziland","Value":"42867"},{"Key":"Sweden","Value":"42868"},{"Key":"Switzerland","Value":"42869"},{"Key":"Syrian Arab Republic","Value":"42870"},{"Key":"Tajikistan","Value":"42871"},{"Key":"Tanzania, United Rep. Of","Value":"42872"},{"Key":"Tfyr Of Macedonia","Value":"42873"},{"Key":"Timor-Leste","Value":"42875"},{"Key":"Togo","Value":"42876"},{"Key":"Tokelau Islands","Value":"42877"},{"Key":"Tonga","Value":"42878"},{"Key":"Trinidad And Tobago","Value":"42879"},{"Key":"Tunisia","Value":"42880"},{"Key":"Turkey","Value":"42881"},{"Key":"Turkmenistan","Value":"42882"},{"Key":"Turks And Caicos Island","Value":"42883"},{"Key":"Mauritania","Value":"42803"},{"Key":"Mauritius","Value":"42804"},{"Key":"Mexico","Value":"42805"},{"Key":"Micronesia","Value":"42806"},{"Key":"Monaco","Value":"42807"},{"Key":"Mongolia","Value":"42808"},{"Key":"Montenegro","Value":"42809"},{"Key":"Montserrat","Value":"42810"},{"Key":"Morocco","Value":"42811"},{"Key":"Mozambique","Value":"42812"},{"Key":"Namibia","Value":"42813"},{"Key":"Nauru","Value":"42814"},{"Key":"Nepal","Value":"42815"},{"Key":"Netherlands","Value":"42816"},{"Key":"Netherlands Antilles","Value":"42817"},{"Key":"New Caledonia","Value":"42818"},{"Key":"New Zealand","Value":"42819"},{"Key":"Nicaragua","Value":"42820"},{"Key":"Niger","Value":"42821"},{"Key":"Nigeria","Value":"42822"},{"Key":"Niue","Value":"42823"},{"Key":"Northern Mariana Islands","Value":"42824"},{"Key":"Norway","Value":"42825"},{"Key":"Oman","Value":"42826"},{"Key":"Palau, Republic Of","Value":"42828"},{"Key":"Palestine","Value":"42829"},{"Key":"Panama","Value":"42830"},{"Key":"Papua New Guinea","Value":"42831"},{"Key":"Paraguay","Value":"42832"},{"Key":"Peru","Value":"42833"},{"Key":"Philippines","Value":"42834"},{"Key":"Poland","Value":"42835"},{"Key":"Portugal","Value":"42836"},{"Key":"Puerto Rico","Value":"42837"},{"Key":"Qatar","Value":"42838"},{"Key":"Republic Of Korea","Value":"42839"},{"Key":"Republic Of Moldova","Value":"42840"},{"Key":"Republic Of Yemen","Value":"42841"},{"Key":"Reunion","Value":"42842"},{"Key":"Romania","Value":"42843"},{"Key":"Russian Federation","Value":"42844"},{"Key":"Rwanda","Value":"42845"},{"Key":"Saint Kitts And Nevis","Value":"42846"},{"Key":"Saint Lucia","Value":"42847"},{"Key":"Sao Tome & Principe","Value":"42848"},{"Key":"Saudi Arabia","Value":"42849"},{"Key":"Senegal","Value":"42850"},{"Key":"Serbia","Value":"42851"},{"Key":"Serbia & Monten","Value":"42852"},{"Key":"Seychelles","Value":"42853"},{"Key":"Singapore","Value":"42855"},{"Key":"Slovakia","Value":"42856"},{"Key":"Slovenia","Value":"42857"}

{"Key":"New Zealand","Value":"42819"},{"Key":"Reunion","Value":"42842"},{"Key":"Sri Lanka","Value":"42863"},{"Key":"Thailand","Value":"42874"},{"Key":"Pakistan","Value":"42827"},{"Key":"Sierra Leone","Value":"42854"},

Static (Read Optimised) Volatile (Write Optimised)

Page 115: [DDD] Microservice scars

Oh shit #2

DynamoDb

Page 116: [DDD] Microservice scars

Recovery Point Objective = 30

minutes

DynamoDb

Page 117: [DDD] Microservice scars

Recovery Time Objective = 1 day

DynamoDb

Page 118: [DDD] Microservice scars
Page 119: [DDD] Microservice scars

DynamoDb

Page 120: [DDD] Microservice scars

DynamoDb

Page 121: [DDD] Microservice scars

DynamoDb

Page 122: [DDD] Microservice scars

DynamoDb

Page 123: [DDD] Microservice scars

S3 Versioned Buckets

DynamoDb

Page 124: [DDD] Microservice scars

DynamoDb

Page 125: [DDD] Microservice scars

DynamoDb

Page 126: [DDD] Microservice scars

DynamoDb

Page 127: [DDD] Microservice scars

DynamoDb Version Control

DynamoDb

Page 128: [DDD] Microservice scars

Retrospective

Page 129: [DDD] Microservice scars

Manage your risks explicitly

Page 130: [DDD] Microservice scars

Monolith Gateway

Page 131: [DDD] Microservice scars

Synchronization

Page 132: [DDD] Microservice scars

Stakeholders

Page 133: [DDD] Microservice scars

More than you think

Stakeholders

Page 134: [DDD] Microservice scars

Metrics

Stakeholders

Page 135: [DDD] Microservice scars

Transparency

Stakeholders

Page 136: [DDD] Microservice scars

Business value

Page 137: [DDD] Microservice scars

Team goals

Page 138: [DDD] Microservice scars

Support Balance

Page 139: [DDD] Microservice scars

Bake some goods

Page 140: [DDD] Microservice scars

Time to iterate

Page 141: [DDD] Microservice scars

Don’t underestimate

users

Page 142: [DDD] Microservice scars

Pair pair pair

Page 143: [DDD] Microservice scars

Questions

Page 144: [DDD] Microservice scars

Thank you

Page 145: [DDD] Microservice scars

https://github.com/PageUpPeopleOrg