This is a talk I gave at Code Freeze 2018:
The microservice architecture is becoming increasingly popular. However, frequent references to using “a microservice to solve a problem” suggest that the concept is not universally well understood. In this talk, I define the microservice architecture as an architectural style and explain what that actually means. I also describe how the primary goal of the microservice architecture is to enable continuous delivery and deployment, and how it achieves that. You will learn why the architecture that you pick for your application matters. And you will learn how to solve key challenges with decomposing an application into microservices. This talk explains why there is no such thing as a microservice!
5. @crichardson
About Chris
Founder of a startup that is creating
an open-source/SaaS platform
that simplifies the development of
transactional microservices
(http://eventuate.io)
7. @crichardson
Agenda
A brief refresher on software architecture
From monolith to microservices
Microservices != silver bullet
Applying the microservice pattern language
8. About software architecture
“The software architecture of a computing system is the
set of structures needed to reason about the system,
which comprise software elements, relations among
them, and properties of both.”
Documenting Software Architectures, Bass et al
18. @crichardson
""… An architectural style determines
the vocabulary of components and
connectors that can be used in instances
of that style, together with a set of
constraints on how they can be
combined….. ””
David Garlan and Mary Shaw, An Introduction to Software
Architecture
26. Agenda
A brief refresher on software architecture
From monolith to microservices
Microservices != silver bullet
Applying the microservice pattern language
34. -ilities of large monoliths
Maintainability
Testability
Deployability
…
https://en.wikipedia.org/wiki/Non-functional_requirement
😭
35. The microservice architecture
is an architectural style
that structures an
application as a
set of loosely coupled,
services organized around
business capabilities
36. @crichardson
Application
Service = business capability
Acme, Inc
Order
Taking
Inventory
management
Delivery
management
Business Capability = something a business does to deliver value
…
Order
Service
Inventory
Management
Service
Delivery
Management
Service …
Service
37. @crichardson
Service = independently
deployable component
Command
Query
API
Event
Publisher
Event
Subscriber
API
Client
Consumer facing Implementation
Synchronous:
REST, gRPC, …
Asynchronous:
Command/Reply, Notification
Service database
Events
Events
Synchronous:
REST, gRPC, …
Asynchronous:
Command/Reply, Notification
Data owned by the service
Data replicated from elsewhere
SLA
46. @crichardson
Agenda
A brief refresher on software architecture
From monolith to microservices
Microservices != silver bullet
Applying the microservice pattern language
50. @crichardson
Do I have the pre-requisites in place:
automated testing
automated provisioning
…..
?
51. @crichardson
When using microservices:
How to decompose an application into services?
How to deploy an application’s services?
How to handle cross cutting concerns?
Which communication mechanisms to use?
How do external clients communicate with the services?
How does a client discover the network location of a service instance?
How to prevent a network or service failure from cascading to other services?
How to maintain data consistency and implement queries?
How to make testing easier?
How to understand the behavior of an application and troubleshoot problems?
How to implement a UI screen or page that displays data from multiple services?
55. @crichardson
The structure of a pattern
encourages objectivity
Resulting context
aka the situation
Name
Context
Problem
Related patterns
(conflicting) issues
etc to address
Forces
Solution Benefits
Drawbacks
Issues to resolve
Alternatives
Solutions to issues
57. @crichardson
Agenda
A brief refresher on software architecture
From monolith to microservices
Microservices != silver bullet
Applying the microservice pattern language
58. @crichardson
The pattern language guides you
when developing an architecture
What architectural decisions you must make
For each decision:
Available options
Trade-offs of each option
60. Issue: What’s the deployment
architecture?
Forces
Maintainability
Deployability
Testability
…
Monolithic
architecture
Microservice
architecture
Single deployable/
executable OR
Tightly coupled services
Multiple loosely coupled
services
61. Issue: How to decompose an
application into services?
Forces
Stability
Cohesive
Loosely coupled
Not too large
Decompose by
business capability
Decompose by
subdomain
Organize around
business capabilities
Organize around DDD
subdomains
62. @crichardson
Issue: how to maintain data
consistency?
Context
• Each service has its own
database
• Data is private to a service
Forces
Transactional data consistency
must be maintained across
multiple services
2PC is not an option
63. @crichardson
Issue: how to perform
queries?
CQRS
Context
Each service has its own
database
Forces
Queries must join data
from multiple services
Data is private to a service
Maintain query views by
subscribing to events
API
Composition
65. @crichardson
Issue: How do services
communicate?
Messaging
Remote Procedure
Invocation
Domain-specific
Forces
Services must
communicate
Usually processes on
different machines
…
66. @crichardson
Issue: How to handle cross
cutting concerns?
Microservice
Chassis
Forces
Every service must
implement logging;
externalize configuration;
health check endpoint;
metrics; …
67. Issue: How to deploy an
application’s services?
Multiple Services
per host
Single Service per
Host
Service-per-
Container
Service-per-VM
Serverless
deployment
Service deployment
platform
Forces
Multiple languages
Isolated
Constrained
Monitor-able
Reliable
Efficient
68. @crichardson
Issue: How to discover a service
instance’s network location?
Client-side discovery
Server-side
discovery
Service registry
Self registration
3rd party registration
Forces
Client needs IP address of
service instance
Dynamic IP addresses
Dynamically provisioned
instances
69. @crichardson
Issue: how to monitor the
behavior of your application?
Exception
tracking
Distributed
tracing
Audit logging
Application
metrics
Log
aggregation
Health check
API
70. @crichardson
Summary
The goal of architecture is to satisfy non-functional
requirements
For continuous delivery/deployment use the appropriate
architectural style
Small applications Monolithic architecture
Complex applications Microservice architecture
Use the pattern language to guide your decision making