This is a keynote I gave at Oracle Code 2017 in New York:
https://developer.oracle.com/code/newyork
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 we define the microservice architecture as an architectural style and explain what that actually means. You will learn why the architecture that you pick for your application matters. We describe how the primary goal of the microservice architecture is to enable continuous delivery/deployment and how it achieves that.
You will learn how to solve key challenges with decomposing an application into microservices. We describe 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)
8. @crichardson
Agenda
A brief refresher on software architecture
From monolith to microservices
Microservices != silver bullet
Managing distributed data
9. 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
19. @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
34. -ilities of large monoliths
Maintainability
Evolvability
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
Implementation view
36. @crichardson
A business has a business
capabilities
Acme, Inc
Order
Taking
Inventory
management
Delivery
management
A
Business Capability
is something a
business
does in order to
deliver value
…
37. @crichardson
Service = business capability
Order Taking
Service
Inventory
management Service
Delivery management
Service
…
Service
44. @crichardson
Evolve the technology stack
Pick a new technology when
Writing a new service
Making major changes to an existing service
Let’s you experiment and fail safely
45. @crichardson
Agenda
A brief refresher on software architecture
From monolith to microservices
Microservices != silver bullet
Managing distributed data
49. @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?
52. @crichardson
The structure of a pattern
Resulting context
aka the situation
Name
Context
Problem
Related patterns
(conflicting) issues
etc to address
Forces
Solution
54. @crichardsonMicroservice patterns
Communication patterns
Core
Cross-cutting concerns Security
Deployment
Maintaining data consistency
Database architecture
External API
Reliability
Discovery
Communication style
Testing
Observability
UI
Decomposition
API gateway
Client-side discovery
Server-side
discovery
Service registry
Self registration
3rd party registration
Multiple Services
per host
Single Service per
Host
Service-per-
Container
Service-per-VM
Messaging
Remote Procedure
Invocation
Database per
Service
Event-driven
architectureShared
database
Microservice
Chassis
Backend for front end
Event
sourcing
Transaction
log tailing
Database
triggers
Application
events
Monolithic
architecture
Microservice
architecture
CQRS
Motivating
Pattern
Solution
Pattern
Solution A Solution B
General Specific
Serverless
deployment
Circuit BreakerAccess Token
Domain-specific
Externalized
configuration
Service Integration
Contract Test
Service
Component Test
Exception
tracking
Distributed
tracing
Audit logging
Application
metrics
Log
aggregation
Health check
API
Service deployment
platform
Server-side page
fragment
composition
Client-side UI
composition
Decompose by
business capability
Decompose by
subdomain
Application patterns
Infrastructure patterns
Application Infrastructure patterns
Microservices pattern language: http://microservices.io
55. @crichardson
Agenda
A brief refresher on software architecture
From monolith to microservices
Microservices != silver bullet
Managing distributed data
58. @crichardson
How to enforce credit limit?
BEGIN TRANSACTION
…
SELECT ORDER_TOTAL
FROM ORDERS WHERE CUSTOMER_ID = ?
…
SELECT CREDIT_LIMIT
FROM CUSTOMERS WHERE CUSTOMER_ID = ?
…
INSERT INTO ORDERS …
…
COMMIT TRANSACTION
Private to the
Order Service
Private to the
Customer Service
Distributed transactions
60. @crichardson
Saga
Instead: use event-driven sagas
Distributed transaction
Order Customer
Local transaction
Order
Local transaction
Customer
Local transaction
Order
Event
Event
61. @crichardson
Order Service
Saga-based, eventually consistent
order processing
Customer Service
Order created
Credit Reserved
Credit Check Failed
Create Order
OR Customer
creditLimit
creditReservations
...
Order
state
total
…
approve()/reject()
Event Handler
Event Handler
reserveCredit()
64. @crichardson
How to find recent, valuable
customers?
SELECT *
FROM CUSTOMER c, ORDER o
WHERE
c.id = o.ID
AND o.ORDER_TOTAL > 100000
AND o.STATE = 'SHIPPED'
AND c.CREATION_DATE > ?
Customer
Service
Order Service
What if event
sourcing is
used?…. is no longer easy
66. @crichardson
Queries database (type)
Command side
POST
PUT
DELETE
Aggregate
Event Store
Events
Query side
GET /customers/id
MongoDB
Query side
GET /orders?text=xyz
ElasticSearch
Query side
GET …
Neo4j
67. @crichardson
Summary
The goal of architecture is to satisfy non-functional
requirements
Use the appropriate architectural style
Small applications Monolithic architecture
Complex applications Microservice architecture
Use the pattern language to guide your decision making
Use an event-driven architecture for transactions and queries