The microservice architecture is growing in popularity. It is an architectural style that structures an application as a set of loosely coupled services that are organized around business capabilities. Its goal is to enable the continuous delivery of large, complex applications. However, the microservice architecture is not a silver bullet and it has some significant drawbacks.
The goal of the microservices pattern language is to enable software developers to apply the microservice architecture effectively. It is a collection of patterns that solve architecture, design, development and operational problems. In this talk, I’ll provide an overview of the microservice architecture and describe the motivations for the pattern language. You will learn about the key patterns in the pattern language.
7. @crichardson
Yet almost 30 years later
developers are still
passionately arguing over
“silver bullets”
Functional programming
8. @crichardson
Suck/Rock Dichotomy
Spring vs. Java EE
JavaScript vs. Java
Functional programming vs. Object-oriented
http://nealford.com/memeagora/2009/08/05/suck-rock-dichotomy.html
Containers vs. Virtual Machines
12. @crichardson
Alternative
Pattern
The structure of a pattern
Pattern
Benefits
Drawbacks
Issues
Alternative
Pattern
Pattern
that
addresses
issue
Context
Problem
Solution
aka the situation
(conflicting) issues/
requirements/etc to
address
Forces
Consequences
13. Pattern language
A collection of
related patterns
that solve problems
in a particular
domain
http://en.wikipedia.org/wiki/A_Pattern_Language
Motivating
Pattern
Solution
Pattern
Solution
Pattern A
Solution
Pattern B
Generic
Pattern
Specific
Pattern
Has
issue
Solves
issue
Alternative
solutions
Refines
15. @crichardson
The pattern language guides you
when developing an architecture
What architectural decisions you must make (a.k.a. problems
to solve)
For each decision/problem:
Available patterns
Trade-offs of each pattern
17. @crichardson
Success triangle
Process: Lean + DevOps/Continuous Delivery & Deployment
Organization:
Network of small,
loosely coupled, teams
Architecture: ???
IT must deliver software
rapidly, frequently, reliably and
sustainably
Businesses must be
nimble, agile and
innovate faster
S/W
VUCA
18. Development in high performing
organizations
“Complete their work without communicating and
coordinating with people outside their team”
“Make large-scale changes to the design of their system
without depending on other teams to make changes in
their systems or creating significant work for other teams”
….
Loose design-time coupling/
modularity
=
20. @crichardson
Successful applications live for a long time, e.g. 10 years,
20 years, …
BUT
Technology changes: Programming languages,
frameworks, …
Time
Technology A Technology B
V1 V2 V3 V…
Importance
The importance of a technology changes over time
22. @crichardson
The context, problem and
forces
Context: IT must deliver software rapidly, frequently, reliably and sustainably
Problem: what’s the architecture?
Forces
Simplicity
Testability
Deployability
Modularity / Loose coupling
Evolvability (of technology stack)
24. @crichardson
Tomcat/App. Server
Food To Go: Monolithic
architecture
Browser/
Client
WAR/EAR
MySQL
Database
Delivery
management
Order
Management
Kitchen
Management
Web UI
Restaurant
Management
HTML
REST/JSON
The application
25. @crichardson
Many teams, one application
Orders
Team
FTGO
application
Kitchen
Team
Automated deployment pipeline
Source code repository
Delivery
Team
Production
26. Benefits and drawbacks
Benefits
Simplicity of development: ACID
transactions, local method/function
calls
Simplicity of operations: one
application
Drawbacks
Potentially large codebase
overwhelms developers
Single technology stack
Teams cannot deploy changes
independently
Entire application subject to
regulatory requirements
Potentially slow deployment pipeline
Poor fault isolation
27. @crichardson
Issues
How to enable many developers to
frequently commit their changes?
How to improve productivity by enabling
developers to work on part of the
application?
How to enable teams to work
independently?
How to accelerate deployment pipeline?
Merge Queue
Modular
Monolith
Parallelization
28. @crichardson
Many teams, modular monolith
Order
Module
Orders
Team
Deployment
pipeline
Source code repository
Kitchen
Module
Kitchen
Team
Deployment
pipeline
Source code repository
Delivery
Module
Delivery
Team
Deployment
pipeline
Source code repository
Production
Deployment
pipeline
FTGO
application
Assembles
and tests
29. Pattern: microservice
architecture
Highly maintainable and
testable
Minimal lead time (time from
commit to deploy)
Loosely coupled
Independently deployable
Implements a business
capability
Owned/developed/tested/
deployed by a small team
An architectural
style
that structures an
application as a
set of deployable/
executable units,
a.k.a. services
A service is:
30. @crichardson
Food to Go: Microservice
architecture
Browser
Mobile
Application
API
Gateway
Order
Service
Restaurant
Service
Delivery
Service
…
Service
Order
Database
Restaurant
Database
Delivery
Database
…
Database
REST
REST
JavaScript
Message
Broker
31. @crichardson
Loosely coupled teams and
services
Order
Service
Orders
Team
Automated deployment pipeline
Source code repository
Kitchen
Service
Kitchen
Team
Automated deployment pipeline
Source code repository
Delivery
Service
Delivery
Team
Automated deployment pipeline
Source code repository
Working independently > 80% of the time
Production
32. Benefits and drawbacks
Benefits
Multiple technology stacks/
incremental evolution
Teams can deploy changes
independently
Fast deployment pipeline
Improved fault isolation
Drawbacks
Potential complexity of
distributed architecture:
eventual consistency, inter-
service communication
More complex operations:
observability and
troubleshooting
37. Pattern: Shared database
Benefits:
Simple, familiar ACID
transactions
Drawbacks:
Design-time coupling
Runtime coupling
Order Service
Customer
Service
Database
Order
Table
Customer
Table
38. Pattern: Database per Service
Benefits:
Loose design-time
coupling
Loose runtime coupling
Drawbacks:
More complex, eventual
consistency
Orders Service
Customer
Service
Order
Database
Customer
Database
39. How to implement
transactions?
Context:
You have applied the
Microservice architecture and
Database per service patterns
Problem:
How to implement
transactions that span
services/databases?
Forces:
Services must be loosely
coupled
Database per
Service
Saga
2PC
40. Pattern: 2PC
Benefits
Simplicity of ACID transactions
Drawbacks
Tight runtime coupling
Challenging to recover from
coordinator failures
Not supported by all databases
https://en.wikipedia.org/wiki/Two-phase_commit_protocol
42. How to implement queries?
Context:
You have applied the
Microservice architecture and
Data per service patterns
Problem:
How to implement queries
that span services?
Forces:
Services must be loosely
coupled
Database per
Service
CQRS
API
Composition