microservices bounded contexts and everything in … · 2020. 7. 13. · microservices bounded...
TRANSCRIPT
vladikk doit-intl.com#OReillySACon
MICROSERVICES BOUNDED CONTEXTS AND EVERYTHING IN BETWEEN
vladikk doit-intl.com#OReillySACon
”95% of the words are spent extolling the benefits of “modularity” and that little, if anything, is said
about how to achieve it”Glenford J. Myers
vladikk doit-intl.com#OReillySACon
vladikk doit-intl.com#OReillySACon
“MICROSERVICES FTW!!!!!!!!1”
Me @ Internovus
vladikk doit-intl.com#OReillySACon
“MICROSERVICES FTW!!!!!!!!1”
Me @ Internovus💩
vladikk doit-intl.com#OReillySACon
”95% of the words are spent extolling the benefits of “modularity” and that little, if anything, is said
about how to achieve it”Glenford J. Myers
vladikk doit-intl.com#OReillySACon
vladikk doit-intl.com#OReillySACon
vladikk doit-intl.com#OReillySACon
Decomposi)on Strategies
Microservices
Design Heuris)cs
vladikk doit-intl.com#OReillySACon
INTERNOVUS
01
BUSINESS DOMAIN
vladikk doit-intl.com#OReillySACon
Your Product Marketing Strategy
Creatives Campaigns Sales Agents
OptimizationProfits
vladikk doit-intl.com#OReillySACon
DECOMPOSITION
02
STRATEGIES
vladikk doit-intl.com#OReillySACon
Bounded Contexts
vladikk doit-intl.com#OReillySACon
vladikk doit-intl.com#OReillySACon
Domain ExpertSoftware Developer
vladikk doit-intl.com#OReillySACon
Business Domain ExpertSoftware Developer
??? !!!
Ubiquitous Language
vladikk doit-intl.com#OReillySACon
Campaigns Sales Agents
Your Product Marketing Strategy
Creatives
OptimizationProfits
vladikk doit-intl.com#OReillySACon
Sales AgentCampaign Manager
??? !!!
LEAD?
vladikk doit-intl.com#OReillySACon
Conflicting models
Different contexts
Dividing the language/model
Bounded Context
vladikk doit-intl.com#OReillySACon
MarkeCngSales
Lead Lead
FunnelCampaign
Placement Landing PageAgency Insertion Order Message
Campaign
PropositionDesk
Conversion
ContactCDR
Bounded Contexts
vladikk doit-intl.com#OReillySACon
MarkeCng Service
Sales Service
DecomposiCon Strategy #1: Bounded Contexts
vladikk doit-intl.com#OReillySACon
MarkeCngSales
CommissionsDesks
Sales Optimization
CRMTelephony
Creative Catalog
Contracts
Billing
Campaign Management
Identity & Access
Ads OptimizationIdentity & Access
vladikk doit-intl.com#OReillySACon
Business (Sub)Domains
vladikk doit-intl.com#OReillySACon
Business Domain: Customer Acquisi)onBounded Context: Marke)ng Bounded Context: Sales
Subdomain: Crea)ve Catalog
Subdomain: Campaigns Mngmt
Subdomain: Ads Op)miza)on
Subdomain: Contracts Mngmt
Subdomain: CRM
Subdomain: Sales Op)miza)on
Subdomain: Commissions
Subdomain: Desks Mngmt
vladikk doit-intl.com#OReillySACon
DecomposiCon Strategy #2: Subomains
Campaign Management
Service
Content Catalog Service
Desks Management
Service
CRM Service
Users Service
Billing Service
vladikk doit-intl.com#OReillySACon
Business EnCCes and Processes
vladikk doit-intl.com#OReillySACon
MarkeCngCreative Catalog
Contracts
Billing
Campaign Management
Identity & Access
Optimization
Campaign Management
Campaign Placement
FunnelBanner
Landing Page
WebsiteZone
Asset
Publisher
Target Market
vladikk doit-intl.com#OReillySACon
DecomposiCon Strategy #3: EnCCes
Website Asset Target Market
Broker Distribu)on Customer
vladikk doit-intl.com#OReillySACon
DecomposiCon Strategies
Bounded Contexts
Subdomains
Business Entities and Processes
vladikk doit-intl.com#OReillySACon
SHOW ME THE MICROSERVICES!
vladikk doit-intl.com#OReillySACon
MarkeCngCreative Catalog
Contracts
Billing
Campaign Management
Identity & Access
Optimization
Campaign Management
Campaign Placement
FunnelBanner
Landing Page
WebsiteZone
Asset
Publisher
Target Market
Campaign
Website
Placement
Funnel
Bounded Contexts? Subdomains? EnCCes?
vladikk doit-intl.com#OReillySACon
Bounded Contexts == Microservices ?
vladikk doit-intl.com#OReillySACon
Sales AgentCampaign Manager
??? !!!
LEAD?
vladikk doit-intl.com#OReillySACon
MarkeCngSales
Lead Lead
FunnelCampaign
Placement Landing PageAgency Insertion Order Message
Campaign
PropositionDesk
Conversion
ContactCDR
vladikk doit-intl.com#OReillySACon
MarkeCngSales
Lead Lead
FunnelCampaign
Placement Landing PageAgency Insertion Order Message
Campaign
PropositionDesk
Conversion
ContactCDR
vladikk doit-intl.com#OReillySACon
MarkeCngSales
CommissionsDesks
Optimization
CRMTelephony
Creative Catalog
Contracts
BillingCampaign
Management
Identity & Access
OptimizationIdentity & Access
Lead
Lead
vladikk doit-intl.com#OReillySACon
MarkeCngCreative Catalog
Campaign Management
OptimizationLead
Sales
Commissions
Optimization
CRM Lead
Desks
Telephony
SupportContracts
Billing
Identity & Access
vladikk doit-intl.com#OReillySACon
Bounded Contexts Decomposi)on #1
Bounded Contexts Decomposi)on #2
Bounded Contexts Decomposi)on #3
vladikk doit-intl.com#OReillySACon
Bounded Context
Consistency boundary of the language / model
Define the biggest valid monoliths
Required decomposition boundary
vladikk doit-intl.com#OReillySACon
Bounded Contexts == Microservices? No
vladikk doit-intl.com#OReillySACon
Campaign Management
Campaign Placement
FunnelBanner
Landing Page
WebsiteZone
Asset
Publisher
Target Market
Campaign
Website
Placement
Funnel
MarkeCngCreative Catalog
Contracts
Billing
Campaign Management
Identity & Access
Optimization
Bounded Contexts? No Subdomains? EnCCes?
vladikk doit-intl.com#OReillySACon
MICROSERVICES
03
vladikk doit-intl.com#OReillySACon
“A service is a unit of functionality exposed to the world” - Juval Lowy
“A mechanism to enable access to one or more capabilities, where the access is provided using a prescribed interface” - OASIS
Service
vladikk doit-intl.com#OReillySACon
Service Interface
“Any mechanism for getting data in or out of the service”
- Randy Shoup
vladikk doit-intl.com#OReillySACon
Service Interface
Asynchronous:
• Producing events
• Consuming events
Synchronous:
• Request / Response
• Bulk ETL
vladikk doit-intl.com#OReillySACon
Service Interface
“Any mechanism for getting data in or out of the service”
- Randy Shoup
vladikk doit-intl.com#OReillySACon
Service Interface
vladikk doit-intl.com#OReillySACon
Services ➜ Microservice
vladikk doit-intl.com#OReillySACon
A microservice is a service with a micro interface
vladikk doit-intl.com#OReillySACon
Microservice = Microinterface
Reducing coupling between services
Limits reasons for change
Easier to understand
Better fault isolation
More autonomy between services
vladikk doit-intl.com#OReillySACon
Microservice & Databases
Microservices should own its database
No external access
Access through Microservice’s API only
Database = infinite interface!
vladikk doit-intl.com#OReillySACon
1 Method = Perfect Microservice !!??
vladikk doit-intl.com#OReillySACon
vladikk doit-intl.com#OReillySACon
vladikk doit-intl.com#OReillySACon
vladikk doit-intl.com#OReillySACon
vladikk doit-intl.com#OReillySACon
STAFF ONLY
STAFF ONLY
vladikk doit-intl.com#OReillySACon
The threshold upon which a system can be decomposed
into microservices is defined by the use cases of the
system that the microservices are a part of.
vladikk doit-intl.com#OReillySACon
Monolith Microservices Distributed Monolith
Cost of
Change
vladikk doit-intl.com#OReillySACon
Big Ball Of Mud Bounded Contexts
Microservices Distributed Big Ball Of Mud
Avg. Service
Size
vladikk doit-intl.com#OReillySACon
Campaign Management
Campaign Placement
FunnelBanner
Landing Page
WebsiteZone
Asset
Publisher
Target Market
Campaign
Website
Placement
Funnel
Subdomains? EnCCes?
vladikk doit-intl.com#OReillySACon
vladikk doit-intl.com#OReillySACon
”Global complexity … the complexity of the
overall structure of a program or system. I.e., the
degree of association or interdependence
among the major pieces of a program”Glenford J. Myers
vladikk doit-intl.com#OReillySACon
”Global complexity … the complexity of the
overall structure of a program or system. I.e., the
degree of association or interdependence
among the major pieces of a program”Glenford J. Myers
Composite / Structured Design, 1978
vladikk doit-intl.com#OReillySACon
When you design a system…, then if the features can be broken into … loosely bound groups of
rela>vely closely bound features, then that division is a good thing to be made a part of the
design. This is just good engineering.
Tim Berners-LeePrinciples of design, 1998
vladikk doit-intl.com#OReillySACon
Services + Good Engineering = Microservices
vladikk doit-intl.com#OReillySACon
Its is not only necessary to make sure your own system is designed to be made of modular parts.
It is also necessary to realize that your own system … should always be designed to be a part
of another larger system.
Tim Berners-LeePrinciples of design, 1998
vladikk doit-intl.com#OReillySACon
A major part of this paper will be concerned with the ques>on of how good modularity can be
achieved, that is, how modules can be chosen so as to minimize the connec5ons between them.
Barbara LiskovA design methodology for reliable soIware systems, 1972
vladikk doit-intl.com#OReillySACon
A microservice is a service with a micro interface.
The threshold upon which a system can be decomposed
into microservices is defined by the use cases of the
system that the microservices are a part of.
vladikk doit-intl.com#OReillySACon
A microservice is a service with a micro interface.
The threshold upon which the system can be decomposed
is defined by the use cases of the system that the
microservices are a part of.
…how to evaluate?
vladikk doit-intl.com#OReillySACon
DESIGN
04
HEURISTICS
vladikk doit-intl.com#OReillySACon
HeurisCc #1: Decompose to Bounded Contexts
Do not implement conflicting models in the same service. Always decompose to Bounded Contexts.
vladikk doit-intl.com#OReillySACon
HeurisCc #2: Don’t
First Law of Distributed Object Design: “Don’t distribute your objects”
MarCn Fowler
vladikk doit-intl.com#OReillySACon
HeurisCc #2: Don’t
Benefits Addi)onal Complexity
vladikk doit-intl.com#OReillySACon
MONOLITHSYSTEM DESIGN THAT UNDERMINES DELIVERY OF FUNCTIONAL OR NON-FUNCTIONAL REQUIREMENTS
vladikk doit-intl.com#OReillySACon
HeurisCc #2: Don’t
Benefits Addi)onal Complexity
vladikk doit-intl.com#OReillySACon
HeurisCc #2: Don’t
Benefits Addi)onal Complexity
vladikk doit-intl.com#OReillySACon
Core
Supporting
Generic
vladikk doit-intl.com#OReillySACon
Generic Subdomains
No competitive advantage
Everybody is implementing in the same way
Complex business logic
vladikk doit-intl.com#OReillySACon
MarkeCngSales
CommissionsDesks
Optimization
CRMTelephony
Creative Catalog
Contracts
Billing
Campaign Management
Identity & Access
OptimizationIdentity & Access
Generic
vladikk doit-intl.com#OReillySACon
MarkeCngSales
CommissionsDesks
Optimization
CRMTelephony
Creative Catalog
Contracts
Billing
Campaign Management
Identity & AccessOptimization Identity & Access
Generic
vladikk doit-intl.com#OReillySACon
MarkeCngSales
CommissionsDesks
Optimization
CRMTelephony
Creative Catalog
Contracts
Billing
Campaign Management
Identity & Access
OptimizationIdentity & Access
Generic
vladikk doit-intl.com#OReillySACon
MarkeCngSales
CommissionsDesks
Optimization
CRMTelephony
Creative Catalog
Contracts
BillingCampaign
Management
Identity & Access
OptimizationIdentity & Access
Generic
vladikk doit-intl.com#OReillySACon
MarkeCngSales
CommissionsDesks
Optimization
CRMTelephony
Creative Catalog
Contracts
Billing
Campaign Management
Identity & Access
OptimizationIdentity & Access
Generic
vladikk doit-intl.com#OReillySACon
HeurisCc #3: Buy/Adopt Generic Subdomains
Your System
3rd party product
vladikk doit-intl.com#OReillySACon
HeurisCc #3: Buy/Adopt Generic Subdomains
Your System
3rd party product
An)-
Corr
up)o
n La
yer
vladikk doit-intl.com#OReillySACon
Core SubdomainsInventing something new
Optimizing existing paractices
Competitive advantage
Complex business logic
Change often
vladikk doit-intl.com#OReillySACon
MarkeCngSales
CommissionsDesks
Sales Optimization
CRMTelephony
Creative Catalog
Contracts
Billing
Campaign Management
Identity & Access
Ad OptimizationIdentity & Access
Generic Core
vladikk doit-intl.com#OReillySACon
Core SubdomainsInventing something new
Optimizing existing paractices
Competitive advantage
Complex business logic
Change often
vladikk doit-intl.com#OReillySACon
HeurisCc #4: Core Subdomains - Don’t Rush
Adhere to subdomain’s boundaries. Decompose further only when you acquire domain knowledge.
vladikk doit-intl.com#OReillySACon
SupporCng Subdomains
No competitive advantage
Support the Core Subdomains
Can’t be bought / adopted
Simple business logic
vladikk doit-intl.com#OReillySACon
MarkeCngSales
CommissionsDesks
Sales Optimization
CRMTelephony
Creative Catalog
Contracts
Billing
Campaign Management
Identity & Access
Ad OptimizationIdentity & Access
Generic Core Supporting
vladikk doit-intl.com#OReillySACon
SupporCng Subdomains
No competitive advantage
Support the Core Subdomains
Can’t be bought / adopted
Simple business logic
vladikk doit-intl.com#OReillySACon
HeurisCc #5: SupporCng Subdomains - Safe
Safe to decompose beyond the subdomain’s boundaries.
vladikk doit-intl.com#OReillySACon
Core
Supporting
Generic
vladikk doit-intl.com#OReillySACon
HeurisCc #6: Evaluate Consistency Requirements
Method A Method B
vladikk doit-intl.com#OReillySACon
HeurisCc #6: Evaluate Consistency Requirements
Concurrency control? - Same service
Method A Method B
Service A
vladikk doit-intl.com#OReillySACon
HeurisCc #6: Evaluate Consistency Requirements
Read last write? - Two services, synchronous communication
Service A
Method A
Service B
Method B
Sync call
vladikk doit-intl.com#OReillySACon
HeurisCc #6: Evaluate Consistency Requirements
Eventual consistency? - Two services, asynchronous communication
Service A
Method A
Service B
Method B
Asynchronous Communication
vladikk doit-intl.com#OReillySACon
HeurisCc #6: Evaluate Consistency Requirements
Concurrency control? - Same service
Read last write? - Two services, sync communication
Eventual consistency? - Two services, async communication
vladikk doit-intl.com#OReillySACon
Service A
Method A
Service B
Method B
Asynchronous Communication
vladikk doit-intl.com#OReillySACon
HeurisCc #7: Public / Private Events
Service
Event Type 1
Event Type 2
Event Type 3
Event Type 4
Event Type 5
Event Type 6
Event Type 1000
…
vladikk doit-intl.com#OReillySACon
HeurisCc #7: Public / Private Events
Service
Event Type 1
Event Type 2
Event Type 3
Event Type 4
Event Type 5
Event Type 6Private event types (Implementation details)}Event Type 1000
…
vladikk doit-intl.com#OReillySACon
HeurisCc #7: Public / Private Events
Service
Event Type 1
Event Type 2
Event Type 3
Event Type 4
Event Type 5
Event Type 6
Event Type 1000
…
Private event types (Implementation details)}Public event types (Public interface)}
vladikk doit-intl.com#OReillySACon
Service
EmailChanged
PhoneNumberChanged
AddressChanged
HeurisCc #7: Public / Private Events
vladikk doit-intl.com#OReillySACon
Service
EmailChanged
PhoneNumberChanged
AddressChanged
ContactDetailsChanged
HeurisCc #7: Public / Private Events
vladikk doit-intl.com#OReillySACon
Service
EmailChanged
PhoneNumberChanged
AddressChanged
ContactDetailsChanged
Private event types (Implementation details)
} Public event type (Public interface)
}HeurisCc #7: Public / Private Events
vladikk doit-intl.com#OReillySACon
HeurisCc #7: Public / Private Events
Events?Domain Events
State Change Events
Private Public
vladikk doit-intl.com#OReillySACon
HeurisCc #8: Make Events Explicit
Eliminate ambiguity
vladikk doit-intl.com#OReillySACon
HeurisCc #8: Make Events Explicit
Service
AgentAssignedToLead
vladikk doit-intl.com#OReillySACon
HeurisCc #8: Make Events Explicit
Service
AgentAssignedToLead
AgentAssignedToLead
AgentAssignedToLead
vladikk doit-intl.com#OReillySACon
HeurisCc #8: Make Events Explicit
Service
AgentAssignedToLead
AgentUnassignedToLead
AgentAssignedToLead
vladikk doit-intl.com#OReillySACon
HeurisCc #9: Evaluate Reasons for Change
Service A Service B
vladikk doit-intl.com#OReillySACon
Same reasons for change?
Same rate of change?
Can be decoupled?
Should be the same service?
HeurisCc #9: Evaluate Reasons for Change
vladikk doit-intl.com#OReillySACon
vladikk doit-intl.com#OReillySACon
HeurisCc #10: Evaluate Services’ “Doors”
vladikk doit-intl.com#OReillySACon
HeurisCc #10: Evaluate Services’ “Doors”
STAFF ONLY
STAFF ONLY
vladikk doit-intl.com#OReillySACon
WRAP UP
05
vladikk doit-intl.com#OReillySACon
1. A service is a unit of func)onality exposed to the world through its public interface.
2. A microservice is a service with micro interface 3. The “micro-interface” is rela)ve to the use cases of
the system that the service is a part of
vladikk doit-intl.com#OReillySACon
Heuris)c #1: Always decompose to Bounded Contexts Heuris)c #2: Don’t go further, unless you have to Heuris)c #3: Buy/adopt generic subdomains Heuris)c #4: Core subdomains - don’t rush Heuris)c #5: Suppor)ng subdomains can be decomposed early
vladikk doit-intl.com#OReillySACon
Heuris)c #6: Evaluate Consistency Requirements Heuris)c #7: Private / Public Events Heuris)c #8: Explicitly Define Events Heuris)c #9: Evaluate Reasons for Change Heuris)c #10: Evaluate Services’ “Doors”
vladikk doit-intl.com#OReillySACon
Big Ball Of Mud Bounded Contexts
Microservices Distributed Big Ball Of Mud
Avg. Service
Size
vladikk doit-intl.com#OReillySACon
Bibliography1. A Design Methodology for Reliable Soeware Systems, Barbara Liskov 2. Designing Autonomous Teams and Services, Nick Tune & Scoh Millet 3. Composite/Structured Design, Glenford Myers 4. Domain-Driven Design: Tackling Complexity in the Heart of Soeware, Eric Evans 5. Emerging Boundaries, Mathias Veraes 6. Implemen)ng Domain-Driven Design, Vaughn Vernon 7. Enterprise Integra)on Paherns, Gregory Hohpe, at al 8. Long Sad Story of Microservices, Greg Young 9. Managing Data in Microservices, Randy Shoup 10. Microservices, At Last Some Boundaries, Eric Evans 11. On the Criteria to be Used in Decomposing Systems Into Modules, David Parnas 12. Paherns of Enterprise Applica)on Architecture, Mar)n Fowler, at al 13. Principles of Design, Tim Berners-Lee 14. Programming WCF Services, Juval Lowy 15. What Every Programmer Should Know About Object Oriented Design, Melir Page-Jones
https://bit.ly/2ptJ5fS
THANK [email protected]
https://bit.ly/31nSD9c
http://careers.doit-intl.com
http://explore-ddd.com
vladikk doit-intl.com#OReillySACon