thirty months of microservices. stairway to heaven or highway to hell

76
@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

Upload: sander-hoogendoorn

Post on 07-Jan-2017

247 views

Category:

Software


0 download

TRANSCRIPT

@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

@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]

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

@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

@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?

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

Dependencies will kill youA typical systems landscape

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

@aahoogendoorn | www.ditisagile.nl

A brief history of components and services

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

Client server

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

Component based development

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

Service oriented architecture

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

Microservices

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

@aahoogendoorn | www.ditisagile.nl

MicroservicesBeyond the hype?

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

MicroservicesBeyond the hype?

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

Gartner hype cycle

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

@aahoogendoorn | www.ditisagile.nl

MicroservicesThe clear benefits

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

But first … a definition

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

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

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

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

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

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

MicroservicesPromises

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

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…

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

Opinions, opinions, opinions

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

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

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

@aahoogendoorn | www.ditisagile.nl

Are microservicesa stairway to heaven?

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

@aahoogendoorn | www.ditisagile.nl

Or are they a highway to hell?

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

@aahoogendoorn | www.ditisagile.nl

From the trenchesMicroservices in real life

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

Where do we come from?

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

Where do we come from?

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

Where do we come from?

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

Outsourcing didn’t work

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

Where are we going to?

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

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

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

Aristotle

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

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

@aahoogendoorn | www.ditisagile.nl

So what did we learn?

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

Microservices require an evolutionary software architecture

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

@aahoogendoorn | www.ditisagile.nl

Start with some guiding principles

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

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 processComponents serve a single purpose and offer servicesApplications and components all have their own bounded context – a domain modelApplications and components will have an similar internal software architecture to facilitate ease of maintenance and allow for harvesting re-useCommunication between applications and components will use a simple open protocol - REST

Some guiding principles

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

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 processComponents serve a single purpose and offer servicesApplications and components all have their own bounded context – a domain modelApplications and components will have an similar internal software architecture to facilitate ease of maintenance and allow for harvesting re-useCommunication between applications and components will use a simple open protocol - REST

Some guiding principles

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

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

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

@aahoogendoorn | www.ditisagile.nl

Designing microservicesModular design and bounded contexts

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

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

Dave Thomas

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

Bounded contexts

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

SOLIDSingle Responsibility PrincipleOpen Closed PrincipleLiskov Substitution PrincipleInterface Segregation PrincipleDependency Inversion Principle

Single Responsibility PrincipleEvery “module” should have responsibility over a single part of the functionality provided by the software,That responsibility should be entirely encapsulated by that moduleAll its services should be narrowly aligned with that responsibility

The SOLID principlesUncle Bob Martin

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

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

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

Domain driven designThe paradigm of designing software based on models of the underlying domainThe domain model helps the business and the developers to reason about the functionalityA model needs to be unified – internally consistent without contradictions

Bounded contextThe bounded context is a central pattern in domain driven design When you model larger domains, it becomes progressively harder to create this single unified modelSo, instead of creating a single unified model, you create several, all valid within their bounded context

Bounded contextEric Evans

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

The single unified domain modelOr more often the humongous data model

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

Bounded contexts

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

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

@aahoogendoorn | www.ditisagile.nl

Modeling resources

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

Root resource (component)

GET the collection, but only limited to this representation (but with locations likely)

GET a single item from the collection, but with representation

Modeling resources

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

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

@aahoogendoorn | www.ditisagile.nl

RESTfulnessis not as easy as it seems

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

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

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

HTTP return codes cheat sheet

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

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

5**. I fucked up

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

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

Postel’s Law

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

@aahoogendoorn | www.ditisagile.nl

Testing microservices

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

Fail fast, fail often, fail forward

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

A (typical) service development lifecycle

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

What to test

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

Even though you might have really brilliant testers…

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

… please automate all your tests

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

@aahoogendoorn | www.ditisagile.nl

Deploying microservicesContinuous integrationand build pipelines

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

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

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

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

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

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

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

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

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

@aahoogendoorn | www.ditisagile.nl

In retrospectiveSome final thoughts

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

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

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

Will it work?

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

The hockey stick model

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

Minimal viable product

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

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

@aahoogendoorn | www.ditisagile.nl

Allow your teams to learn continuously…

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

@aahoogendoorn | www.ditisagile.nl

And never forgetto have fun

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

@aahoogendoorn | www.ditisagile.nl

References and questions

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