SlideShare a Scribd company logo
@crichardson
Microservices + Events +
Docker = A Perfect Trio
Chris Richardson
Founder of Eventuate.io
Founder of the original CloudFoundry.com
Author of POJOs in Action
@crichardson
chris@chrisrichardson.net
http://eventuate.io
@crichardson
Presentation goal
http://muppet.wikia.com/wiki/Brought_to_You_by_the_Number_3
Microservices,
Events, and
Docker are a great
way to develop and
deploy applications
@crichardson
About Chris
@crichardson
About Chris
Consultant and trainer
focusing on modern
application architectures
including microservices
(http://www.chrisrichardson.net/)
@crichardson
About Chris
Founder of a startup that is creating
a platform that makes it easier for
developers to write transactional
microservices
(http://eventuate.io)
@crichardson
For more information
http://learnmicroservices.io
@crichardson
Agenda
Monolith vs. microservices
Event-driven microservices
Developing and deploying microservices using Docker
@crichardson
Let’s imagine you are building
a large, complex application,
e.g. an online store
@crichardson
Successful software development
Architecture
Process Organization
Agile
Continuous delivery
…
Small,
autonomous,
teams
3
@crichardson
?Architecture
@crichardson
@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
Monolithic architecture
Process Organization
Agile
Continuous delivery
…
Small,
autonomous,
teams
@crichardson
Apply functional
decomposition
X axis
- horizontal duplication
Z
axis
-data
partitioning
Y axis -
functional
decomposition
Scale
by
splitting
sim
ilar
things
Scale by
splitting
different things
3
@crichardson
Microservice architecture
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
REST
@crichardson
Microservice architecture
Process Organization
Agile
Continuous delivery
…
Small,
autonomous,
teams✔ ✔
@crichardson
Drawbacks
Complexity
@crichardson
Drawbacks
Complexity of developing a distributed system
Implementing inter-process communication
Handling partial failures
Complexity of implementing business transactions that span multiple
databases (without 2PC)
Complexity of testing a distributed system
Complexity of deploying and operating a distributed system
Managing the development and deployment of features that span
multiple services
Fortunately solutions exists
@crichardson
The benefits typically
outweigh the drawbacks
for
large, complex applications
@crichardson
Issues to address
How to deploy the services?
How do the services communicate?
How do clients of the application communicate with the
services?
How to partition the system into services?
How to deal with distributed data management problems?
….
@crichardson
Agenda
Monolith vs. microservices
Event-driven microservices
Developing and deploying microservices using Docker
Data management patterns
@crichardson
The Database
Shared database
Order Service Customer Service … Service
Order table
Customer
table
…
orderTotal creditLimit
Tight coupling
Simple and
ACID
@crichardson
Database per service
Order Service Customer Service
Order Database Customer Database
Order table
Customer
table
orderTotal creditLimit
Loose coupling 😀 but more complex 😓 and….
@crichardson
2PC (aka. distributed
transactions)
is not viable choice
for most modern applications
@crichardson
Customer management
How to maintain data consistency
without 2PC?
Order management
Order Service
placeOrder()
Customer Service
updateCreditLimit()
Customer
creditLimit
...
has ordersbelongs toOrder
total
Invariant:
sum(open order.total) <= customer.creditLimit
?
@crichardson
Event-driven architecture
@crichardson
Use event-driven, eventually
consistent order processing
Order
Service
Customer
Service
Order created
Credit Reserved
Credit Check Failed
Place Order
OR
@crichardson
How atomically update
database and publish an event
Order Service
Order
Database
Message Broker
insert Order
publish
OrderCreatedEvent
dual write problem
?
@crichardson
Reliably publish events when
state changes
@crichardson
Use event-sourcing
Event table
Aggregate
type
Event
id
Aggregate
id
Event
data
Order 902101 …OrderApproved
Order 903101 …OrderShipped
Event
type
Order 901101 …OrderCreated
@crichardson
Replay events to recreate
state
Order
state
OrderCreated(…)
OrderAccepted(…)
OrderShipped(…)
Events
Periodically snapshot to avoid loading all events
@crichardson
Benefits of event sourcing
Solves data consistency issues in a Microservice/NoSQL based
architecture
Reliable event publishing: publishes events needed by predictive
analytics etc, user notifications,…
Eliminates O/R mapping problem (mostly)
Reifies state changes:
Built in, reliable audit log
temporal queries
Preserved history More easily implement future requirements
@crichardson
Drawbacks of event sourcing
Requires application rewrite
Weird and unfamiliar style of programming
Events = a historical record of your bad design decisions
Must handle duplicate events: idempotent handlers or
duplicate detection
Querying the event store can be challenging
But what about queries?
@crichardson
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
Command Query Responsibility
Segregation (CQRS)
Command side
Commands
Aggregate
Event Store
Events
Query side
Queries
Materialized
View
Events
POST
PUT
DELETE
GET
MongoDB
Redis
Neo4j
SQL
ElasticSearch
…
More complex 😓 but high performance, scalable views 😀
@crichardson
Agenda
Monolith vs. microservices
Event-driven microservices
Developing and deploying microservices using Docker
@crichardson
We have applied the microservices pattern:
How to deploy the 10s or 100s of services?
@crichardson
Forces
Services are written using a variety of languages, frameworks,
and framework versions
Each service consists of multiple service instances for
throughput and availability
Building and deploying a service must be fast
Services must be deployed and scaled independently
Service instances need to be isolated
Deployment must be reliable and cost-effective
@crichardson
@crichardson
@crichardson
VM
VM
Pattern: Service per Container
host
Service
Container
image
Container
Service
Container
Service
Container
Service
packaged as
deployed as
@crichardson
Benefits of containers
Great isolation
Great manageability
Container encapsulates implementation technology
Efficient resource utilization
Fast deployment
@crichardson
Docker
(Compose)
also simplifies
development
Running infrastructure services
on development machines
Typical services needs a
database, message
broker, …
Making sure every
developer installs the
correctly version = painful
rabbitmq:
image: rabbitmq:3.5.3
ports:
- "5672:5672"
- "15672:15672"
mongodb:
image: mongo:3.0.4
ports:
- "27017:27017"
command: mongod --smallfiles
@crichardson
Deploying microservices for
end-to-end testing
restfulservice:
image: java:openjdk-8u45-jdk
working_dir: /app
volumes:
- ./spring-boot-restful-service/build/libs:/app
command: java -jar /app/spring-boot-restful-service.jar
ports:
- "8081:8080"
links:
- rabbitmq
- mongodb
environment:
SPRING_DATA_MONGODB_URI: mongodb://mongodb/userregistration
SPRING_RABBITMQ_HOST: rabbitmq
@crichardson
Jenkins-based deployment
pipeline
Build & Test
microservice
Build & Test
Docker
image
Deploy
Docker
image
to registry
One pipeline per microservice
@crichardson
Smoke testing docker images
Smoke test
Docker
daemon
Service
containerGET /health
POST /containers/create
creates
POST /containers/{id}/start
Docker daemon must listen on
TCP port
@crichardson
Running on Docker!
EC2 Instance
Jenkins
Container
Artifactory
container
EBS volume
/jenkins-
home
/gradle-home
/artifactory-
home
@crichardson
Summary
Use microservices to accelerate development
Use an event-driven architecture to maintain data consistency
Use Docker to simplify development and deployment
@crichardson
@crichardson chris@chrisrichardson.net
http://learnmicroservices.io
Questions?

More Related Content

PPSX
Event Sourcing & CQRS, Kafka, Rabbit MQ
PPTX
Database CI/CD Pipeline
PDF
My First 100 days with an Exadata (PPT)
PDF
Microservice Architecture with CQRS and Event Sourcing
PPTX
Azure Migrate
PPTX
Let's Talk About: Database Migration Service
PPTX
Grafana.pptx
PDF
Oracle Database統合のベスト・プラクティス
Event Sourcing & CQRS, Kafka, Rabbit MQ
Database CI/CD Pipeline
My First 100 days with an Exadata (PPT)
Microservice Architecture with CQRS and Event Sourcing
Azure Migrate
Let's Talk About: Database Migration Service
Grafana.pptx
Oracle Database統合のベスト・プラクティス

What's hot (20)

PDF
Training Webinar: Fitting OutSystems applications into Enterprise Architecture
PPTX
Azure Cloud Adoption Framework + Governance - Sana Khan and Jay Kumar
PDF
事例から見る規模別クラウド・データベースの選び方 (Oracle Database) (Oracle Cloudウェビナーシリーズ: 2021年6月30日)
PPTX
Azure Synapse Analytics Overview (r1)
PDF
Azure SQL Data Warehouse
PDF
Prometheus + Grafana = Awesome Monitoring
PPTX
Azure fundamentals
PPTX
Microservices Architecture Part 2 Event Sourcing and Saga
PPT
Requirement Gathering & Rapid Prototyping
PDF
Azure SQL Database Managed Instance - technical overview
PDF
AZ-900 Azure Fundamentals.pdf
PDF
Oracle Database: リリースモデルとアップグレード・パッチ計画 (2021年2月版)
PDF
Sql server 2019 new features
PDF
Next-Generation Cloud Native Apps with Spring Cloud and Kubernetes
PDF
【旧版】Oracle Exadata Cloud Service:サービス概要のご紹介 [2021年7月版]
PPTX
Getting started with azure event hubs and stream analytics services
PPTX
The Microservices world in. NET Core and. NET framework
PDF
The Layman's Guide to Microsoft Azure
PPTX
Domain Driven Design
PDF
Azure Monitoring Overview
Training Webinar: Fitting OutSystems applications into Enterprise Architecture
Azure Cloud Adoption Framework + Governance - Sana Khan and Jay Kumar
事例から見る規模別クラウド・データベースの選び方 (Oracle Database) (Oracle Cloudウェビナーシリーズ: 2021年6月30日)
Azure Synapse Analytics Overview (r1)
Azure SQL Data Warehouse
Prometheus + Grafana = Awesome Monitoring
Azure fundamentals
Microservices Architecture Part 2 Event Sourcing and Saga
Requirement Gathering & Rapid Prototyping
Azure SQL Database Managed Instance - technical overview
AZ-900 Azure Fundamentals.pdf
Oracle Database: リリースモデルとアップグレード・パッチ計画 (2021年2月版)
Sql server 2019 new features
Next-Generation Cloud Native Apps with Spring Cloud and Kubernetes
【旧版】Oracle Exadata Cloud Service:サービス概要のご紹介 [2021年7月版]
Getting started with azure event hubs and stream analytics services
The Microservices world in. NET Core and. NET framework
The Layman's Guide to Microsoft Azure
Domain Driven Design
Azure Monitoring Overview
Ad

Similar to Microservices + Events + Docker = A Perfect Trio (dockercon) (20)

PDF
Developing event-driven microservices with event sourcing and CQRS (Shanghai)
PDF
Developing event-driven microservices with event sourcing and CQRS (london Ja...
PDF
Omnikron webbinar - Microservices: enabling the rapid, frequent, and reliable...
PDF
Solving distributed data management problems in a microservice architecture (...
PDF
Saturn2017: No such thing as a microservice!
PDF
Building microservices with Scala, functional domain models and Spring Boot
PDF
Microservices: Decomposing Applications for Deployability and Scalability (ja...
PDF
Building and deploying microservices with event sourcing, CQRS and Docker (Ha...
PDF
Developing event-driven microservices with event sourcing and CQRS (phillyete)
PDF
Building and deploying microservices with event sourcing, CQRS and Docker (QC...
PDF
There is no such thing as a microservice! (oracle code nyc)
PDF
Saturn 2018: Managing data consistency in a microservice architecture using S...
PDF
Kong Summit 2018 - Microservices: decomposing applications for testability an...
PDF
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
PDF
Developing applications with a microservice architecture (svcc)
PDF
Microservices in Java and Scala (sfscala)
PDF
Developing applications with a microservice architecture (SVforum, microservi...
PDF
YOW2018 - Events and Commands: Developing Asynchronous Microservices
PDF
Dark Energy, Dark Matter and the Microservices Patterns?!
PDF
Code Freeze 2018: There is no such thing as a microservice!
Developing event-driven microservices with event sourcing and CQRS (Shanghai)
Developing event-driven microservices with event sourcing and CQRS (london Ja...
Omnikron webbinar - Microservices: enabling the rapid, frequent, and reliable...
Solving distributed data management problems in a microservice architecture (...
Saturn2017: No such thing as a microservice!
Building microservices with Scala, functional domain models and Spring Boot
Microservices: Decomposing Applications for Deployability and Scalability (ja...
Building and deploying microservices with event sourcing, CQRS and Docker (Ha...
Developing event-driven microservices with event sourcing and CQRS (phillyete)
Building and deploying microservices with event sourcing, CQRS and Docker (QC...
There is no such thing as a microservice! (oracle code nyc)
Saturn 2018: Managing data consistency in a microservice architecture using S...
Kong Summit 2018 - Microservices: decomposing applications for testability an...
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
Developing applications with a microservice architecture (svcc)
Microservices in Java and Scala (sfscala)
Developing applications with a microservice architecture (SVforum, microservi...
YOW2018 - Events and Commands: Developing Asynchronous Microservices
Dark Energy, Dark Matter and the Microservices Patterns?!
Code Freeze 2018: There is no such thing as a microservice!
Ad

More from Chris Richardson (20)

PDF
The microservice architecture: what, why, when and how?
PDF
More the merrier: a microservices anti-pattern
PDF
YOW London - Considering Migrating a Monolith to Microservices? A Dark Energy...
PDF
Dark energy, dark matter and microservice architecture collaboration patterns
PDF
Scenarios_and_Architecture_SkillsMatter_April_2022.pdf
PDF
Using patterns and pattern languages to make better architectural decisions
PDF
iSAQB gathering 2021 keynote - Architectural patterns for rapid, reliable, fr...
PDF
Events to the rescue: solving distributed data problems in a microservice arc...
PDF
A pattern language for microservices - June 2021
PDF
QConPlus 2021: Minimizing Design Time Coupling in a Microservice Architecture
PDF
Mucon 2021 - Dark energy, dark matter: imperfect metaphors for designing micr...
PDF
Designing loosely coupled services
PDF
Microservices - an architecture that enables DevOps (T Systems DevOps day)
PDF
DDD SoCal: Decompose your monolith: Ten principles for refactoring a monolith...
PDF
Decompose your monolith: Six principles for refactoring a monolith to microse...
PDF
TDC2020 - The microservice architecture: enabling rapid, reliable, frequent a...
PDF
Overview of the Eventuate Tram Customers and Orders application
PDF
An overview of the Eventuate Platform
PDF
#DevNexus202 Decompose your monolith
PDF
JFokus: Cubes, Hexagons, Triangles, and More: Understanding Microservices
The microservice architecture: what, why, when and how?
More the merrier: a microservices anti-pattern
YOW London - Considering Migrating a Monolith to Microservices? A Dark Energy...
Dark energy, dark matter and microservice architecture collaboration patterns
Scenarios_and_Architecture_SkillsMatter_April_2022.pdf
Using patterns and pattern languages to make better architectural decisions
iSAQB gathering 2021 keynote - Architectural patterns for rapid, reliable, fr...
Events to the rescue: solving distributed data problems in a microservice arc...
A pattern language for microservices - June 2021
QConPlus 2021: Minimizing Design Time Coupling in a Microservice Architecture
Mucon 2021 - Dark energy, dark matter: imperfect metaphors for designing micr...
Designing loosely coupled services
Microservices - an architecture that enables DevOps (T Systems DevOps day)
DDD SoCal: Decompose your monolith: Ten principles for refactoring a monolith...
Decompose your monolith: Six principles for refactoring a monolith to microse...
TDC2020 - The microservice architecture: enabling rapid, reliable, frequent a...
Overview of the Eventuate Tram Customers and Orders application
An overview of the Eventuate Platform
#DevNexus202 Decompose your monolith
JFokus: Cubes, Hexagons, Triangles, and More: Understanding Microservices

Recently uploaded (20)

PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
ai tools demonstartion for schools and inter college
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
System and Network Administration Chapter 2
PPT
Introduction Database Management System for Course Database
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
top salesforce developer skills in 2025.pdf
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
medical staffing services at VALiNTRY
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PTS Company Brochure 2025 (1).pdf.......
Design an Analysis of Algorithms II-SECS-1021-03
ai tools demonstartion for schools and inter college
How to Migrate SBCGlobal Email to Yahoo Easily
Operating system designcfffgfgggggggvggggggggg
System and Network Administration Chapter 2
Introduction Database Management System for Course Database
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Odoo POS Development Services by CandidRoot Solutions
ManageIQ - Sprint 268 Review - Slide Deck
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
top salesforce developer skills in 2025.pdf
Odoo Companies in India – Driving Business Transformation.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Internet Downloader Manager (IDM) Crack 6.42 Build 41
medical staffing services at VALiNTRY
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx

Microservices + Events + Docker = A Perfect Trio (dockercon)