SlideShare a Scribd company logo
1 of 73
Download to read offline
http://acloudfan.com/
Pragmatic Paths Inc © 2021
Contact: raj@acloudfan.com
Discount Link to course:
https://www.udemy.com/course/domain-driven-design-and-microservices/?referralCode=C5DCD3C4CC0F0298EC1A
Section: Microservices Data Patterns
Course: Domain Driven Design & Microservices for Architects
www.ACloudFan.com
Microservices Data Patterns
Domain Driven Design
Databases are an essential part of ALL applications.
B
A
C
Microservices Data Patterns
Monolithic app to Microservices
B
A
C
Microservices Data Patterns
Breaking the Database is a CHALLENGE
Microservices Data Patterns
Data Patterns
• Used for designing the new Microservices
• Conversion of Monolithic apps to Microservices
Microservices Data Patterns
1 Shared Database Pattern
2 Separate Database Pattern
3 Strangler Pattern
4 Converting monolith to microservices
5 Options for breaking shared DB into multiple DB instances
Section objective
Data storage in legacy applications
*
Persistence in Shared Databases
1 Shared Database pattern
2 Pros of shared database
3 Cons of shared database
Data Storage
Persistence for application data
• Managed in raw files
• Databases
Relational DBs commonly used in legacy apps for all types of data !!
Use of RDBMS in Legacy Apps
Shared Database(s) for multiple applications
Enterprise
Applications
Shared Database
SQL Statements
SQL Statements
SQL Statements
Shared Database - Good things
2 Cost savings on Database (licensing, servers …)
3 Centralized database administration
1 Simplified data management
Challenges with Shared Database
1 DB Changes need to be managed carefully
All application owners will need to assess the impact on their App !!!
• High Cost
• High Risk
• Longer time to value
Application A needs a change in Schema
Challenges with Shared Database
2 One application may negatively impact all applications
One App can use too much resource and impact all other Apps !!
A
B
C
OLAP
E.g., Large Batch Job
• Impact on other applications
Uses up connections | resources on Database
A
B
C
Challenges with Shared Database
3 Single Point of Failure
All Applications dependent on the DB will be unavailable !!!
• Complex HA solutions à High cost
A failure here means all applications down
Challenges with Shared Database
4 Capacity planning for the Database
ALL teams MUST provide estimates on their usage !!!
CPU | Memory | Storage
OVER Capacity is Common !!!
A
B
C
Challenges with Shared Database
6 Same Database types for all applications
Application teams does not have a choice of DB type !!!
Monolithic applications
Shared Database(s) is an anti-pattern BUT
• Many enterprises are still dealing with such applications
• Service Oriented Architecture | API for rescue
S
O
A
Quick Review
Shared Database(s) is an anti-pattern BUT
• Many enterprises are still dealing with such applications
• Service Oriented Architecture (SOA) | API for rescue
S
O
A
Insulated applications from underlying database(s)
*
Service Oriented Architecture (SOA)
1 Introduction to SOA
2 SOA & Shared Database pattern
www.ACloudFan.com
Service Oriented Architecture
Data exposed by way of CRUD services | API
CREATE
RETRIEVE
UPDATE
DELETE
Hides the Database structure behind services !!!
SOA Layer placed between Apps & DB
Shared Database
SQL Statements
SQL Statements
SQL Statements
A
B
C
www.ACloudFan.com
SOA Layer placed between Apps & DB
Shared Database
SOA
Services
Layer
Services provided CRUD and Higher-level business operations
Svc
Svc
Svc
A
B
C
HTTP/MQ XML/JSON SOAP/REST
SOA addressed some Challenges
1 Hides the structure of DB i.e., no more SQL statements
2 Services were designed to be re-usable
Doesn't address *many* of the shared DB challenges !!
3 Changes to DB become manageable
Misconception
A small SOA Service is a Microservice
Misconception
A small SOA Service is a Microservice
NOT a Microservice
Quick Review
SOA services insulated the application from Database changes
• BUT did not address other challenges of Shared Database(s)
www.ACloudFan.com
Recommended for Greenfield Microservices Initiative
*
Separate Database Pattern
1 Greenfield versus Brownfield
2 Separate Database Pattern
3 Advantages of separate DB
Microservices Projects
Brownfield
Existing monolithic app to be converted to Microservices architecture
Greenfield
New application with no constraints from technical debt perspective
Microservices : Recommendation
Brownfield
"Separate DB" recommended for Microservices
Is it even possible to break the existing DB?
Is it worth the effort i.e., do a Cost-Benefit Analysis?
What will be the Business benefits?
www.ACloudFan.com
Microservices : Recommendation
Greenfield
"Separate DB" recommended for Microservices
Are the teams skilled for managing their own DB?
Does the organization have tools to manage multiple database?
Are the teams ready to manage design complexities?
www.ACloudFan.com
Microservices from ground up
Greenfield
Microservices teams assigned the Bounded Context
DDD Exercise
Microservices from ground up
Each microservice has its own Database !!!
Greenfield
A
B
• No interdependency between teams
• Each team decide on their tech stack
• Service interactions via defined interfaces
• No direct access to data
Under Maintenance
NO Direct Impact
Benefits : Separate Database Pattern
A
B
C
Simpler change management
Separate Database Pattern
Each microservice team owns & manages their database
A
B
C
Benefits : Separate Database Pattern
Reduced blast radius on Database Failure
NO direct impact on B & C
A
Benefits : Separate Database Pattern
Capacity planning | Scaling at DB level becomes simpler
• No new capacity for next year
• Additional 5 TB for storage
• 1 TB Storage • CPU +2 cores
Benefits : Separate Database Pattern
Each team can decide on Database i.e., doesn't have to RDBMS
• RDMBS
• NoSQL
• RDBMS
Quick Review
Separate Database Pattern is recommended
Greenfield
Converting a Monolith to Microservices
*
Brownfield & Databases
1 Converting Brownfield to Microservices
2 Shared Database = Anti pattern
3 Strangler pattern
Shared
Database
Conversion to Microservices
Brownfield
A monolith is refactored to multiple microservices
2 Database Refactoring
1 Apply Separate DB Pattern
3 Logical separation of database
Conversion to Microservices
Brownfield
A monolith is refactored to multiple microservices
1 Apply Separate DB Pattern
Using the Strangler Pattern
www.ACloudFan.com
Conversion to Microservices
Brownfield
A monolith is refactored to multiple microservices
System of records in RDBMS
• Hundreds of tables • Complex relationships
• Stored Procedures | Triggers
A
B
C
Microservices will suffer from the same challenges as applications !!!
Conversion to Microservices
Brownfield
ONLY application refactored; DB stays in place
Shared Database Pattern
It is an Anti-Pattern as it leads to inter-dependencies
A B C
DB Administration Team
• Slow speed to value
• Increased testing effort
• Higher need for coordination
• No independent scaling
Shared DB : Transition State Architecture
Positioning the application for Microservices architecture
Transition
State
Target
State
• Focus on Application
• Focus on Data
Shared DB : Transition State Architecture
Keep the Microservices code independent of the Database
A
B
C
Use of SQL in code will make it difficult to switch the DB !!!
SQL Statement
Strangler Strategy
Access the data via services/API in the transition stage
A
B
C
Svc
Svc
Svc
Svc
Svc
Svc
Svc
Svc
Svc
Switching the DB will not affect the Microservice
Strangler services | Stranglers
Strangler Strategy
Access the data via services/API in the transition stage
A
B
C
Svc
Svc
Svc
Svc
Svc
Svc
Svc
Svc
Svc
Teams decide their priorities and work independently (almost)
Strangler Strategy
Access the data via services/API in the transition stage
A
B
C
Svc
Svc
Svc
Svc
Svc
Svc
Svc
Svc
Svc
Eventually the target state is achieved !!!
Strangler Pattern
May be used for other legacy services as well
A
Svc
Svc
Svc
Legacy Services
Modernized Services
Strangler Pattern
Over a period, modernized service will replace the legacy service
A
Svc
Svc
Svc
Legacy Services
Modernized Services
Strangler Pattern
The strangler services will be changed to point to new services
A
Svc
Svc
Svc
Modernized Services
Microservice code insulated from backend changes !!!
Quick Review
Shared Database pattern = Anti pattern for Microservices
Strangler pattern used for replacing the backend | databases
Target
State
Converting Brownfield monolith to Microservices
*
Microservices : Shared DB Pattern
1 Objective & Challenges
2 Database Refactoring
Note: Discussion apply ONLY to an RDBMS
3 Logical Database Separation
Reality check
One may not have the flexibility of using "Separate DB"
• Time constraints • Cost | Budget constraints
For multiple reasons:
• Lack of skilled resources • Higher risk
• Legacy technology • …
Brownfield
Objective
Achieve isolation of data within the same Database instance
• Each Microservice owns part of the data in the Database
• Each Microservice have direct access to ONLY its own data
Use DB features to achieve MAXIMUM isolation between Microservices
Challenges with breaking the DB
A
B
C
Large Databases are NOT easy to separate L
Brownfield
Challenges with breaking the DB
Separation doesn't end with segregating the tables
• Shared data across Microservices
• Relationships between tables
• Stored Procedures
• Triggers
Brownfield
www.ACloudFan.com
Dealing with Shared Database
1 Database Refactoring
2 Logical separation of database
• Changes to underlying database
• Use the database as-is
A small change to the database which
improves its design without changing its
semantics
by Scott W & Pramod S
Database Refactoring
1
Structural Changes to definition of tables, views, and columns
Architectural Changes to methodology on how apps interact with DB
Referential
Integrity
Changes to the Primary Key, Foreign Keys, Triggers
There are 6 change categories suggested for DB Refactoring
Database Refactoring
1
Methods
Code changes to Stored Procedure like adding and
removing parameters
Transformations Changes to the database schema
Data Quality Changes for improvement to data quality
There are 6 categories of change suggested for DB Refactoring
Database Refactoring : Change Categories
1
Example : Structural Refactoring
Schema A
Schema B
Schema C
Separate schemas and put in access control for microservices
How is it done? Depends on the specific RDBMS !!!!
Tables owned by
Microservice A
Logical separation of the Database (RDBMS)
2
Divide the related tables among Microservices
Teams need to be disciplined; not to access other MS data directly
Tables owned by
Microservice B
Tables owned by
Microservice C
Using services for data access
All data access via services to minimize risk of direct access
• Governed services
• Provides control over only the assigned tables/data
Logically
separated DB
Table: A, B, C, D, E
Table: P, Q, R, S
Table: X, Y, Z
Quick Review
Microservices
Initiative?
Greenfield Brownfield
Separate DB Pattern
Break the DB
DB Refactoring
DB Design Changes
Evaluate
Time/Cost/Resource/Risk/
Complexity
Analyze DB
Technology, Complexity,
Data, Skills …
Logical Separation
NO DB Changes
But there are solutions !!!
*
Downside of Separate Databases
1 Challenges
2 Solution to challenges
3 Introduction to CQRS, Event Sourcing & SAGA patterns
Downside : Separate Database Pattern
1 HIGHER cost of the Database for the solution
$$$ spent on Databases may go up by up to 3 times !!
Licensing | Hardware
Operational | Maintenance
Downside : Separate Database Pattern
2 Degraded Read Performance due to distribution of data
A
API
API
B
C
In a Shared DB - we could have used a JOIN !!!
GET data from A
GET data from B
Merge data from A & B
SQL Statement
SQL Statement
Addressing the challenge
Manage local copy of the data thru asynchronous replication
B
A
Data from B
(as a view)
CQRS & Event Sourcing patterns
<<Event Source>>
<<Event Consumer>>
SQL INSERT/UPDATE/DELETE
I Event
SQL INSERT/UPDATE/DELETE
API
Change Data for B
API
Query data for A& B
Local SQL Query
Downside : Separate Database Pattern
3 Complexity in managing Transaction | Data integrity
Shared DB - Could have used a local Transaction !!!
Customer
PAID + Received Email
but will not receive the
order L
Shipment
Orders
Thanks for
your order
!!!
Notifier
2. Ship the Order FAILED
1. Inform Customer SUCCESS
Addressing the challenge
Use a sequence of local transactions with distributed rollback
B
C
Local TX Local TX
A B
Addressing the challenge
Use a sequence of local transactions with distributed rollback
Rollback changes to DB
SAGA & Reliable messaging pattern
B
C
FAILED Local TX
A B
Quick Review
CQRS Pattern & Event Sourcing
Open Source, Cloud Native Databases
SAGA Pattern & Reliable messaging
www.ACloudFan.com

More Related Content

Similar to 9.Microservices+Data+Patterns (1).pdf

Alex Thissen (Xpirit) - Een verschuiving in architectuur: op weg naar microse...
Alex Thissen (Xpirit) - Een verschuiving in architectuur: op weg naar microse...Alex Thissen (Xpirit) - Een verschuiving in architectuur: op weg naar microse...
Alex Thissen (Xpirit) - Een verschuiving in architectuur: op weg naar microse...AFAS Software
 
Advanced database protocols
Advanced database protocolsAdvanced database protocols
Advanced database protocolsHitesh Mohapatra
 
Extending D365 with Azure
Extending D365 with AzureExtending D365 with Azure
Extending D365 with AzureNelson Johnson
 
Caching for Microservices Architectures: Session I
Caching for Microservices Architectures: Session ICaching for Microservices Architectures: Session I
Caching for Microservices Architectures: Session IVMware Tanzu
 
Brk3043 azure sql db intelligent cloud database for app developers - wash dc
Brk3043 azure sql db   intelligent cloud database for app developers - wash dcBrk3043 azure sql db   intelligent cloud database for app developers - wash dc
Brk3043 azure sql db intelligent cloud database for app developers - wash dcBob Ward
 
Webinar: An Enterprise Architect’s View of MongoDB
Webinar: An Enterprise Architect’s View of MongoDBWebinar: An Enterprise Architect’s View of MongoDB
Webinar: An Enterprise Architect’s View of MongoDBMongoDB
 
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!ScaleBase
 
Cloud-Native Data: What data questions to ask when building cloud-native apps
Cloud-Native Data: What data questions to ask when building cloud-native appsCloud-Native Data: What data questions to ask when building cloud-native apps
Cloud-Native Data: What data questions to ask when building cloud-native appsVMware Tanzu
 
Big data and polyglot solutions
Big data and polyglot solutionsBig data and polyglot solutions
Big data and polyglot solutionsKumaran Ramanujam
 
Build on AWS: Migrating and Platforming
Build on AWS: Migrating and PlatformingBuild on AWS: Migrating and Platforming
Build on AWS: Migrating and PlatformingAmazon Web Services
 
Building a highly scalable and available cloud application
Building a highly scalable and available cloud applicationBuilding a highly scalable and available cloud application
Building a highly scalable and available cloud applicationNoam Sheffer
 
Databus - LinkedIn's Change Data Capture Pipeline
Databus - LinkedIn's Change Data Capture PipelineDatabus - LinkedIn's Change Data Capture Pipeline
Databus - LinkedIn's Change Data Capture PipelineSunil Nagaraj
 
Geek Sync | Designing Data Intensive Cloud Native Applications
Geek Sync | Designing Data Intensive Cloud Native ApplicationsGeek Sync | Designing Data Intensive Cloud Native Applications
Geek Sync | Designing Data Intensive Cloud Native ApplicationsIDERA Software
 
Cloud Data Strategy event London
Cloud Data Strategy event LondonCloud Data Strategy event London
Cloud Data Strategy event LondonMongoDB
 
Build on AWS: Migrating And Platforming
Build on AWS: Migrating And PlatformingBuild on AWS: Migrating And Platforming
Build on AWS: Migrating And PlatformingAmazon Web Services
 
Pros & Cons of Microservices Architecture
Pros & Cons of Microservices ArchitecturePros & Cons of Microservices Architecture
Pros & Cons of Microservices ArchitectureAshwini Kuntamukkala
 
Pitfalls & Challenges Faced During a Microservices Architecture Implementation
Pitfalls & Challenges Faced During a Microservices Architecture ImplementationPitfalls & Challenges Faced During a Microservices Architecture Implementation
Pitfalls & Challenges Faced During a Microservices Architecture ImplementationCognizant
 
6 microservice architecture
6 microservice architecture6 microservice architecture
6 microservice architectureLen Bass
 
Eliminate Risk when Migrating from IMS to Db2
Eliminate Risk when Migrating from IMS to Db2Eliminate Risk when Migrating from IMS to Db2
Eliminate Risk when Migrating from IMS to Db2Precisely
 
Odbc and data access objects
Odbc and data access objectsOdbc and data access objects
Odbc and data access objectsSangeetha Sg
 

Similar to 9.Microservices+Data+Patterns (1).pdf (20)

Alex Thissen (Xpirit) - Een verschuiving in architectuur: op weg naar microse...
Alex Thissen (Xpirit) - Een verschuiving in architectuur: op weg naar microse...Alex Thissen (Xpirit) - Een verschuiving in architectuur: op weg naar microse...
Alex Thissen (Xpirit) - Een verschuiving in architectuur: op weg naar microse...
 
Advanced database protocols
Advanced database protocolsAdvanced database protocols
Advanced database protocols
 
Extending D365 with Azure
Extending D365 with AzureExtending D365 with Azure
Extending D365 with Azure
 
Caching for Microservices Architectures: Session I
Caching for Microservices Architectures: Session ICaching for Microservices Architectures: Session I
Caching for Microservices Architectures: Session I
 
Brk3043 azure sql db intelligent cloud database for app developers - wash dc
Brk3043 azure sql db   intelligent cloud database for app developers - wash dcBrk3043 azure sql db   intelligent cloud database for app developers - wash dc
Brk3043 azure sql db intelligent cloud database for app developers - wash dc
 
Webinar: An Enterprise Architect’s View of MongoDB
Webinar: An Enterprise Architect’s View of MongoDBWebinar: An Enterprise Architect’s View of MongoDB
Webinar: An Enterprise Architect’s View of MongoDB
 
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!
 
Cloud-Native Data: What data questions to ask when building cloud-native apps
Cloud-Native Data: What data questions to ask when building cloud-native appsCloud-Native Data: What data questions to ask when building cloud-native apps
Cloud-Native Data: What data questions to ask when building cloud-native apps
 
Big data and polyglot solutions
Big data and polyglot solutionsBig data and polyglot solutions
Big data and polyglot solutions
 
Build on AWS: Migrating and Platforming
Build on AWS: Migrating and PlatformingBuild on AWS: Migrating and Platforming
Build on AWS: Migrating and Platforming
 
Building a highly scalable and available cloud application
Building a highly scalable and available cloud applicationBuilding a highly scalable and available cloud application
Building a highly scalable and available cloud application
 
Databus - LinkedIn's Change Data Capture Pipeline
Databus - LinkedIn's Change Data Capture PipelineDatabus - LinkedIn's Change Data Capture Pipeline
Databus - LinkedIn's Change Data Capture Pipeline
 
Geek Sync | Designing Data Intensive Cloud Native Applications
Geek Sync | Designing Data Intensive Cloud Native ApplicationsGeek Sync | Designing Data Intensive Cloud Native Applications
Geek Sync | Designing Data Intensive Cloud Native Applications
 
Cloud Data Strategy event London
Cloud Data Strategy event LondonCloud Data Strategy event London
Cloud Data Strategy event London
 
Build on AWS: Migrating And Platforming
Build on AWS: Migrating And PlatformingBuild on AWS: Migrating And Platforming
Build on AWS: Migrating And Platforming
 
Pros & Cons of Microservices Architecture
Pros & Cons of Microservices ArchitecturePros & Cons of Microservices Architecture
Pros & Cons of Microservices Architecture
 
Pitfalls & Challenges Faced During a Microservices Architecture Implementation
Pitfalls & Challenges Faced During a Microservices Architecture ImplementationPitfalls & Challenges Faced During a Microservices Architecture Implementation
Pitfalls & Challenges Faced During a Microservices Architecture Implementation
 
6 microservice architecture
6 microservice architecture6 microservice architecture
6 microservice architecture
 
Eliminate Risk when Migrating from IMS to Db2
Eliminate Risk when Migrating from IMS to Db2Eliminate Risk when Migrating from IMS to Db2
Eliminate Risk when Migrating from IMS to Db2
 
Odbc and data access objects
Odbc and data access objectsOdbc and data access objects
Odbc and data access objects
 

Recently uploaded

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 

Recently uploaded (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 

9.Microservices+Data+Patterns (1).pdf

  • 1. http://acloudfan.com/ Pragmatic Paths Inc © 2021 Contact: raj@acloudfan.com Discount Link to course: https://www.udemy.com/course/domain-driven-design-and-microservices/?referralCode=C5DCD3C4CC0F0298EC1A Section: Microservices Data Patterns Course: Domain Driven Design & Microservices for Architects
  • 2. www.ACloudFan.com Microservices Data Patterns Domain Driven Design Databases are an essential part of ALL applications. B A C
  • 3. Microservices Data Patterns Monolithic app to Microservices B A C
  • 4. Microservices Data Patterns Breaking the Database is a CHALLENGE
  • 5. Microservices Data Patterns Data Patterns • Used for designing the new Microservices • Conversion of Monolithic apps to Microservices
  • 6. Microservices Data Patterns 1 Shared Database Pattern 2 Separate Database Pattern 3 Strangler Pattern 4 Converting monolith to microservices 5 Options for breaking shared DB into multiple DB instances Section objective
  • 7. Data storage in legacy applications * Persistence in Shared Databases 1 Shared Database pattern 2 Pros of shared database 3 Cons of shared database
  • 8. Data Storage Persistence for application data • Managed in raw files • Databases Relational DBs commonly used in legacy apps for all types of data !!
  • 9. Use of RDBMS in Legacy Apps Shared Database(s) for multiple applications Enterprise Applications Shared Database SQL Statements SQL Statements SQL Statements
  • 10. Shared Database - Good things 2 Cost savings on Database (licensing, servers …) 3 Centralized database administration 1 Simplified data management
  • 11. Challenges with Shared Database 1 DB Changes need to be managed carefully All application owners will need to assess the impact on their App !!! • High Cost • High Risk • Longer time to value Application A needs a change in Schema
  • 12. Challenges with Shared Database 2 One application may negatively impact all applications One App can use too much resource and impact all other Apps !! A B C OLAP E.g., Large Batch Job • Impact on other applications Uses up connections | resources on Database
  • 13. A B C Challenges with Shared Database 3 Single Point of Failure All Applications dependent on the DB will be unavailable !!! • Complex HA solutions à High cost A failure here means all applications down
  • 14. Challenges with Shared Database 4 Capacity planning for the Database ALL teams MUST provide estimates on their usage !!! CPU | Memory | Storage OVER Capacity is Common !!! A B C
  • 15. Challenges with Shared Database 6 Same Database types for all applications Application teams does not have a choice of DB type !!!
  • 16. Monolithic applications Shared Database(s) is an anti-pattern BUT • Many enterprises are still dealing with such applications • Service Oriented Architecture | API for rescue S O A
  • 17. Quick Review Shared Database(s) is an anti-pattern BUT • Many enterprises are still dealing with such applications • Service Oriented Architecture (SOA) | API for rescue S O A
  • 18. Insulated applications from underlying database(s) * Service Oriented Architecture (SOA) 1 Introduction to SOA 2 SOA & Shared Database pattern www.ACloudFan.com
  • 19. Service Oriented Architecture Data exposed by way of CRUD services | API CREATE RETRIEVE UPDATE DELETE Hides the Database structure behind services !!!
  • 20. SOA Layer placed between Apps & DB Shared Database SQL Statements SQL Statements SQL Statements A B C www.ACloudFan.com
  • 21. SOA Layer placed between Apps & DB Shared Database SOA Services Layer Services provided CRUD and Higher-level business operations Svc Svc Svc A B C HTTP/MQ XML/JSON SOAP/REST
  • 22. SOA addressed some Challenges 1 Hides the structure of DB i.e., no more SQL statements 2 Services were designed to be re-usable Doesn't address *many* of the shared DB challenges !! 3 Changes to DB become manageable
  • 23. Misconception A small SOA Service is a Microservice
  • 24. Misconception A small SOA Service is a Microservice NOT a Microservice
  • 25. Quick Review SOA services insulated the application from Database changes • BUT did not address other challenges of Shared Database(s) www.ACloudFan.com
  • 26. Recommended for Greenfield Microservices Initiative * Separate Database Pattern 1 Greenfield versus Brownfield 2 Separate Database Pattern 3 Advantages of separate DB
  • 27. Microservices Projects Brownfield Existing monolithic app to be converted to Microservices architecture Greenfield New application with no constraints from technical debt perspective
  • 28. Microservices : Recommendation Brownfield "Separate DB" recommended for Microservices Is it even possible to break the existing DB? Is it worth the effort i.e., do a Cost-Benefit Analysis? What will be the Business benefits? www.ACloudFan.com
  • 29. Microservices : Recommendation Greenfield "Separate DB" recommended for Microservices Are the teams skilled for managing their own DB? Does the organization have tools to manage multiple database? Are the teams ready to manage design complexities? www.ACloudFan.com
  • 30. Microservices from ground up Greenfield Microservices teams assigned the Bounded Context DDD Exercise
  • 31. Microservices from ground up Each microservice has its own Database !!! Greenfield A B • No interdependency between teams • Each team decide on their tech stack • Service interactions via defined interfaces • No direct access to data
  • 32. Under Maintenance NO Direct Impact Benefits : Separate Database Pattern A B C Simpler change management
  • 33. Separate Database Pattern Each microservice team owns & manages their database A B C
  • 34. Benefits : Separate Database Pattern Reduced blast radius on Database Failure NO direct impact on B & C A
  • 35. Benefits : Separate Database Pattern Capacity planning | Scaling at DB level becomes simpler • No new capacity for next year • Additional 5 TB for storage • 1 TB Storage • CPU +2 cores
  • 36. Benefits : Separate Database Pattern Each team can decide on Database i.e., doesn't have to RDBMS • RDMBS • NoSQL • RDBMS
  • 37. Quick Review Separate Database Pattern is recommended Greenfield
  • 38. Converting a Monolith to Microservices * Brownfield & Databases 1 Converting Brownfield to Microservices 2 Shared Database = Anti pattern 3 Strangler pattern
  • 39. Shared Database Conversion to Microservices Brownfield A monolith is refactored to multiple microservices 2 Database Refactoring 1 Apply Separate DB Pattern 3 Logical separation of database
  • 40. Conversion to Microservices Brownfield A monolith is refactored to multiple microservices 1 Apply Separate DB Pattern Using the Strangler Pattern www.ACloudFan.com
  • 41. Conversion to Microservices Brownfield A monolith is refactored to multiple microservices System of records in RDBMS • Hundreds of tables • Complex relationships • Stored Procedures | Triggers
  • 42. A B C Microservices will suffer from the same challenges as applications !!! Conversion to Microservices Brownfield ONLY application refactored; DB stays in place
  • 43. Shared Database Pattern It is an Anti-Pattern as it leads to inter-dependencies A B C DB Administration Team • Slow speed to value • Increased testing effort • Higher need for coordination • No independent scaling
  • 44. Shared DB : Transition State Architecture Positioning the application for Microservices architecture Transition State Target State • Focus on Application • Focus on Data
  • 45. Shared DB : Transition State Architecture Keep the Microservices code independent of the Database A B C Use of SQL in code will make it difficult to switch the DB !!! SQL Statement
  • 46. Strangler Strategy Access the data via services/API in the transition stage A B C Svc Svc Svc Svc Svc Svc Svc Svc Svc Switching the DB will not affect the Microservice Strangler services | Stranglers
  • 47. Strangler Strategy Access the data via services/API in the transition stage A B C Svc Svc Svc Svc Svc Svc Svc Svc Svc Teams decide their priorities and work independently (almost)
  • 48. Strangler Strategy Access the data via services/API in the transition stage A B C Svc Svc Svc Svc Svc Svc Svc Svc Svc Eventually the target state is achieved !!!
  • 49. Strangler Pattern May be used for other legacy services as well A Svc Svc Svc Legacy Services Modernized Services
  • 50. Strangler Pattern Over a period, modernized service will replace the legacy service A Svc Svc Svc Legacy Services Modernized Services
  • 51. Strangler Pattern The strangler services will be changed to point to new services A Svc Svc Svc Modernized Services Microservice code insulated from backend changes !!!
  • 52. Quick Review Shared Database pattern = Anti pattern for Microservices Strangler pattern used for replacing the backend | databases Target State
  • 53. Converting Brownfield monolith to Microservices * Microservices : Shared DB Pattern 1 Objective & Challenges 2 Database Refactoring Note: Discussion apply ONLY to an RDBMS 3 Logical Database Separation
  • 54. Reality check One may not have the flexibility of using "Separate DB" • Time constraints • Cost | Budget constraints For multiple reasons: • Lack of skilled resources • Higher risk • Legacy technology • … Brownfield
  • 55. Objective Achieve isolation of data within the same Database instance • Each Microservice owns part of the data in the Database • Each Microservice have direct access to ONLY its own data Use DB features to achieve MAXIMUM isolation between Microservices
  • 56. Challenges with breaking the DB A B C Large Databases are NOT easy to separate L Brownfield
  • 57. Challenges with breaking the DB Separation doesn't end with segregating the tables • Shared data across Microservices • Relationships between tables • Stored Procedures • Triggers Brownfield www.ACloudFan.com
  • 58. Dealing with Shared Database 1 Database Refactoring 2 Logical separation of database • Changes to underlying database • Use the database as-is
  • 59. A small change to the database which improves its design without changing its semantics by Scott W & Pramod S Database Refactoring 1
  • 60. Structural Changes to definition of tables, views, and columns Architectural Changes to methodology on how apps interact with DB Referential Integrity Changes to the Primary Key, Foreign Keys, Triggers There are 6 change categories suggested for DB Refactoring Database Refactoring 1
  • 61. Methods Code changes to Stored Procedure like adding and removing parameters Transformations Changes to the database schema Data Quality Changes for improvement to data quality There are 6 categories of change suggested for DB Refactoring Database Refactoring : Change Categories 1
  • 62. Example : Structural Refactoring Schema A Schema B Schema C Separate schemas and put in access control for microservices How is it done? Depends on the specific RDBMS !!!!
  • 63. Tables owned by Microservice A Logical separation of the Database (RDBMS) 2 Divide the related tables among Microservices Teams need to be disciplined; not to access other MS data directly Tables owned by Microservice B Tables owned by Microservice C
  • 64. Using services for data access All data access via services to minimize risk of direct access • Governed services • Provides control over only the assigned tables/data Logically separated DB Table: A, B, C, D, E Table: P, Q, R, S Table: X, Y, Z
  • 65. Quick Review Microservices Initiative? Greenfield Brownfield Separate DB Pattern Break the DB DB Refactoring DB Design Changes Evaluate Time/Cost/Resource/Risk/ Complexity Analyze DB Technology, Complexity, Data, Skills … Logical Separation NO DB Changes
  • 66. But there are solutions !!! * Downside of Separate Databases 1 Challenges 2 Solution to challenges 3 Introduction to CQRS, Event Sourcing & SAGA patterns
  • 67. Downside : Separate Database Pattern 1 HIGHER cost of the Database for the solution $$$ spent on Databases may go up by up to 3 times !! Licensing | Hardware Operational | Maintenance
  • 68. Downside : Separate Database Pattern 2 Degraded Read Performance due to distribution of data A API API B C In a Shared DB - we could have used a JOIN !!! GET data from A GET data from B Merge data from A & B SQL Statement SQL Statement
  • 69. Addressing the challenge Manage local copy of the data thru asynchronous replication B A Data from B (as a view) CQRS & Event Sourcing patterns <<Event Source>> <<Event Consumer>> SQL INSERT/UPDATE/DELETE I Event SQL INSERT/UPDATE/DELETE API Change Data for B API Query data for A& B Local SQL Query
  • 70. Downside : Separate Database Pattern 3 Complexity in managing Transaction | Data integrity Shared DB - Could have used a local Transaction !!! Customer PAID + Received Email but will not receive the order L Shipment Orders Thanks for your order !!! Notifier 2. Ship the Order FAILED 1. Inform Customer SUCCESS
  • 71. Addressing the challenge Use a sequence of local transactions with distributed rollback B C Local TX Local TX A B
  • 72. Addressing the challenge Use a sequence of local transactions with distributed rollback Rollback changes to DB SAGA & Reliable messaging pattern B C FAILED Local TX A B
  • 73. Quick Review CQRS Pattern & Event Sourcing Open Source, Cloud Native Databases SAGA Pattern & Reliable messaging www.ACloudFan.com