This is the deck of the talks on microservices I did at both Avisi's #ASAS2016 (Arnhem, NL), Microsoft's #TechDaysNL (Amsterdam, NL) and #GeeCon (Prague, Czech Republic) conferences in September and October 2016.
Microservices are the next hype. Websites are full of introducing posts, books are being written and conferences organized. There’s big promises of scalability and flexibility. However, when you are knee deep in mud as an architect, developer or tester, it’s hard to find out how to get there. Sander Hoogendoorn, independent craftsman and CTO of Klaverblad Insurances, discusses the long and winding road his projects, both greenfield and brownfield, have travelled. Sander will e.g. address polyglot persistence, DDD, bounded contexts, modeling HTTP/REST, continuous delivery and many lessons learned, using many real-life examples.
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Thirty months of microservices. Stairway to heaven or highway to hell
1. @aahoogendoorn | www.ditisagile.nlThirty 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
2. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 2
Sander Hoogendoorn
Me
Dad, software architect, agile coach,
programmer, trainer, speaker, writer
Books, articles, conferences, courses
Work
Owner ditisagile.nl
Former CTO insurance company
Former global agile thoughtleader Capgemini
Web
www.sanderhoogendoorn.com
aahoogendoorn
aahoogendoorn
sander@ditisagile.nl
4. @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
5. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 6
Who has a system that is too big
and that really should be broken up?
6. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 8
Dependencies will kill you
A typical systems landscape
7. @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
12. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 15
@aahoogendoorn | www.ditisagile.nl
Microservices
Beyond the hype?
15. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 18
@aahoogendoorn | www.ditisagile.nl
Microservices
The clear benefits
17. @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
18. @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
19. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 29
Products not projects
Scalable
Decentralized governance
Replaceable parts
High performance
Technology independent
Polyglot persistence
Easy to build
Easy to test
Easier deployment than monoliths
Microservices
Promises
20. @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 world
Components or services
Who owns a microservice?
What technologies do you use?
What protocols do you apply?
How to define messages
How to test microservices
How to coordinate when business services run across
components?
How to build deployment pipelines?
How does integration really work?
Containers anyone?
Microservices
But…
22. @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
23. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 33
@aahoogendoorn | www.ditisagile.nl
Are microservices
a stairway to
heaven?
24. @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?
25. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 35
@aahoogendoorn | www.ditisagile.nl
From the trenches
Microservices in real life
32. @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 themAristotle
34. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 47
@aahoogendoorn | www.ditisagile.nl
So what did
we learn?
35. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 48
Microservices require
an evolutionary software architecture
36. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 49
@aahoogendoorn | www.ditisagile.nl
Start with some
guiding principles
37. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 51
Client thinks in business processes, so we implement business
processes
We move away from the mainframe, to a new systems
landscape, consisting of micro-applications and micro-
components
Requirements and documentation are modeled rather than
written
Applications implement a single (elementary) business
process
Components serve a single purpose and offer services
Applications and components all have their own bounded
context – a domain model
Applications and components will have an similar internal
software architecture to facilitate ease of maintenance and
allow for harvesting re-use
Communication between applications and components will
use a simple open protocol - REST
Some guiding principles
38. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 52
Client thinks in business processes, so we implement business
processes
We move away from the mainframe, to a new systems
landscape, consisting of micro-applications and micro-
components
Requirements and documentation are modeled rather than
written
Applications implement a single (elementary) business
process
Components serve a single purpose and offer services
Applications and components all have their own bounded
context – a domain model
Applications and components will have an similar internal
software architecture to facilitate ease of maintenance and
allow for harvesting re-use
Communication between applications and components will
use a simple open protocol - REST
Some guiding principles
41. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 64
@aahoogendoorn | www.ditisagile.nl
Designing
microservices
Modular design and
bounded contexts
42. @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 dumberDave Thomas
44. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 67
SOLID
Single Responsibility Principle
Open Closed Principle
Liskov Substitution Principle
Interface Segregation Principle
Dependency Inversion Principle
Single Responsibility Principle
Every “module” should have responsibility over a single
part of the functionality provided by the software,
That responsibility should be entirely encapsulated by
that module
All its services should be narrowly aligned with that
responsibility
The SOLID principles
Uncle Bob Martin
45. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 68
Single responsibility principle
Group together things that change together
Separate things that change for different reason
46. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 69
Domain driven design
The paradigm of designing software based on models
of the underlying domain
The domain model helps the business and the
developers to reason about the functionality
A model needs to be unified – internally consistent
without contradictions
Bounded context
The bounded context is a central pattern in domain
driven design
When you model larger domains, it becomes
progressively harder to create this single unified model
So, instead of creating a single unified model, you create
several, all valid within their bounded context
Bounded context
Eric Evans
47. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 70
The single unified domain model
Or more often the humongous data model
50. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 73
@aahoogendoorn | www.ditisagile.nl
Modeling
resources
51. @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
53. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 77
@aahoogendoorn | www.ditisagile.nl
RESTfulness
is not as easy
as it seems
54. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 78
A small quiz
Guess the HTTP status codes…
Get
localhost:8080/countries
Get
localhost: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
55. @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
56. @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
57. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 87
@aahoogendoorn | www.ditisagile.nl
Testing
microservices
61. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 91
Even though you might have really brilliant testers…
63. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 95
@aahoogendoorn | www.ditisagile.nl
Deploying
microservices
Continuous integration
and build pipelines
64. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 99
Microservices. Building a deployment pipeline
Code DeveloperTest Test AcceptanceTest Acceptance Live
Code DeveloperTest Test AcceptanceTest Acceptance Live
Code DeveloperTest Test AcceptanceTest Acceptance Live
Code DeveloperTest Test AcceptanceTest Acceptance Live
65. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 100
Microservices. Pipeline hell?
Codev.2 DeveloperTestv.2 Testv.2 AcceptanceTestv.2 Acceptancev.2
Code DeveloperTest Test AcceptanceTest Acceptance Live
Testv.2 AcceptanceTestv.2 Acceptancev.2 Livev.2
DeveloperTest Test AcceptanceTest Acceptance Live
Codev.3 DeveloperTestv.3
Live
Codev.2
66. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 101
No one tool to rule them all
We tried Jenkins, Bamboo, Team City, GoCD and then Jenkins again…
67. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 102
DevOps is not easy
It feels like showing up at the wrong re-enactment
68. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 131
@aahoogendoorn | www.ditisagile.nl
In retrospective
Some final thoughts
69. @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?
74. @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…
75. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 138
@aahoogendoorn | www.ditisagile.nl
And never forget
to have fun
76. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 139
@aahoogendoorn | www.ditisagile.nl
References
and questions
www.sanderhoogendoorn.com
www.ditisagile.nl
aahoogendoorn
aahoogendoorn
sander@ditisagile.nl