Sander Hoogendoorn
Me
Dad
Mentor, trainer, software architect, programmer
Books, articles, conferences
Work
Owner, ditisagile.nl
Web
www.sanderhoogendoorn.com
www.smartusecase.com
www.speedbird9.com
@aahoogendoorn
sander@ditisagile.nl
@aahoogendoorn
www.ditisagile.nl
@aahoogendoorn
www.ditisagile.nl
Agenda
An introduction into microservices
A microservice architecture
Evolutionary architecture
Building a landscape of small applications and services
Micro-applications
@aahoogendoorn
www.ditisagile.nl
Agenda
How do microservices communicate with each
other?
Service interfaces
Setting up communication between services
Communication via REST
Patterns in communication
Services and transactions
Designing microservices
Agenda
Deployment of microservices
Some recommendations
Do microservices solve all challenges your IT
department has?
How to continue?
@aahoogendoorn
www.ditisagile.nl
MONOLITHS
Hard to deliver, even harder to test and impossible to maintain
@aahoogendoorn
Monoliths
Advantages
Product Account
Order
Customer
Products Accounts
Orders
Customers
10
@aahoogendoorn
www.ditisagile.nl
11
A BRIEF HISTORY
OF COMPONENTS AND SERVICES
@aahoogendoorn
Client server
@aahoogendoorn
www.ditisagile.nl
13
@aahoogendoorn
www.ditisagile.nl
14
@aahoogendoorn
www.ditisagile.nl
15
Microservices
@aahoogendoorn
www.ditisagile.nl
16
MICROSERVICES
Beyond the hype?
@aahoogendoorn
@aahoogendoorn
www.ditisagile.nl
18
@aahoogendoorn
www.ditisagile.nl
19
MICROSERVICES
The clear benefits
@aahoogendoorn
21
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.nl
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.nl
23
Monoliths. Scalability
Product Account
Product Account
Product Account
Order
Order
Order
@aahoogendoorn
www.ditisagile.nl
Customer
Customer
Customer
24
Microservices. Scalability
@aahoogendoorn
www.ditisagile.nl
Product
Account
Customer
Order
25
Microservices. Scalability
Product Product
@aahoogendoorn
www.ditisagile.nl
Order
26
Monoliths. Persistence
Product Account
Order
Customer
Products Accounts
Orders
@aahoogendoorn
www.ditisagile.nl
Customers
MICROSERVICES? STAIRWAY TO HEAVEN OR HIGHWAY TO HELL?
27
@aahoogendoorn
www.ditisagile.nl
Product
Account
Customer
Order
Products
Accounts
Customers
Orders
Oracle
Active Directory
MongoDB
MongoDB
28
Microservices. Promises
Products not projects
Scalable
Decentralized governance
Product
Account
Replaceable parts
High performance
Technology independent
Polyglot persistence
Easy to build
Easy to test
Easier deployment than monoliths
@aahoogendoorn
www.ditisagile.nl
Customer
Order
MICROSERVICES? STAIRWAY TO HEAVEN OR HIGHWAY TO HELL?
29
Microservices. But
What is a microservice exactly?
How small is a microservice?
Requirements in a microservice world
Product
Components or services
Account
Customer
Order
30
ARE MICROSERVICES
A STAIRWAY TO HEAVEN?
@aahoogendoorn
OR A HIGHWAY TO HELL?
@aahoogendoorn
ARCHITECTURE IN THE
MICROSERVICE WORLD
@aahoogendoorn
34
35
Evolutionary architecture
Microservices are autonomous
in mind
36
@aahoogendoorn
www.ditisagile.nl
37
Aging technology
No mobile strategy, allowing for new business or new
services to clients, and intermediaries
We need to
Get rid of the mainframe
Shorten time-to-market
Lower TCO
Uphold a fully secure systems landscape
@aahoogendoorn
www.ditisagile.nl
38
Application architecture
End user facing Different users, different fast evolving needs
Which technology is the best for which purpose?
Component architecture
Components and services are evolving rapidly. How do we decide which components we need?
How do we deal with versioning? How do we deal with distributed processes and transactions?
@aahoogendoorn
www.ditisagile.nl
39
@aahoogendoorn
www.ditisagile.nl
40
@aahoogendoorn
www.ditisagile.nl
43
Step 1
@aahoogendoorn
www.ditisagile.nl
Step 2
Step 3
Step 4
Step 5
44
Step 3
Step 3.1
@aahoogendoorn
www.ditisagile.nl
Step 3.2
Step 3.3
Step 3.4
45
Step 3.3
Step 3.3.1
@aahoogendoorn
www.ditisagile.nl
Step 3.3.2
Step 3.3.3
Step 3.3.4
Step 3.3.5
46
APPLICATIONS
@aahoogendoorn
Micro-applications
Our principles
48
Pages
Grids / Panels, Controls
Presentation
Process
Use cases
Flow
Domain
Services
Outside world
@aahoogendoorn
www.ditisagile.nl
Relations
Dossiers
Intermediaries
Accounts
Rates
Components
50
COMPONENTS
@aahoogendoorn
Components
Our principles
53
Resources
Representations
Service interface
Process
Use cases
Flow
Domain
Data / Services
Outside world
@aahoogendoorn
www.ditisagile.nl
Relations
Dossiers
Intermediaries
DB2
MongoDB
Storage
55
Communication
Our principles
@aahoogendoorn
www.ditisagile.nl
57
DESIGNING MICROSERVICES
@aahoogendoorn
@aahoogendoorn
www.ditisagile.nl
61
Design guidelines
Single Responsibility Principle (SRP)
Product
Account
Microservices size
Applications, tasks
Customer
Order
62
63
Bounded context
Domain driven design
Bounded context
@aahoogendoorn
www.ditisagile.nl
64
Vendor
Delivery
Product
Client
Order
Stock
Payment
@aahoogendoorn
www.ditisagile.nl
65
Bounded contexts
Vendor
Delivery
Client
Product
Order
Product
Stock
Payment
@aahoogendoorn
www.ditisagile.nl
66
Bounded contexts
Modeling
Vendor
Product
Stock
67
No specific instances
Isbn, Email, Url, Money
References (code tables)
68
MODELING
APPLICATIONS
@aahoogendoorn
Step 3.3
Step 3.3.1
@aahoogendoorn
www.ditisagile.nl
Step 3.3.2
Step 3.3.3
Step 3.3.4
Step 3.3.5
70
@aahoogendoorn
www.ditisagile.nl
71
@aahoogendoorn
www.ditisagile.nl
Traditional
use cases
Smart
use cases
Format
Textual
Visual
Granularity
Different
Unified
Estimate
Hard
Easy
Unit of work
Lousy
Good
Reuse
Incidental
Normal
Traceability
Possible
Normal
Testability
Poor
Good
72
@aahoogendoorn
www.ditisagile.nl
73
@aahoogendoorn
www.ditisagile.nl
74
Application
bounded context
@aahoogendoorn
www.ditisagile.nl
76
76
HTTP
HTTP
When using HTTP as your transfer protocol you will have to
be very precise about how you use it
Verbs
GET
POST
PUT
DELETE
@aahoogendoorn
www.ditisagile.nl
83
@aahoogendoorn
www.ditisagile.nl
84
HTTP GET
GET
Examples
@aahoogendoorn
www.ditisagile.nl
localhost:8080/countries
85
HTTP POST
POST
Examples
localhost:8080/countries
@aahoogendoorn
www.ditisagile.nl
86
HTTP PUT
PUT
Examples
localhost:8080/countries/38
@aahoogendoorn
www.ditisagile.nl
87
HTTP DELETE
DELETE
Examples
Delete
localhost:8080/countries/38
@aahoogendoorn
www.ditisagile.nl
88
@aahoogendoorn
www.ditisagile.nl
89
MODELING COMPONENTS
@aahoogendoorn
Modeling resources
Why?
Services need to be able to change independently, so APIs
need to be well-defined
How?
Model resources and representations
Start with the root resource
Add the valid HTTP methods for that resource
Follow paths to sub-resources
91
Modeling resources
Root resources (component)
/qa
/qa
Questionnaire
/questionnaires
GET
/{id}
/questionnaires
GET
@aahoogendoorn
www.ditisagile.nl
Questionnaire
Id, Name, Description
Question
Answer
Name, Value
MICROSERVICES? STAIRWAY TO HEAVEN OR HIGHWAY TO HELL?
92
Resource
model
@aahoogendoorn
www.ditisagile.nl
93
93
@aahoogendoorn
www.ditisagile.nl
94
94
Component
bounded context
@aahoogendoorn
www.ditisagile.nl
97
97
TESTING MICROSERVICES
@aahoogendoorn
Testing microservices
Why is it even more important?
Next questions
Test when?
Test what?
@aahoogendoorn
www.ditisagile.nl
100
@aahoogendoorn
www.ditisagile.nl
Code
Developer Test
Test
Integration Test
Acceptance Test
Live
101
What to test
Developers
Unit tests
Prepare & Design
Code
Developer Test
Developers
Q&A
@aahoogendoorn
www.ditisagile.nl
Product owner
Product
Testers
Scenarios & APIs
Test
Integration Test
Acceptance Test
Live
Testers
Scenarios & APIs
102
Code
Developer Test
Developers
Q&A
@aahoogendoorn
www.ditisagile.nl
Product owner
Product
Testers
Scenarios & APIs
Test
Integration Test
Acceptance Test
Live
Testers
Scenarios & APIs
103
@aahoogendoorn
www.ditisagile.nl
104
@aahoogendoorn
www.ditisagile.nl
105
@aahoogendoorn
www.ditisagile.nl
106
@aahoogendoorn
www.ditisagile.nl
107
Pages
Integration tests
Grids / Panels, Controls
BDD & Selenium
Presentation
Process
Use cases
Flow
Unit tests
Domain
Unit tests
Services
Outside world
@aahoogendoorn
www.ditisagile.nl
Unit tests
Relations
Dossiers
Intermediaries
Accounts
Rates
Components
108
Service interface
Integration tests
SOAP UI or BDD
Process
Unit tests
Domain
Unit tests
Data / Services
Outside world
@aahoogendoorn
www.ditisagile.nl
Dossiers
Use cases
Flow
Unit tests
Relations
Resources
Representations
Intermediaries
DB2
MongoDB
Storage
109
Integration tests
@aahoogendoorn
www.ditisagile.nl
110
110
DEPLOYING MICROSERVICES
Continuous integration, build pipelines and continuous delivery
@aahoogendoorn
Continuous
Continuous integration (CI)
@aahoogendoorn
www.ditisagile.nl
112
@aahoogendoorn
www.ditisagile.nl
Code
Developer Test
Test
Integration Test
Acceptance Test
Live
113
Development
Prepare & Design
@aahoogendoorn
www.ditisagile.nl
Test
Code
Developer Test
Integration
Test
Integration Test
Acceptance
Acceptance Test
Production
Live
114
@aahoogendoorn
www.ditisagile.nl
115
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.nl
116
Code
Developer Test
Test
Acceptance Test
Acceptance
Live
Live
Code v.2
Test v.2
Acceptance v.2
Test v.2
Acceptance v.2
Live v.2
Code v.3
Developer Test
Test
Acceptance Test
Acceptance
Live
Code v.2
@aahoogendoorn
www.ditisagile.nl
117
Breaking changes
Try to avoid breaking changes
If there are breaking changes, make sure they appear as
soon as possible
Build pipelines
Create a build pipeline per application and component
In production consider Platform-as-a-Service (e.g. Docker)
@aahoogendoorn
www.ditisagile.nl
118
App1
App2
v1
v1
Customer
@aahoogendoorn
www.ditisagile.nl
App1
App2
v2
Customer
App1
v1
App2
v2
App1
App2
v2
Customer
Customer
119
@aahoogendoorn
www.ditisagile.nl
121
Planning?
@aahoogendoorn
www.ditisagile.nl
122
Or roadmap?
@aahoogendoorn
www.ditisagile.nl
123
@aahoogendoorn
www.ditisagile.nl
124
@aahoogendoorn
www.ditisagile.nl
125
@aahoogendoorn
www.ditisagile.nl
128
Project
MVP
Maintenance
Maintenance
Maintenance
Conti
nuous delivery
@aahoogendoorn
www.ditisagile.nl
129
@aahoogendoorn
www.ditisagile.nl
130
@aahoogendoorn
132
IN RETROSPECTIVE?
@aahoogendoorn
@aahoogendoorn
13
4
@aahoogendoorn
www.ditisagile.nl
136
FIRST DO IT
THEN DO IT RIGHT
THEN DO IT BETTER
@aahoogendoorn
COMMUNICATION
VIA REST IS NOT
AS EASY AS IT PROMISES
@aahoogendoorn
@aahoogendoorn
www.ditisagile.nl
141
@aahoogendoorn
THIS IS
AGILE
www.createspace.com/4747266
Password: agilescrum
Discount code: KGNWKKWG
@aahoogendoorn
REFERENCES
AND QUESTIONS
www.sanderhoogendoorn.com
www.smartusecase.com
www.speedbird9.com
sander@ditisagile.nl
@aahoogendoorn
@aahoogendoorn