SlideShare a Scribd company logo
@crichardson
Decompose your monolith:
strategies for migrating to
microservices
Chris Richardson
Founder of Eventuate.io
Founder of the original CloudFoundry.com
Author of POJOs in Action and Microservices Patterns
@crichardson
chris@chrisrichardson.net
https://adopt.microservices.io
Copyright © 2019. Chris Richardson Consulting, Inc. All rights reserved
@crichardson
Presentation goal
How to incrementally refactor a
monolithic application to
microservices
@crichardson
About Chris
http://adopt.microservices.io
@crichardson
About Chris
https://microservices.io/book
40% discount with code 	
ctworaclecodeone19
About Chris: microservices.io
Microservices pattern
language
Articles
Example code
Microservices Assessment
Platform
@crichardson
Agenda
Why microservices?
Overview of refactoring a monolith
Implementing new features as services
Extracting modules into services
@crichardson
+
Marketplace is volatile, uncertain, complex
and ambiguous
+
Businesses must innovate faster
Deliver software rapidly, frequently and reliably
Software
@crichardson
Monolithic architecture: -ilities
decline over time
Time
Maintainability
Testability
Deployability
Modularity
Evolvability
Size/
Complexity
-ilities required to be competitive
Risk of
disruption
The microservice architecture is
an architectural style
that structures an application as a
set of services*
Each microservice is:
• highly maintainable and testable
• loosely coupled
• independently deployable
• organized around business capabilities
• owned by a small team
*Start with one service per team until it becomes a problem
@crichardson
Process: Lean + DevOps/Continuous Delivery & Deployment
Organization: Small,
autonomous,
product teams
Architecture:
microservices
Testability
Deployability
Modularity
Modularity
Evolvability
Maintainability
Rapidly, frequently
and reliably delivery of
changes to long-lived
applications
@crichardson
Agenda
Why microservices?
Overview of refactoring a monolith
Implementing new features as services
Extracting modules into services
@crichardson
When to migrate to
microservices: DON”T!
The monolithic architecture is not an anti-pattern
If software delivery is slow
Optimize development process
Improve deployment pipeline = more automation
Improve team autonomy
Modularize the monolith
Eliminate hand-offs and create cross functional teams
If technology stack is obsolete modernize to a new monolith
…
@crichardson
If and only if that is
insufficient* then consider
migrating to microservices
*Large, complex applications developed by a
(usually) large team that need to be delivered
rapidly, frequently, and reliably
@crichardson
How do you decompose your
big, scary monolithic application?
Monolith
Service?
Microservice architecture
Service
Service
Service
@crichardson
According to Randy Shoup:
“As Martin Fowler likes to say, the only
thing a Big Bang rewrite guarantees is a
Big Bang!”
http://www.randyshoup.com/evolutionary-architecture
@crichardson
Best done incrementally!
@crichardson
Strangler
Application
http://www.martinfowler.com/bliki/StranglerApplication.html
@crichardson
@crichardson
Strangling the monolith
Monolith
Time
Monolith
Service
Monolith
Service
Service
Monolith
Service
Service
Service
Service
…. Monolith
Service
Service
Service
Service
Service
Service
Service
Service
Service
Service
Service
Service
Service
Service
Service
Service
….
Strangler application
The strangler application grows larger over time
The monolith shrinks over time
@crichardson
Module
Strangling the monolith: reroute
requests to services
Monolith Service
API Gateway
Request
Monolith
Module
Request
@crichardson
Agenda
Why microservices?
Overview of refactoring a monolith
Implementing new features as services
Extracting modules into services
@crichardson
Let’s imagine you want to implement
a significant new feature….
The Law of Holes:
"if you find yourself in a hole, stop digging"
(https://en.m.wikipedia.org/wiki/Law_of_holes)
Stop making the monolith larger!
@crichardson
Implement new functionality as a
service
Monolith Service
Data integration glue
API Gateway
Request
Monolithic
database
Service
database
Code in service/monolith
that enables service to
access monolith’s data
Pristine
new
service
@crichardson
Service Monolith data integration glue:
API invocation
Monolith Service
Monolithic
database
Service
database
Invokes
Command/
Query
@crichardson
Service Monolith data integration glue:
replicate data for reading
Monolith Service
Monolithic
database
Service
database
Application events
DB replicationTables Replica
CDC Events
@crichardson
Service Monolith data
access options
Option Benefits Drawbacks
API call to
monolith
Simple
Works for writes and reads
Doesn’t efficiently support
complex queries
Replicate
data to
service
Supports complex queries
Only for reads
Cost/complexity of replication
@crichardson
Data replication options
Option Benefits Drawbacks
Application events
Easy to publish meaningful events
Decoupled
Requires code changes in monolith
Eventual consistency
Change data capture
CRUD Events
No code changes in monolith
Decoupled
Publishing non-CRUD event is tricky
Eventual consistency
Triggers that publish
CRUD events
Simple
No code changes in monolith
Decoupled
Triggers = yuck
Publishing non-CRUD event is tricky
Eventual consistency
Triggers that update
target DB
Simple
No code changes in monolith
ACID consistency
Triggers = yuck
Coupled to target DB
Other DB replication
mechanism, e.g. OGG
Simple
No code changes in monolith
Coupled to target DB
Eventual consistency
@crichardson
FTGO Delayed delivery service
As a workaround for a mediocre
courier scheduling algorithm
that is taking too long to fix……
Improve customer satisfaction
by proactively notifying
customers (and customer
experience) that their order
won’t be delivered on time
FTGO Delayed delivery service
Periodically looks for
orders that won’t be
delivered on time
Not picked up and
restaurant closed
Courier delayed
…
Notifies consumer
and CRM system
getDelayedOrders()
Notification
Service
CRM system
Send
apology
notification
create case
REST
API
???
Delayed Order Service
«stereotype»
Order
«entity»
Restaurant
«entity»
OpeningHours
«entity»
Notification
API gateway
«repository»
Customer
ContactInfo
Repository
Monolith
???
REST
API
«Service»
DelayedDelivery
Service
Integration glue
Need to design
@crichardson
Delayed delivery service: data
integration strategies
Usage How
Orders
“complex” query to
determine whether
delivery will be
delayed
ReplicateRestaurants
Courier
Consumers
Contact info for
notifications
Query via API
@crichardson
Agenda
Why microservices?
Overview of refactoring a monolith
Implementing new features as services
Extracting modules into services
@crichardson
Module service ...
Monolithic database
Module’s tables
Module
Monolith
Ext. API
Including slices
of tables
@crichardson
Define a two way “remotable”
interface
Monolithic database
Module’s tables
Module
Untangle
dependencies
Monolith
Ext. API
Modifying the
monolith is
tricky
@crichardson
Incrementally modify monolith
to invoke module via new API*
Module
Module
All writes - module/service owns its data
Ideally all reads - but can replicate changes back
*Branch by abstraction pattern
@crichardson
Replicating data to reduce scope of
refactoring
ORDER_ID STATE … DELIVERY_STATE COURIER_ID
… … … … …
ORDER_ID STATE … STATE COURIER_ID
… … … … …
ID
…
COURIER_ID
…
ORDERS table
ORDERS table DELIVERY table
Replicate back, e.g. trigger
Read-only replica Extract delivery service
Delivery management
@crichardson
... Module service
Monolith
Service
Monolithic database
Module
Database
API Gateway
Request
Existing code or
rewrite
Ext. API
Bidirectional integration glue
@crichardson
Repeat extracting
services until:
• Eliminated the
monolith
• Solved software
delivery problems
• Higher priority work
Monolith
Time
Monolith
Service
Monolith
Service
Service
Monolith
Service
Service
Service
Service
…. Monolith
Service
Service
Service
Service
Service
Service
Service
Service
Service
Service
Service
Service
Service
Service
Service
Service
….
Strangler application
The strangler application grows larger over time
The monolith shrinks over time
Years
@crichardson
What to extract?
Have the ideal microservice architecture in mind
Limited time-boxed architecture definition effort
But be prepared to revise as you learn more
Start with the modules that would give you the greatest ROI:
Solves a significant problem
Velocity frequently updated
Scalability Conflicting resource requirements
@crichardson
Example:
Extracting delivery
management from the FTGO
monolith
https://microservices.io/refactoring/
@crichardson
AS-IS architecture: tangled code
FTGO
<<module>>
Order and DeliveryManagement
<<entity>>
Order
ORDER_ID STATE … DELIVERY_STATE COURIER_ID
… … … … …
Consumer
Courier
ORDER table
noteAvailable()
notePickedUp
noteDelivered()
…
Tangled code
and data
@crichardson
AS-IS: tangled code
Order
deliveryTime
Restaurant
address
… Courier
address
availability
…
Plan
Action
type
Line
Item
Address
delivery
Delivery
Management
@crichardson
TO-BE design
Order
deliveryTime
Restaurant
Courier
availability
…
Plan
Action
type
Line
Item Address
delivery
Courier
address
availability
…
Delivery
deliveryTime
FTGO monolith Delivery Service
How to sync
with Order?
Owned by
Monolith!
Inter-service
reference!!!
@crichardson
FTGO monolith Delivery Service integration
Delivery Service
Restaurant
Courier
availability
…
Delivery
deliveryTime
schedule()
reschedule()
cancel()
“Replicas”
FTGO monolith
Data integration glue
Client
API
@crichardson
AS-IS TO-BE: Overview of
extracting the Delivery Service
1. Split the code: convert delivery management code into a
module within the monolith
2.Split the database: define separate DB schema for delivery
management within the monolith
3.Define and deploy Delivery Service
4.Use the Delivery Service
5.Remove old code from monolith
Commit and deploy changes after each step
@crichardson
FTGO
<<module>>
Order Management
<<module>>
Delivery Management
<<entity>>
Order
ORDER_ID STATE … DELIVERY_STATE COURIER_ID
… … … … …
Consumer Courier
schedule()
ORDER table
<<entity>>
Delivery
Step #1 - Separate code
cancel()
reschedule()
@crichardson
Delivery Mgmt
Module
Restaurant
Courier
availability
location
…
Delivery
deliveryTime
Delivery
Service
schedule()
reschedule()
cancel()
Delivery
Controller
updateCourierLocation()
updateCourierAvailability()
Order
Service
Order Mgmt
Module
Order
Order table
Courier
Restaurant
Mapped to original
tables
Order Controller
updateCourierLocation()
updateCourierAvailability()
Split
ext. API
Integration
API
Shared
table
@crichardson
FTGO
<<module>>
Order
Management
<<module>>
Delivery
Management
<<entity>>
Order
Consumer
Courier
schedule()
<<entity>>
Delivery
ORDER_ID STATE … STATE COURIER_ID
… … … … …
ID
…
DELIVERY tableORDER table Extract table
Step #2 - Separate data
COURIER_ID
…
Replicate back!
Creates
Delivery
@crichardson
Defining the DELIVERY table
create table ftgo_delivery.delivery (…)
select …subset of columns…
from ftgo.orders
where assigned_courier_id is not null;
CREATE TRIGGER assigned_courier_id_updated
AFTER UPDATE
ON delivery
FOR EACH ROW
BEGIN
UPDATE ftgo.orders
SET assigned_courier_id = NEW.assigned_courier_id
where id = NEW.id;
END;;
Replicate assigned_courier back to ORDERS table
@crichardson
Delivery ServiceFTGO
But it’s not just the DELIVERY table
Courier
Id
Name
Availability
Courier
Id
Name
Availability
…
CourierActions
…
CourierActions
….
Restaurant
Id
Name
Address
Restaurant
Id
Name
Address
…
Sync
@crichardson
Replicating the RESTAURANT
table
create table ftgo_delivery.restaurants
select …subset of columns…
from ftgo.restaurants
CREATE TRIGGER restaurant_created AFTER INSERT
ON ftgo.restaurants
FOR EACH ROW
BEGIN
INSERT INTO ftgo_delivery_service.restaurants(…)
…
@crichardson
FTGO
<<module>>
Order
Management
<<module>>
Delivery
Management
<<entity>>
Order
Consumer Courier
schedule()
<<entity>>
Delivery
ORDER_ID STATE …
STATE COURIER_ID… … …
… …
ID
…
DELIVERY table
ORDER table
Delivery Service
<<module>>
Delivery
Management
<<entity>>
Delivery
Step #3 - Define and deploy
new service
@crichardson
FTGO
<<module>>
Order
Management
<<module>>
Delivery
Management
<<entity>>
Order
Consumer Courier
schedule()
<<entity>>
Delivery
ORDER_ID STATE … STATE COURIER_ID
… … …
… …
ID
…
DELIVERY tableORDER table
Delivery Service
<<module>>
Delivery
Management
<<entity>>
Delivery
Step #4 - Use service
@crichardson
Integration using asynchronous messaging
Delivery
Service
Delivery
Service
schedule()
reschedule()
cancel()
Delivery
Controller
Order
Service
FTGO
Order Controller
Delivery
Service
Proxy
schedule()
…
Command
Handlers
Schedule
command
message
Message
channel
@crichardson
FTGO
<<module>>
Order
Management
<<entity>>
Order
Consumer Courier
schedule() Delivery Service
<<module>>
Delivery
Management
<<entity>>
Delivery
STATE COURIER_ID
… …
ID
…
DELIVERY table
ORDER_ID STATE …
… … …
ORDER table
Step #5 - delete old code
@crichardson
Summary
The microservice architecture enables the rapid, frequent and
reliable delivery of changes to long-lived applications
Incrementally migrate to microservices when you have
outgrown your monolith
Implement new features as services
Extract modules into service
Prioritize extracting modules that give the greatest benefit
@crichardson
@crichardson chris@chrisrichardson.net
http://adopt.microservices.io
Questions?
40% discount with code 	
ctworaclecodeone19

More Related Content

PDF
Microservices Interview Questions and Answers | Microservices Architecture Tr...
PDF
A pattern language for microservices - June 2021
PPT
Three layer API Design Architecture
PDF
Digital Engagement Suite - Advanced omnichannel banking solution
PDF
APIs in a Microservice Architecture
PPTX
Microservices Architecture & Testing Strategies
PPTX
Microsoft Azure in 5 minutes
PDF
Microservices architecture
Microservices Interview Questions and Answers | Microservices Architecture Tr...
A pattern language for microservices - June 2021
Three layer API Design Architecture
Digital Engagement Suite - Advanced omnichannel banking solution
APIs in a Microservice Architecture
Microservices Architecture & Testing Strategies
Microsoft Azure in 5 minutes
Microservices architecture

What's hot (20)

PDF
Escaping Dependency Hell: A deep dive into Gradle's dependency management fea...
PPTX
Introduction to microservices
PPTX
App Modernization
PPTX
What’s new in OpenText Extended ECM Platform CE 21.1 and OpenText Content Sui...
PDF
MicroService Architecture
PDF
Microservice Architecture
PPTX
Microservice architecture design principles
PPTX
Introduction To Microservices
PPTX
MuleSoft Architecture Presentation
PDF
Decompose your monolith: strategies for migrating to microservices (Tide)
PPTX
Operational intelligence
PDF
Microservices vs monolithic
PDF
Multi-Cloud Strategy for Unrestricted Possibilities
PPTX
Plat4mation - Your ServiceNow Partner
PDF
MuleSoft Anypoint Platform and Three Tier Architecture
PPTX
Benefits of integration with the Mulesoft Anypoint Platform
PDF
DDD SoCal: Decompose your monolith: Ten principles for refactoring a monolith...
PPTX
Cloud Migration Strategy Framework
PPTX
Microservices
PDF
Saturn 2018: Managing data consistency in a microservice architecture using S...
Escaping Dependency Hell: A deep dive into Gradle's dependency management fea...
Introduction to microservices
App Modernization
What’s new in OpenText Extended ECM Platform CE 21.1 and OpenText Content Sui...
MicroService Architecture
Microservice Architecture
Microservice architecture design principles
Introduction To Microservices
MuleSoft Architecture Presentation
Decompose your monolith: strategies for migrating to microservices (Tide)
Operational intelligence
Microservices vs monolithic
Multi-Cloud Strategy for Unrestricted Possibilities
Plat4mation - Your ServiceNow Partner
MuleSoft Anypoint Platform and Three Tier Architecture
Benefits of integration with the Mulesoft Anypoint Platform
DDD SoCal: Decompose your monolith: Ten principles for refactoring a monolith...
Cloud Migration Strategy Framework
Microservices
Saturn 2018: Managing data consistency in a microservice architecture using S...
Ad

Similar to Oracle CodeOne 2019: Decompose Your Monolith: Strategies for Migrating to Microservices (20)

PDF
#DevNexus202 Decompose your monolith
PDF
Decompose your monolith: Six principles for refactoring a monolith to microse...
PDF
Microservices + Events + Docker = A Perfect Trio by Docker Captain Chris Rich...
PDF
Microservices: Decomposing Applications for Deployability and Scalability (ja...
PDF
Microservices + Events + Docker = A Perfect Trio (dockercon)
PDF
Dark Energy, Dark Matter and the Microservices Patterns?!
PDF
Kong Summit 2018 - Microservices: decomposing applications for testability an...
PDF
Omnikron webbinar - Microservices: enabling the rapid, frequent, and reliable...
PDF
Saturn2017: No such thing as a microservice!
PDF
SVCC Microservices: Decomposing Applications for Testability and Deployability
PDF
Using patterns and pattern languages to make better architectural decisions
PDF
Introduction to MicroServices (Oakjug)
PDF
Decomposing applications for deployability and scalability(SpringSource webinar)
PDF
#JaxLondon keynote: Developing applications with a microservice architecture
PDF
Developing Applications with a Micro Service Architecture - Chris Richardson
PDF
YOW London - Considering Migrating a Monolith to Microservices? A Dark Energy...
PDF
Developing applications with a microservice architecture (svcc)
PDF
Developing applications with a microservice architecture (SVforum, microservi...
PPSX
Microservices Architecture, Monolith Migration Patterns
PDF
Microservices - an architecture that enables DevOps (T Systems DevOps day)
#DevNexus202 Decompose your monolith
Decompose your monolith: Six principles for refactoring a monolith to microse...
Microservices + Events + Docker = A Perfect Trio by Docker Captain Chris Rich...
Microservices: Decomposing Applications for Deployability and Scalability (ja...
Microservices + Events + Docker = A Perfect Trio (dockercon)
Dark Energy, Dark Matter and the Microservices Patterns?!
Kong Summit 2018 - Microservices: decomposing applications for testability an...
Omnikron webbinar - Microservices: enabling the rapid, frequent, and reliable...
Saturn2017: No such thing as a microservice!
SVCC Microservices: Decomposing Applications for Testability and Deployability
Using patterns and pattern languages to make better architectural decisions
Introduction to MicroServices (Oakjug)
Decomposing applications for deployability and scalability(SpringSource webinar)
#JaxLondon keynote: Developing applications with a microservice architecture
Developing Applications with a Micro Service Architecture - Chris Richardson
YOW London - Considering Migrating a Monolith to Microservices? A Dark Energy...
Developing applications with a microservice architecture (svcc)
Developing applications with a microservice architecture (SVforum, microservi...
Microservices Architecture, Monolith Migration Patterns
Microservices - an architecture that enables DevOps (T Systems DevOps day)
Ad

More from Chris Richardson (20)

PDF
The microservice architecture: what, why, when and how?
PDF
More the merrier: a microservices anti-pattern
PDF
Dark energy, dark matter and microservice architecture collaboration patterns
PDF
Scenarios_and_Architecture_SkillsMatter_April_2022.pdf
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
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
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
JFokus: Cubes, Hexagons, Triangles, and More: Understanding Microservices
PDF
Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...
PDF
YOW! Perth: Cubes, Hexagons, Triangles, and More: Understanding the Microserv...
PDF
MicroCPH - Managing data consistency in a microservice architecture using Sagas
PDF
GotoChgo 2019: Not Just Events: Developing Asynchronous Microservices
PDF
Melbourne Jan 2019 - Microservices adoption anti-patterns: Obstacles to decom...
PDF
YOW2018 - Events and Commands: Developing Asynchronous Microservices
PDF
Mucon: Not Just Events: Developing Asynchronous Microservices
The microservice architecture: what, why, when and how?
More the merrier: a microservices anti-pattern
Dark energy, dark matter and microservice architecture collaboration patterns
Scenarios_and_Architecture_SkillsMatter_April_2022.pdf
iSAQB gathering 2021 keynote - Architectural patterns for rapid, reliable, fr...
Events to the rescue: solving distributed data problems in a microservice arc...
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
TDC2020 - The microservice architecture: enabling rapid, reliable, frequent a...
Overview of the Eventuate Tram Customers and Orders application
An overview of the Eventuate Platform
JFokus: Cubes, Hexagons, Triangles, and More: Understanding Microservices
Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...
YOW! Perth: Cubes, Hexagons, Triangles, and More: Understanding the Microserv...
MicroCPH - Managing data consistency in a microservice architecture using Sagas
GotoChgo 2019: Not Just Events: Developing Asynchronous Microservices
Melbourne Jan 2019 - Microservices adoption anti-patterns: Obstacles to decom...
YOW2018 - Events and Commands: Developing Asynchronous Microservices
Mucon: Not Just Events: Developing Asynchronous Microservices

Recently uploaded (20)

PDF
Nekopoi APK 2025 free lastest update
PPTX
Online Work Permit System for Fast Permit Processing
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
ai tools demonstartion for schools and inter college
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
L1 - Introduction to python Backend.pptx
PPTX
history of c programming in notes for students .pptx
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
System and Network Administraation Chapter 3
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Digital Strategies for Manufacturing Companies
Nekopoi APK 2025 free lastest update
Online Work Permit System for Fast Permit Processing
VVF-Customer-Presentation2025-Ver1.9.pptx
ManageIQ - Sprint 268 Review - Slide Deck
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
ai tools demonstartion for schools and inter college
Design an Analysis of Algorithms II-SECS-1021-03
How Creative Agencies Leverage Project Management Software.pdf
PTS Company Brochure 2025 (1).pdf.......
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
CHAPTER 2 - PM Management and IT Context
How to Migrate SBCGlobal Email to Yahoo Easily
Odoo POS Development Services by CandidRoot Solutions
L1 - Introduction to python Backend.pptx
history of c programming in notes for students .pptx
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Internet Downloader Manager (IDM) Crack 6.42 Build 41
System and Network Administraation Chapter 3
Operating system designcfffgfgggggggvggggggggg
Digital Strategies for Manufacturing Companies

Oracle CodeOne 2019: Decompose Your Monolith: Strategies for Migrating to Microservices