87
@aahoogendoorn | www.ditisagile.nl Thirty months of microservices. Stairway to heaven or highway to hell? 1 @aahoogendoorn | www.ditisagile.nl Thirty months of microservices Stairway to heaven or highway to hell? Sander Hoogendoorn ditisagile.nl

Geecon Prague 2016 - Thirty months of microservices

Embed Size (px)

Citation preview

Page 1: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 1

@aahoogendoorn | www.ditisagile.nl

Thirty months of microservicesStairway to heaven or highway to hell?

Sander Hoogendoornditisagile.nl

Page 2: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 2

Sander Hoogendoorn

MeDad, software architect, agile coach, programmer, trainer, speaker, writerBooks, articles, conferences, courses

WorkOwner ditisagile.nlFormer CTO insurance companyFormer global agile thoughtleader Capgemini

Webwww.sanderhoogendoorn.comaahoogendoornaahoogendoorn [email protected]

Page 3: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 3

Page 4: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 4

As a project managerI would like to demo untested code so I embarrass myself

Page 5: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 5

@aahoogendoorn | www.ditisagile.nl

Monoliths Hard to deliver, even harder to test and impossible to maintain

Page 6: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 6

Who has a system that is too bigand that really should be broken up?

Page 7: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 8

Page 8: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 9

Page 9: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 10

Page 10: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 11

Dependencies will kill youA typical systems landscape

Page 11: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 18

@aahoogendoorn | www.ditisagile.nl

MicroservicesBeyond the hype?

Page 12: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 19

MicroservicesBeyond the hype?

Page 13: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 20

Gartner hype cycle

Page 14: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 21

@aahoogendoorn | www.ditisagile.nl

MicroservicesThe clear benefits

Page 15: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 22

But first … a definition

Page 16: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 23

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.

Martin Fowler

Page 17: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 24

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.

Martin Fowler

Page 18: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 32

Products not projectsScalableDecentralized governanceReplaceable partsHigh performanceTechnology independentPolyglot persistenceEasy to buildEasy to testEasier deployment than monoliths

MicroservicesPromises

Page 19: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 33

What is a microservice exactly?How small is a microservice?Requirements in a microservice worldComponents or servicesWho owns a microservice?What technologies do you use?What protocols do you apply?How to define messagesHow to test microservicesHow to coordinate when business services run across components?How to build deployment pipelines?How does integration really work?Containers anyone?

MicroservicesBut…

Page 20: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 34

Opinions, opinions, opinions

Page 21: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 35

Oh and by the way…Doing microservices means that you are building a distributed system

Page 22: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 36

@aahoogendoorn | www.ditisagile.nl

Are microservicesa stairway to heaven?

Page 23: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 37

@aahoogendoorn | www.ditisagile.nl

Or are they a highway to hell?

Page 24: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 38

@aahoogendoorn | www.ditisagile.nl

From the trenchesMicroservices in real life

Page 25: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 39

Where do we come from?

Page 26: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 40

Where do we come from?

Page 27: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 41

Where do we come from?

Page 28: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 42

Outsourcing didn’t work

Page 29: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 43

Where are we going to?

Page 30: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 48

For the things we have to learn before we can do them, we learn by doing them

Aristotle

Page 31: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 50

@aahoogendoorn | www.ditisagile.nl

So what did we learn?

Page 32: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 51

Microservices require an evolutionary software architecture

Page 33: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 52

@aahoogendoorn | www.ditisagile.nl

Start with some guiding principles

Page 34: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 55

Client thinks in business processes, so we implement business processesWe move away from the mainframe, to a new systems landscape, consisting of micro-applications and micro-componentsRequirements and documentation are modeled rather than writtenApplications implement a single elementary business processApplications and components all have their own bounded contextApplications do not have storage, and only talk to other applications and componentsComponents have their own storage (database), and only talk to other componentsCommunication between applications and components uses a simple open protocol – JSON on REST Avoid transactional behavior as much as possible

Some guiding principles

Page 35: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 56

Client thinks in business processes, so we implement business processesWe move away from the mainframe, to a new systems landscape, consisting of micro-applications and micro-componentsRequirements and documentation are modeled rather than writtenApplications implement a single elementary business processApplications and components all have their own bounded contextApplications do not have storage, and only talk to other applications and componentsComponents have their own storage (database), and only talk to other componentsCommunication between applications and components uses a simple open protocol – JSON on REST Avoid transactions as much as possible

Some guiding principles

Page 36: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 59

Page 37: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 60

Page 38: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 68

@aahoogendoorn | www.ditisagile.nl

Designing microservicesModular design and bounded contexts

Page 39: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 69

Doing big up-front design is dumb, doing no design up-front is even dumber

Dave Thomas

Page 40: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 70

Bounded contexts

Page 41: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 72

Single responsibility principleGroup together things that change togetherSeparate things that change for different reason

Page 42: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 74

Bounded contextWhen you model larger domains, it becomes progressively harder to create this single unified model. Instead of creating a single unified model, you create several, all valid within their bounded context

Page 43: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 75

The single unified domain modelOr more often the humongous data model

Page 44: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 76

Bounded contexts

Page 45: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 77

Page 46: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 82

@aahoogendoorn | www.ditisagile.nl

RESTfulnessis not as easy as it seems

Page 47: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 83

A small quizGuess the HTTP status codes…

Getlocalhost:8080/countries

Getlocalhost:8080/countries/42

localhost:8080/countries/GRC

localhost:8080/countries/isocode/GRC

localhost:8080/countries?isocode=“GRC”

Post or put? localhost:8080/countries

localhost:8080/countries/38

Page 48: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 89

HTTP return codes cheat sheet

1**. Hold on 2**. Here you go

3**. Go away 4**. You fucked up

5**. I fucked up

Page 49: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 90

Be conservative in what you send, be liberal in what you accept

Postel’s Law

Page 50: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 92

@aahoogendoorn | www.ditisagile.nl

Testing microservices

Page 51: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 93

Fail fast, fail often, fail forward

Page 52: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 94

A (typical) service development lifecycle

Page 53: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 95

What to test?

Page 54: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 96

Even though you might have really brilliant testers…

Page 55: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 97

… please automate all your tests

Page 56: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 98

User acceptance testingMinimize to the max

Page 57: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 101

@aahoogendoorn | www.ditisagile.nl

Deploying microservicesContinuous integrationand build pipelines

Page 58: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 105

Microservices. Building a deployment pipeline

Code Developer Test Test Acceptance Test Acceptance Live

Code Developer Test Test Acceptance Test Acceptance Live

Code Developer Test Test Acceptance Test Acceptance Live

Code Developer Test Test Acceptance Test Acceptance Live

Page 59: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 106

Microservices. Pipeline hell?

Code v.2 Developer Test v.2 Test v.2 Acceptance Test v.2 Acceptance v.2

Code Developer Test Test Acceptance Test Acceptance Live

Test v.2 Acceptance Test v.2 Acceptance v.2 Live v.2

Developer Test Test Acceptance Test Acceptance Live

Code v.3 Developer Test v.3

Live

Code v.2

Page 60: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 107

No one tool to rule them allWe tried Jenkins, Bamboo, Team City, GoCD and then Jenkins again…

Page 61: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 108

@aahoogendoorn | www.ditisagile.nl

Some tooling we useIntelliJSonarQubeJenkinsGit & GitlabInfrastructure as code

Page 62: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 109

Page 63: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 110

Page 64: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 111

Page 65: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 112

Page 66: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 113

Page 67: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 114

Page 68: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 115

Page 69: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 116

Page 70: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 117

Page 71: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 118

Page 72: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 119

Page 73: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 120

Page 74: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 121

Page 75: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 122

Page 76: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 123

DevOps is not easyIt feels like showing up at the wrong re-enactment

Page 77: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 124

Infrastructure as code (often Groovy)And guess what … we know how to do that

Page 78: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 125

Page 79: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 126

Page 80: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 127

Page 81: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 140

@aahoogendoorn | www.ditisagile.nl

In retrospectiveSome final thoughts

Page 82: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 141

Microservices are not for everyone (yet)How do we benefit from implementing microservices?

Page 83: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 142

Will it work?

Page 84: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 143

The hockey stick model

Page 85: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 146

@aahoogendoorn | www.ditisagile.nl

Allow your teams to learn continuously…

Page 86: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 147

@aahoogendoorn | www.ditisagile.nl

And never forgetto have fun

Page 87: Geecon Prague 2016 - Thirty months of microservices

@aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 148

@aahoogendoorn | www.ditisagile.nl

References and questions

www.sanderhoogendoorn.comwww.ditisagile.nlaahoogendoornaahoogendoorn [email protected]