SlideShare a Scribd company logo
A	
  pattern	
  language	
  for	
  microservices
Chris Richardson
@crichardson
chris@chrisrichardson.net
http://eventuate.io
@crichardson
About Chris
@crichardson
About Chris
@crichardson
About Chris
http://learnmicroservices.io
@crichardson
Why microservices?
@crichardson
The monolithic architecture
Browser
SQL
database
HTML
REST/JSON
Client
App
Catalog
Module
Reviews
Module
Orders
Module
StoreFront UI
Module
@crichardson
The monolithic architecture
Tomcat
Browser
WAR
SQL
database
HTML
REST/JSON
Client
App
Catalog
Module
Reviews
Module
Orders
Module
StoreFront UI
Module
@crichardson
The monolithic architecture
Tomcat
Browser
WAR
SQL
database
HTML
REST/JSON
Client
App
Simple to ….
Develop
Test
Deploy
Scale
Catalog
Module
Reviews
Module
Orders
Module
StoreFront UI
Module
@crichardson
But successful
applications
keep growing
….
@crichardson
… and modularity breaks down…
http://www.laputan.org/mud/
@crichardson
Monolithic hell
Agile development and deployment
becomes impossible
Technology stack becomes increasingly obsolete
BUT a rewrite is not feasible
The microservice architecture is an
architectural style that
structures an application as a
set of loosely coupled, services
organized around business capabilities
@crichardson
Microservices tackles complexity* through
modularity
Division of labor
Division of knowledge
@crichardson
Microservices tackles complexity* through
modularity
Division of labor
Division of knowledge
* might improve scalability too
@crichardson
Microservice architecture = functional
decomposition Catalog
Service
Review
Service
Order
Service
…
Service
@crichardson
Microservice architecture = functional
decomposition Catalog
Service
Review
Service
Order
Service
…
Service
Catalog
Database
Review
Database
Order
Database
…
Database
@crichardson
Microservice architecture = functional
decomposition
Browser
Mobile
Device
Store
Front UI
API
Gateway
Catalog
Service
Review
Service
Order
Service
…
Service
Catalog
Database
Review
Database
Order
Database
…
Database
HTML
REST
REST
@crichardson
Microservices enable continuous delivery
and deployment
Process:
Continuous delivery/deployment
Organization:
Small, agile, autonomous,
cross functional teams
Architecture:
Microservice architecture
Enables
Enables
Enables
Successful
Software
Development
@crichardson
Microservices enable continuous delivery
and deployment
Process:
Continuous delivery/deployment
Organization:
Small, agile, autonomous,
cross functional teams
Architecture:
Microservice architecture
Enables
Enables
Enables
Successful
Software
Development
Services improve
testability
and
deployability
@crichardson
Microservices enable continuous delivery
and deployment
Process:
Continuous delivery/deployment
Organization:
Small, agile, autonomous,
cross functional teams
Architecture:
Microservice architecture
Enables
Enables
Enables
Successful
Software
Development
Services improve
testability
and
deployability
Teams own services
@crichardson
Easily try other technologies
@crichardson
Easily try other technologies
... and fail safely
@crichardson
Where does Redis fit in?
Using Redis within a service
Caching
High performance database
Catalog
Service
Catalog
DB
@crichardson
Using Redis for inter-service communication
API
Gateway
Catalog
Service
Review
Service
…
Service
Pub/Sub
Need Product
Details X
GET /product/X
Need … Need … Need …Info Info Info
@crichardson
Redis and the API Gateway
API
Gateway
Caching
Rate limiting
Routing
@crichardson
No silver bullet
http://en.wikipedia.org/wiki/Fred_Brooks
@crichardson
Drawbacks of microservices
Complexity
@crichardson
Drawbacks of microservices
Complexity
Development: IPC, partial failure, distributed data
@crichardson
Drawbacks of microservices
Complexity
Development: IPC, partial failure, distributed data
Testing: Integration, end to end, …
@crichardson
Drawbacks of microservices
Complexity
Development: IPC, partial failure, distributed data
Testing: Integration, end to end, …
Deployment
…
@crichardson
Are microservices a good fit for
my application?
@crichardson
When using microservices:
@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?
@crichardson
Patterns
=
Better decisions
@crichardson
What’s a pattern?
Reusable solution
to a problem
occurring
in a particular context
@crichardson
The structure of a pattern encourages
objectivity
Resulting context
Name
Context
Problem
Related patterns
Forces
Solution
@crichardson
The structure of a pattern encourages
objectivity
Resulting context
The situation
Name
Context
Problem
Related patterns
Forces
Solution
@crichardson
The structure of a pattern encourages
objectivity
Resulting context
The situation
Name
Context
Problem
Related patterns
The issues that must be
addressed
Forces
Solution
@crichardson
The structure of a pattern encourages
objectivity
Resulting context
The situation
Name
Context
Problem
Related patterns
The issues that must be
addressed
Forces
Solution
Benefits
Drawbacks
Issues
@crichardson
The structure of a pattern encourages
objectivity
Resulting context
The situation
Name
Context
Problem
Related patterns
The issues that must be
addressed
Forces
Solution
Benefits
Drawbacks
Issues
Patterns that are alternative
solutions
Patterns that address the issues
@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
@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
@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
@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
@crichardson
The rest are generic technical
architecture patterns
=
Undifferentiated heavy lifting!
@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
@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
@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
@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
@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
@crichardson
Solving distributed data management
problems
in a microservice architecture
@crichardson
Loose coupling = encapsulated data
Order Service Customer Service
Order Database Customer Database
Order table
Customer
table
orderTotal creditLimit
@crichardson
How to maintain data consistency?
sum(order.total) <= customer.creditLimit
@crichardson
Cannot use ACID transactions
BEGIN TRANSACTION
…
SELECT ORDER_TOTAL
FROM ORDERS WHERE CUSTOMER_ID = ?
…
SELECT CREDIT_LIMIT
FROM CUSTOMERS WHERE CUSTOMER_ID = ?
…
INSERT INTO ORDERS …
…
COMMIT TRANSACTION
@crichardson
Cannot use ACID transactions
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
@crichardson
Cannot use ACID transactions
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
@crichardson
2PC is not an option
@crichardson
Instead: use event-driven sagas
Distributed transaction
Order

Service
Customer

Service
@crichardson
Saga
Instead: use event-driven sagas
Distributed transaction
Order

Service
Customer

Service
Local transaction
Order

Service
Local transaction
Customer

Service
Local transaction
Order

Service
Event
Event
X
@crichardson
Order Service
Saga-based, eventually consistent order processing
Customer Service
Customer
creditLimit
creditReservations
...
Event Handler
Event Handler
@crichardson
Order Service
Saga-based, eventually consistent order processing
Customer Service
Create Order
Customer
creditLimit
creditReservations
...
Event Handler
Event Handler
@crichardson
Order Service
Saga-based, eventually consistent order processing
Customer Service
Create Order
Customer
creditLimit
creditReservations
...
Order
state
total
…
Event Handler
Event Handler
@crichardson
Order Service
Saga-based, eventually consistent order processing
Customer Service
Order created
Create Order
Customer
creditLimit
creditReservations
...
Order
state
total
…
Event Handler
Event Handler
reserveCredit()
@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
…
Event Handler
Event Handler
reserveCredit()
@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()
@crichardson
Service
Reliable sagas require atomicity
Database Message Broker
update publish
How to make
atomic without
2PC?
@crichardson
Event sourcing: event-centric persistence
Service
Event Store
save events
and
publish
Event table
Entity type
Event
id
Entity
id
Event
data
Event
type
Every state change event
@crichardson
Event sourcing: event-centric persistence
Service
Event Store
save events
and
publish
Event table
Entity type
Event
id
Entity
id
Event
data
Event
type
Order 901101 …OrderCreated
Every state change event
@crichardson
Event sourcing: event-centric persistence
Service
Event Store
save events
and
publish
Event table
Entity type
Event
id
Entity
id
Event
data
Order 902101 …OrderApproved
Event
type
Order 901101 …OrderCreated
Every state change event
@crichardson
Event sourcing: event-centric persistence
Service
Event Store
save events
and
publish
Event table
Entity type
Event
id
Entity
id
Event
data
Order 902101 …OrderApproved
Order 903101 …OrderShipped
Event
type
Order 901101 …OrderCreated
Every state change event
@crichardson
How to implement queries?
@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 > ?
@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
@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?
@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
@crichardson
Query side
(Materialized)
View
Command Query Responsibility Segregation
(CQRS)
Command side
Commands
Aggregate
Queries
(Materialized)
View
POST
PUT
DELETE
GET
@crichardson
Query side
(Materialized)
View
Command Query Responsibility Segregation
(CQRS)
Command side
Commands
Aggregate
Event Store
Events
Queries
(Materialized)
View
POST
PUT
DELETE
GET
@crichardson
Query side
(Materialized)
View
Command Query Responsibility Segregation
(CQRS)
Command side
Commands
Aggregate
Event Store
Events
Queries
(Materialized)
View
Events
POST
PUT
DELETE
GET
@crichardson
Food to Go example - on github.com
http://bit.ly/redis-pia
94619:Monday [0700_2:1430, 1130_1:1430, ...]
94619:Tuesday [0700_2:1430, 1130_1:1430, ...]
… …
Restaurant
View
Updater
Service
Restaurant
View
Query
Service
ZRANGEBYSCORE
Event Store
Restaurant
events Materialized view of
restaurant locations
and opening hours
GET
available
restaurants
ZADD
ZREM
Sorted sets
@crichardson
Summary
@crichardson
Summary
Organize into small, agile, autonomous teams responsible for one or more
microservices
@crichardson
Summary
Organize into small, agile, autonomous teams responsible for one or more
microservices
Use an event-driven architecture based on event sourcing and CQRS
@crichardson
Summary
Organize into small, agile, autonomous teams responsible for one or more
microservices
Use an event-driven architecture based on event sourcing and CQRS
Use Redis throughout a microservices architecture
Thank	
  You
Chris	
  Richardson	
  
Founder	
  
http://eventuate.io	
  
#redisconf17

More Related Content

PDF
Microservices and Redis #redisconf Keynote
PDF
A pattern language for microservices (#SFMicroservices)
PDF
Events on the outside, on the inside and at the core - Chris Richardson
PDF
A pattern language for microservices (#gluecon #gluecon2016)
PDF
A Pattern Language for Microservices
PDF
An overview of the Eventuate Platform
PDF
Solving distributed data management problems in a microservice architecture (...
PDF
Saturn2017: No such thing as a microservice!
Microservices and Redis #redisconf Keynote
A pattern language for microservices (#SFMicroservices)
Events on the outside, on the inside and at the core - Chris Richardson
A pattern language for microservices (#gluecon #gluecon2016)
A Pattern Language for Microservices
An overview of the Eventuate Platform
Solving distributed data management problems in a microservice architecture (...
Saturn2017: No such thing as a microservice!

What's hot (20)

PDF
Events on the outside, on the inside and at the core (jfokus jfokus2016)
PDF
Omnikron webbinar - Microservices: enabling the rapid, frequent, and reliable...
PDF
There is no such thing as a microservice! (oracle code nyc)
PDF
#hacksummit 2016 - event-driven microservices – Events on the outside, on the...
PDF
Spring Days NYC - A pattern language for microservices
PDF
ArchSummit Shenzhen - Using sagas to maintain data consistency in a microserv...
PDF
Oracle CodeOne 2019: Decompose Your Monolith: Strategies for Migrating to Mic...
PDF
Kong Summit 2018 - Microservices: decomposing applications for testability an...
PDF
Developing event-driven microservices with event sourcing and CQRS (london Ja...
PDF
Developing Event-driven Microservices with Event Sourcing & CQRS (gotoams)
PDF
OReilly SACON2018 - Events on the outside, on the inside, and at the core
PDF
Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...
PDF
Polyglot persistence for Java developers: time to move out of the relational ...
PDF
Developing microservices with aggregates (SpringOne platform, #s1p)
PDF
Events to the rescue: solving distributed data problems in a microservice arc...
PDF
SVCC Microservices: Decomposing Applications for Testability and Deployability
PDF
MicroCPH - Managing data consistency in a microservice architecture using Sagas
PDF
microXchg: Managing data consistency in a microservice architecture using Sagas
PDF
Melbourne Jan 2019 - Microservices adoption anti-patterns: Obstacles to decom...
PDF
Microservices pattern language (microxchg microxchg2016)
Events on the outside, on the inside and at the core (jfokus jfokus2016)
Omnikron webbinar - Microservices: enabling the rapid, frequent, and reliable...
There is no such thing as a microservice! (oracle code nyc)
#hacksummit 2016 - event-driven microservices – Events on the outside, on the...
Spring Days NYC - A pattern language for microservices
ArchSummit Shenzhen - Using sagas to maintain data consistency in a microserv...
Oracle CodeOne 2019: Decompose Your Monolith: Strategies for Migrating to Mic...
Kong Summit 2018 - Microservices: decomposing applications for testability an...
Developing event-driven microservices with event sourcing and CQRS (london Ja...
Developing Event-driven Microservices with Event Sourcing & CQRS (gotoams)
OReilly SACON2018 - Events on the outside, on the inside, and at the core
Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...
Polyglot persistence for Java developers: time to move out of the relational ...
Developing microservices with aggregates (SpringOne platform, #s1p)
Events to the rescue: solving distributed data problems in a microservice arc...
SVCC Microservices: Decomposing Applications for Testability and Deployability
MicroCPH - Managing data consistency in a microservice architecture using Sagas
microXchg: Managing data consistency in a microservice architecture using Sagas
Melbourne Jan 2019 - Microservices adoption anti-patterns: Obstacles to decom...
Microservices pattern language (microxchg microxchg2016)
Ad

Similar to RedisConf17 - A pattern language for microservices - Chris Richardson (20)

PDF
Code Freeze 2018: There is no such thing as a microservice!
PDF
A Pattern Language for Microservices (@futurestack)
PDF
A pattern language for microservices
PDF
A pattern language for microservices - Chris Richardson
PDF
Decompose that WAR? A pattern language for microservices (@QCON @QCONSP)
PDF
A pattern language for microservices (melbourne)
PDF
Using patterns and pattern languages to make better architectural decisions
PDF
The microservice architecture: what, why, when and how?
PDF
Oracle Code Sydney - There is no such thing as a microservice!
PDF
A pattern language for microservices - June 2021
PDF
iSAQB gathering 2021 keynote - Architectural patterns for rapid, reliable, fr...
PDF
Microservices - an architecture that enables DevOps (T Systems DevOps day)
PDF
The top 6 microservices patterns
PDF
JFokus: Cubes, Hexagons, Triangles, and More: Understanding Microservices
PPTX
Micro service session 1
PDF
Dark Energy, Dark Matter and the Microservices Patterns?!
PDF
CloudDesignPatterns
PPTX
Introduction to Microservices
PDF
Microservices Design Patterns
PPTX
Alex Thissen (Xpirit) - Een verschuiving in architectuur: op weg naar microse...
Code Freeze 2018: There is no such thing as a microservice!
A Pattern Language for Microservices (@futurestack)
A pattern language for microservices
A pattern language for microservices - Chris Richardson
Decompose that WAR? A pattern language for microservices (@QCON @QCONSP)
A pattern language for microservices (melbourne)
Using patterns and pattern languages to make better architectural decisions
The microservice architecture: what, why, when and how?
Oracle Code Sydney - There is no such thing as a microservice!
A pattern language for microservices - June 2021
iSAQB gathering 2021 keynote - Architectural patterns for rapid, reliable, fr...
Microservices - an architecture that enables DevOps (T Systems DevOps day)
The top 6 microservices patterns
JFokus: Cubes, Hexagons, Triangles, and More: Understanding Microservices
Micro service session 1
Dark Energy, Dark Matter and the Microservices Patterns?!
CloudDesignPatterns
Introduction to Microservices
Microservices Design Patterns
Alex Thissen (Xpirit) - Een verschuiving in architectuur: op weg naar microse...
Ad

More from Redis Labs (20)

PPTX
Redis Day Bangalore 2020 - Session state caching with redis
PPTX
Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020
PPTX
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
PPTX
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
PPTX
Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...
PPTX
Redis for Data Science and Engineering by Dmitry Polyakovsky of Oracle
PPTX
Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020
PPTX
Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020
PPTX
Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...
PPTX
JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...
PPTX
Highly Available Persistent Session Management Service by Mohamed Elmergawi o...
PPTX
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
PPTX
Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...
PPTX
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
PPTX
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
PPTX
RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020
PPTX
RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020
PPTX
Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...
PDF
Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...
PPTX
Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...
Redis Day Bangalore 2020 - Session state caching with redis
Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...
Redis for Data Science and Engineering by Dmitry Polyakovsky of Oracle
Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020
Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020
Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...
JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...
Highly Available Persistent Session Management Service by Mohamed Elmergawi o...
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020
RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020
Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...
Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...
Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...

Recently uploaded (20)

PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
Big Data Technologies - Introduction.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
A Presentation on Artificial Intelligence
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
Building Integrated photovoltaic BIPV_UPV.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
NewMind AI Weekly Chronicles - August'25 Week I
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Big Data Technologies - Introduction.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Encapsulation_ Review paper, used for researhc scholars
Dropbox Q2 2025 Financial Results & Investor Presentation
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Spectral efficient network and resource selection model in 5G networks
A Presentation on Artificial Intelligence
Chapter 3 Spatial Domain Image Processing.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”

RedisConf17 - A pattern language for microservices - Chris Richardson

  • 1. A  pattern  language  for  microservices Chris Richardson @crichardson chris@chrisrichardson.net http://eventuate.io
  • 8. @crichardson The monolithic architecture Tomcat Browser WAR SQL database HTML REST/JSON Client App Simple to …. Develop Test Deploy Scale Catalog Module Reviews Module Orders Module StoreFront UI Module
  • 10. @crichardson … and modularity breaks down… http://www.laputan.org/mud/
  • 11. @crichardson Monolithic hell Agile development and deployment becomes impossible Technology stack becomes increasingly obsolete BUT a rewrite is not feasible
  • 12. The microservice architecture is an architectural style that structures an application as a set of loosely coupled, services organized around business capabilities
  • 13. @crichardson Microservices tackles complexity* through modularity Division of labor Division of knowledge
  • 14. @crichardson Microservices tackles complexity* through modularity Division of labor Division of knowledge * might improve scalability too
  • 15. @crichardson Microservice architecture = functional decomposition Catalog Service Review Service Order Service … Service
  • 16. @crichardson Microservice architecture = functional decomposition Catalog Service Review Service Order Service … Service Catalog Database Review Database Order Database … Database
  • 17. @crichardson Microservice architecture = functional decomposition Browser Mobile Device Store Front UI API Gateway Catalog Service Review Service Order Service … Service Catalog Database Review Database Order Database … Database HTML REST REST
  • 18. @crichardson Microservices enable continuous delivery and deployment Process: Continuous delivery/deployment Organization: Small, agile, autonomous, cross functional teams Architecture: Microservice architecture Enables Enables Enables Successful Software Development
  • 19. @crichardson Microservices enable continuous delivery and deployment Process: Continuous delivery/deployment Organization: Small, agile, autonomous, cross functional teams Architecture: Microservice architecture Enables Enables Enables Successful Software Development Services improve testability and deployability
  • 20. @crichardson Microservices enable continuous delivery and deployment Process: Continuous delivery/deployment Organization: Small, agile, autonomous, cross functional teams Architecture: Microservice architecture Enables Enables Enables Successful Software Development Services improve testability and deployability Teams own services
  • 22. @crichardson Easily try other technologies ... and fail safely
  • 24. Using Redis within a service Caching High performance database Catalog Service Catalog DB
  • 25. @crichardson Using Redis for inter-service communication API Gateway Catalog Service Review Service … Service Pub/Sub Need Product Details X GET /product/X Need … Need … Need …Info Info Info
  • 26. @crichardson Redis and the API Gateway API Gateway Caching Rate limiting Routing
  • 29. @crichardson Drawbacks of microservices Complexity Development: IPC, partial failure, distributed data
  • 30. @crichardson Drawbacks of microservices Complexity Development: IPC, partial failure, distributed data Testing: Integration, end to end, …
  • 31. @crichardson Drawbacks of microservices Complexity Development: IPC, partial failure, distributed data Testing: Integration, end to end, … Deployment …
  • 32. @crichardson Are microservices a good fit for my application?
  • 34. @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?
  • 36. @crichardson What’s a pattern? Reusable solution to a problem occurring in a particular context
  • 37. @crichardson The structure of a pattern encourages objectivity Resulting context Name Context Problem Related patterns Forces Solution
  • 38. @crichardson The structure of a pattern encourages objectivity Resulting context The situation Name Context Problem Related patterns Forces Solution
  • 39. @crichardson The structure of a pattern encourages objectivity Resulting context The situation Name Context Problem Related patterns The issues that must be addressed Forces Solution
  • 40. @crichardson The structure of a pattern encourages objectivity Resulting context The situation Name Context Problem Related patterns The issues that must be addressed Forces Solution Benefits Drawbacks Issues
  • 41. @crichardson The structure of a pattern encourages objectivity Resulting context The situation Name Context Problem Related patterns The issues that must be addressed Forces Solution Benefits Drawbacks Issues Patterns that are alternative solutions Patterns that address the issues
  • 42. @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
  • 43. @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
  • 44. @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
  • 45. @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
  • 46. @crichardson The rest are generic technical architecture patterns = Undifferentiated heavy lifting!
  • 47. @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
  • 48. @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
  • 49. @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
  • 50. @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
  • 51. @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
  • 52. @crichardson Solving distributed data management problems in a microservice architecture
  • 53. @crichardson Loose coupling = encapsulated data Order Service Customer Service Order Database Customer Database Order table Customer table orderTotal creditLimit
  • 54. @crichardson How to maintain data consistency? sum(order.total) <= customer.creditLimit
  • 55. @crichardson Cannot use ACID transactions BEGIN TRANSACTION … SELECT ORDER_TOTAL FROM ORDERS WHERE CUSTOMER_ID = ? … SELECT CREDIT_LIMIT FROM CUSTOMERS WHERE CUSTOMER_ID = ? … INSERT INTO ORDERS … … COMMIT TRANSACTION
  • 56. @crichardson Cannot use ACID transactions 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
  • 57. @crichardson Cannot use ACID transactions 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
  • 59. @crichardson Instead: use event-driven sagas Distributed transaction Order
 Service Customer
 Service
  • 60. @crichardson Saga Instead: use event-driven sagas Distributed transaction Order
 Service Customer
 Service Local transaction Order
 Service Local transaction Customer
 Service Local transaction Order
 Service Event Event X
  • 61. @crichardson Order Service Saga-based, eventually consistent order processing Customer Service Customer creditLimit creditReservations ... Event Handler Event Handler
  • 62. @crichardson Order Service Saga-based, eventually consistent order processing Customer Service Create Order Customer creditLimit creditReservations ... Event Handler Event Handler
  • 63. @crichardson Order Service Saga-based, eventually consistent order processing Customer Service Create Order Customer creditLimit creditReservations ... Order state total … Event Handler Event Handler
  • 64. @crichardson Order Service Saga-based, eventually consistent order processing Customer Service Order created Create Order Customer creditLimit creditReservations ... Order state total … Event Handler Event Handler reserveCredit()
  • 65. @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 … Event Handler Event Handler reserveCredit()
  • 66. @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()
  • 67. @crichardson Service Reliable sagas require atomicity Database Message Broker update publish How to make atomic without 2PC?
  • 68. @crichardson Event sourcing: event-centric persistence Service Event Store save events and publish Event table Entity type Event id Entity id Event data Event type Every state change event
  • 69. @crichardson Event sourcing: event-centric persistence Service Event Store save events and publish Event table Entity type Event id Entity id Event data Event type Order 901101 …OrderCreated Every state change event
  • 70. @crichardson Event sourcing: event-centric persistence Service Event Store save events and publish Event table Entity type Event id Entity id Event data Order 902101 …OrderApproved Event type Order 901101 …OrderCreated Every state change event
  • 71. @crichardson Event sourcing: event-centric persistence Service Event Store save events and publish Event table Entity type Event id Entity id Event data Order 902101 …OrderApproved Order 903101 …OrderShipped Event type Order 901101 …OrderCreated Every state change event
  • 73. @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 > ?
  • 74. @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
  • 75. @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?
  • 76. @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
  • 77. @crichardson Query side (Materialized) View Command Query Responsibility Segregation (CQRS) Command side Commands Aggregate Queries (Materialized) View POST PUT DELETE GET
  • 78. @crichardson Query side (Materialized) View Command Query Responsibility Segregation (CQRS) Command side Commands Aggregate Event Store Events Queries (Materialized) View POST PUT DELETE GET
  • 79. @crichardson Query side (Materialized) View Command Query Responsibility Segregation (CQRS) Command side Commands Aggregate Event Store Events Queries (Materialized) View Events POST PUT DELETE GET
  • 80. @crichardson Food to Go example - on github.com http://bit.ly/redis-pia 94619:Monday [0700_2:1430, 1130_1:1430, ...] 94619:Tuesday [0700_2:1430, 1130_1:1430, ...] … … Restaurant View Updater Service Restaurant View Query Service ZRANGEBYSCORE Event Store Restaurant events Materialized view of restaurant locations and opening hours GET available restaurants ZADD ZREM Sorted sets
  • 82. @crichardson Summary Organize into small, agile, autonomous teams responsible for one or more microservices
  • 83. @crichardson Summary Organize into small, agile, autonomous teams responsible for one or more microservices Use an event-driven architecture based on event sourcing and CQRS
  • 84. @crichardson Summary Organize into small, agile, autonomous teams responsible for one or more microservices Use an event-driven architecture based on event sourcing and CQRS Use Redis throughout a microservices architecture
  • 85. Thank  You Chris  Richardson   Founder   http://eventuate.io   #redisconf17