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, greenfield and brownfield, have travelled. Sander will e.g. address polyglot persistence, DDD, bounded contexts, modeling HTTP/REST, continuous delivery and many lessons learned.
Thirty months of microservices. Stairway to heaven or highway to hell? - Sander Hoogendoorn - Codemotion Milan 2016
1. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 1
@aahoogendoorn | www.ditisagile.nl
Thirty months of
microservices
Sander Hoogendoorn
ditisagile.nl
2. @aahoogendoorn | www.ditisagile.nlDesigning, developing, testing and deploying microservices 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
5. @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
19. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 21
@aahoogendoorn | www.ditisagile.nl
Microservices
The clear benefits
21. @aahoogendoorn | www.ditisagile.nlDesigning, developing, testing and deploying microservices 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
22. @aahoogendoorn | www.ditisagile.nlDesigning, developing, testing and deploying microservices 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
23. @aahoogendoorn | www.ditisagile.nlDesigning, developing, testing and deploying microservices 25
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
25. @aahoogendoorn | www.ditisagile.nlDesigning, developing, testing and deploying microservices 35
Oh and by the way…
Doing microservices means that
you are building a distributed system
27. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 37
@aahoogendoorn | www.ditisagile.nl
Are microservices
a stairway to
heaven?
29. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 39
@aahoogendoorn | www.ditisagile.nl
From the trenches
Microservices in real life
36. @aahoogendoorn | www.ditisagile.nlDesigning, developing, testing and deploying microservices 49
For the things we have to learn
before we can do them,
we learn by doing them
Aristotle
39. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 53
@aahoogendoorn | www.ditisagile.nl
Start with some
guiding principles
40. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 54
@aahoogendoorn | www.ditisagile.nl
Business
processes first
41. @aahoogendoorn | www.ditisagile.nlDesigning, developing, testing and deploying microservices 57
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
Applications and components all have their own bounded
context
Applications do not have storage, and only talk to other
applications and components
Components have their own storage (database), and only talk
to other components
Communication between applications and components uses a
simple open protocol – JSON on REST
Avoid transactions as much as possible
Some guiding principles
44. @aahoogendoorn | www.ditisagile.nlDesigning, developing, testing and deploying microservices 69
@aahoogendoorn | www.ditisagile.nl
Designing
microservices
Modular design and
bounded contexts
45. @aahoogendoorn | www.ditisagile.nlDesigning, developing, testing and deploying microservices 70
Doing big up-front design is dumb,
doing no design up-front is even dumber
Dave Thomas
46. @aahoogendoorn | www.ditisagile.nlDesigning, developing, testing and deploying microservices 73
Single responsibility principle
Group together things that change together
Separate things that change for different reason
47. @aahoogendoorn | www.ditisagile.nlDesigning, developing, testing and deploying microservices 75
Bounded context
When 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
51. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 83
@aahoogendoorn | www.ditisagile.nl
RESTfulness
is not as easy
as it seems
52. @aahoogendoorn | www.ditisagile.nlDesigning, developing, testing and deploying microservices 84
Some examples
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
53. @aahoogendoorn | www.ditisagile.nlDesigning, developing, testing and deploying microservices 90
HTTP return codes cheat sheet
1**. Hold on
2**. Here you go
3**. Go away
4**. You fucked up
5**. I fucked up
61. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 102
@aahoogendoorn | www.ditisagile.nl
Deploying
microservices
Continuous integration
and build pipelines
64. @aahoogendoorn | www.ditisagile.nlDesigning, developing, testing and deploying microservices 106
Microservices
Building multiple deployment pipelines
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
65. @aahoogendoorn | www.ditisagile.nlDesigning, developing, testing and deploying microservices 107
No one tool to rule them all
We tried Jenkins, Bamboo, Team City, GoCD and then Jenkins again…
66. @aahoogendoorn | www.ditisagile.nlDesigning, developing, testing and deploying microservices 108
@aahoogendoorn | www.ditisagile.nl
Some tooling
we use
IntelliJ
SonarQube
Jenkins
Git & Gitlab
Infrastructure as code
82. @aahoogendoorn | www.ditisagile.nlThirty months of microservices. Stairway to heaven or highway to hell? 140
@aahoogendoorn | www.ditisagile.nl
In retrospective
Some final thoughts
83. @aahoogendoorn | www.ditisagile.nlDesigning, developing, testing and deploying microservices 141
Microservices are not for everyone (yet)
How do we benefit from implementing microservices?
What are we
going to benefit
from the most?Polyglot
persistence?
Scalability?
Small
Increments?
Enforce
modular
design?
Delivering
more often?
Bounded
Contexts?
86. @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…