Slide 1

Slide 1 text

MICROSERVICES BOUNDED CONTEXTS AND EVERYTHING IN BETWEEN vladikk

Slide 2

Slide 2 text

@vladikk vladikk.com

Slide 3

Slide 3 text

”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 Composite / Structured Design, 1974

Slide 4

Slide 4 text

“MICROSERVICES FTW!!!!!!!!1” Me @ Internovus

Slide 5

Slide 5 text

“MICROSERVICES FTW!!!!!!!!1” Me @ Internovus

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

”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 Composite / Structured Design, 1974

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Decomposi/on Strategies Microservices Design Heuris/cs

Slide 11

Slide 11 text

vladikk NAXEX / INTERNOVUS 01 BUSINESS DOMAIN

Slide 12

Slide 12 text

Your Product Marketing
 Strategy Creatives Campaigns Sales
 Agents Optimization Profits

Slide 13

Slide 13 text

vladikk DECOMPOSITION 02 STRATEGIES

Slide 14

Slide 14 text

Bounded Contexts

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

Business Domain Expert Software Developer ??? !!! Ubiquitous Language

Slide 17

Slide 17 text

Campaigns Sales
 Agents Your Product Marketing
 Strategy Creatives Optimization Profits

Slide 18

Slide 18 text

Campaigns Sales
 Agents Your Product Marketing
 Strategy Creatives Optimization Profits

Slide 19

Slide 19 text

Sales Agent Campaign Manager ??? !!! LEAD?

Slide 20

Slide 20 text

Conflicting models Different contexts Dividing the language/model Bounded Context

Slide 21

Slide 21 text

MarkeCng Sales Lead Lead Funnel Campaign Placement Landing Page Agency Insertion Order Message Campaign Proposition Desk Conversion Contact CDR Bounded Contexts

Slide 22

Slide 22 text

MarkeCng Service Sales Service DecomposiCon Strategy #1: Bounded Contexts

Slide 23

Slide 23 text

MarkeCng

Slide 24

Slide 24 text

MarkeCng Creative Catalog Contracts Billing Campaign Management Identity & Access Ads Optimization

Slide 25

Slide 25 text

MarkeCng Sales Creative Catalog Contracts Billing Campaign Management Identity & Access Ads Optimization

Slide 26

Slide 26 text

MarkeCng Sales Commissions Desks Sales
 Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Ads Optimization Identity & Access

Slide 27

Slide 27 text

Business (Sub)Domains

Slide 28

Slide 28 text

Business Domain: Customer Acquisi/on Bounded 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

Slide 29

Slide 29 text

DecomposiCon Strategy #2: Subomains Campaign Management Service Content Catalog Service Desks Management Service CRM Service Users Service Billing Service

Slide 30

Slide 30 text

Business EnCCes and Processes

Slide 31

Slide 31 text

MarkeCng Creative Catalog Contracts Billing Campaign Management Identity & Access Optimization

Slide 32

Slide 32 text

MarkeCng Creative Catalog Contracts Billing Campaign Management Identity & Access Optimization Campaign Management Campaign Placement Funnel Banner Landing Page Website Zone Asset Publisher Target Market

Slide 33

Slide 33 text

DecomposiCon Strategy #3: EnCCes Website Asset Target Market Broker Distribu/on Customer

Slide 34

Slide 34 text

DecomposiCon Strategies Bounded Contexts Subdomains Business Entities and Processes

Slide 35

Slide 35 text

SHOW ME THE MICROSERVICES!

Slide 36

Slide 36 text

Bounded Contexts == Microservices ?

Slide 37

Slide 37 text

Sales Agent Campaign Manager ??? !!! LEAD?

Slide 38

Slide 38 text

MarkeCng Sales Lead Lead Funnel Campaign Placement Landing Page Agency Insertion Order Message Campaign Proposition Desk Conversion Contact CDR

Slide 39

Slide 39 text

MarkeCng Sales Lead Lead Funnel Campaign Placement Landing Page Agency Insertion Order Message Campaign Proposition Desk Conversion Contact CDR

Slide 40

Slide 40 text

MarkeCng Sales Lead Lead Funnel Campaign Placement Landing Page Agency Insertion Order Message Campaign Proposition Desk Conversion Contact CDR

Slide 41

Slide 41 text

MarkeCng Sales Commissions Desks Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Optimization Identity & Access Lead Lead

Slide 42

Slide 42 text

MarkeCng Sales Commissions Desks Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Optimization Identity & Access Lead Lead

Slide 43

Slide 43 text

MarkeCng Creative Catalog Campaign Management Optimization Lead Sales Commissions Optimization CRM Lead Desks Telephony Support Contracts Billing Identity & Access

Slide 44

Slide 44 text

Bounded Contexts Decomposi/on #1 Bounded Contexts Decomposi/on #2 Bounded Contexts Decomposi/on #3

Slide 45

Slide 45 text

Bounded Context Consistency boundary of the language / model Define the biggest valid monoliths Required decomposition boundary

Slide 46

Slide 46 text

Bounded Contexts == Microservices? No

Slide 47

Slide 47 text

Campaign Management Campaign Placement Funnel Banner Landing Page Website Zone Asset Publisher Target Market Campaign Website Placement Funnel MarkeCng Creative Catalog Contracts Billing Campaign Management Identity & Access Optimization Bounded Contexts? No Subdomains? EnCCes?

Slide 48

Slide 48 text

Campaign Management Campaign Placement Funnel Banner Landing Page Website Zone Asset Publisher Target Market Campaign Website Placement Funnel MarkeCng Creative Catalog Contracts Billing Campaign Management Identity & Access Optimization Bounded Contexts? No Subdomains? EnCCes?

Slide 49

Slide 49 text

vladikk MICROSERVICES 03

Slide 50

Slide 50 text

Service “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

Slide 51

Slide 51 text

“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

Slide 52

Slide 52 text

Service Interface “Any mechanism for getting data in or out of the service” - Randy Shoup

Slide 53

Slide 53 text

Service Interface Synchronous: • Request / Réponse • Bulk ETL

Slide 54

Slide 54 text

Service Interface Asynchronous: • Producing events • Consuming events Synchronous: • Request / Réponse • Bulk ETL

Slide 55

Slide 55 text

Service Interface “Any mechanism for getting data in or out of the service” - Randy Shoup

Slide 56

Slide 56 text

Service Interface

Slide 57

Slide 57 text

Services ➜ Microservice

Slide 58

Slide 58 text

A microservice is a service with a micro interface

Slide 59

Slide 59 text

A microservice is a service with a micro interface

Slide 60

Slide 60 text

Microservice = Microinterface Reducing coupling between services Limits reasons for change Easier to understand Better fault isolation More autonomy between services

Slide 61

Slide 61 text

Microservice & Databases Microservices should own its database No external access Access through Microservice’s API only Database = infinite interface!

Slide 62

Slide 62 text

But!

Slide 63

Slide 63 text

1 Method = Perfect Microservice !!??

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

STAFF ONLY STAFF ONLY

Slide 71

Slide 71 text

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.

Slide 72

Slide 72 text

Monolith Microservices Cost of Change

Slide 73

Slide 73 text

Monolith Microservices Distributed
 Monolith Cost of Change

Slide 74

Slide 74 text

Big Ball Of Mud Bounded Contexts Microservices Distributed Big Ball Of Mud Avg. Service Size

Slide 75

Slide 75 text

Campaign Management Campaign Placement Funnel Banner Landing Page Website Zone Asset Publisher Target Market Campaign Website Placement Funnel Subdomains? EnCCes?

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

”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, 1974

Slide 79

Slide 79 text

”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, 1974

Slide 80

Slide 80 text

”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, 1974

Slide 81

Slide 81 text

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-Lee Principles of design, 1998

Slide 82

Slide 82 text

Services + Good Engineering = Microservices

Slide 83

Slide 83 text

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-Lee Principles of design, 1998

Slide 84

Slide 84 text

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 Liskov A design methodology for reliable soIware systems, 1972

Slide 85

Slide 85 text

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.

Slide 86

Slide 86 text

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?

Slide 87

Slide 87 text

vladikk DESIGN 04 HEURISTICS

Slide 88

Slide 88 text

HeurisCc #1: Decompose to Bounded Contexts Do not implement conflicting models in the same service. 
 Always decompose to Bounded Contexts.

Slide 89

Slide 89 text

HeurisCc #2: Don’t ”First Law of Distributed Object Design: 
 “Don’t distribute your objects” MarCn Fowler

Slide 90

Slide 90 text

HeurisCc #2: Don’t Benefits Addi/onal
 Complexity

Slide 91

Slide 91 text

Monolith: System design that undermines delivery of functional or non-functional requirements

Slide 92

Slide 92 text

HeurisCc #2: Don’t Benefits Addi/onal
 Complexity

Slide 93

Slide 93 text

HeurisCc #2: Don’t Benefits Addi/onal Complexity

Slide 94

Slide 94 text

Core Supporting Generic

Slide 95

Slide 95 text

Generic Subdomains No competitive advantage Everybody is implementing in the same way Complex business logic

Slide 96

Slide 96 text

MarkeCng Sales Commissions Desks Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Optimization Identity & Access Generic

Slide 97

Slide 97 text

MarkeCng Sales Commissions Desks Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Optimization Identity & Access Generic

Slide 98

Slide 98 text

MarkeCng Sales Commissions Desks Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Optimization Identity & Access Generic

Slide 99

Slide 99 text

MarkeCng Sales Commissions Desks Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Optimization Identity & Access Generic

Slide 100

Slide 100 text

MarkeCng Sales Commissions Desks Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Optimization Identity & Access Generic

Slide 101

Slide 101 text

MarkeCng Sales Commissions Desks Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Optimization Identity & Access Generic

Slide 102

Slide 102 text

MarkeCng Sales Commissions Desks Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Optimization Identity & Access Generic

Slide 103

Slide 103 text

MarkeCng Sales Commissions Desks Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Optimization Identity & Access Generic

Slide 104

Slide 104 text

HeurisCc #3: Buy/Adopt Generic Subdomains Your System 3rd party product

Slide 105

Slide 105 text

HeurisCc #3: Buy/Adopt Generic Subdomains Your System 3rd party product An/-Corrup/on Layer

Slide 106

Slide 106 text

Core Subdomains Inventing something new Optimizing existing paractices Competitive advantage Complex business logic Change often

Slide 107

Slide 107 text

MarkeCng Sales Commissions Desks Sales
 Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Ad Optimization Identity & Access Generic Core

Slide 108

Slide 108 text

MarkeCng Sales Commissions Desks Sales
 Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Ad Optimization Identity & Access Generic Core

Slide 109

Slide 109 text

MarkeCng Sales Commissions Desks Sales Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Ad Optimization Identity & Access Generic Core

Slide 110

Slide 110 text

MarkeCng Sales Commissions Desks Sales Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Ad Optimization Identity & Access Generic Core

Slide 111

Slide 111 text

MarkeCng Sales Commissions Desks Sales Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Ad Optimization Identity & Access Generic Core

Slide 112

Slide 112 text

MarkeCng Sales Commissions Desks Sales Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Ad Optimization Identity & Access Generic Core

Slide 113

Slide 113 text

Core Subdomains Inventing something new Optimizing existing paractices Competitive advantage Complex business logic Change often

Slide 114

Slide 114 text

HeurisCc #4: Core Subdomains - Don’t Rush Adhere to subdomain’s boundaries. Decompose further only when you acquire domain knowledge.

Slide 115

Slide 115 text

SupporCng Subdomains No competitive advantage Support the Core Subdomains Can’t be bought / adopted Simple business logic

Slide 116

Slide 116 text

MarkeCng Sales Commissions Desks Sales Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Ad Optimization Identity & Access Generic Core Supporting

Slide 117

Slide 117 text

MarkeCng Sales Commissions Desks Sales Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Ad Optimization Identity & Access Generic Core Supporting

Slide 118

Slide 118 text

MarkeCng Sales Commissions Desks Sales Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Ad Optimization Identity & Access Generic Core Supporting

Slide 119

Slide 119 text

MarkeCng Sales Commissions Desks Sales Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Ad Optimization Identity & Access Generic Core Supporting

Slide 120

Slide 120 text

MarkeCng Sales Commissions Desks Sales Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Ad Optimization Identity & Access Generic Core Supporting

Slide 121

Slide 121 text

MarkeCng Sales Commissions Desks Sales Optimization CRM Telephony Creative Catalog Contracts Billing Campaign Management Identity & Access Ad Optimization Identity & Access Generic Core Supporting

Slide 122

Slide 122 text

SupporCng Subdomains No competitive advantage Support the Core Subdomains Can’t be bought / adopted Simple business logic

Slide 123

Slide 123 text

HeurisCc #5: SupporCng Subdomains - Safe Safe to decompose beyond the subdomain’s boundaries.

Slide 124

Slide 124 text

Core Supporting Generic

Slide 125

Slide 125 text

HeurisCc #6: Evaluate Consistency Requirements Method A Method B

Slide 126

Slide 126 text

HeurisCc #6: Evaluate Consistency Requirements Concurrency control? - Same service Method A Method B 
 Service A

Slide 127

Slide 127 text

HeurisCc #6: Evaluate Consistency Requirements Read last write? - Two services, synchronous communication 
 Service A Method A 
 Service B Method B Sync call

Slide 128

Slide 128 text

HeurisCc #6: Evaluate Consistency Requirements Eventual consistency? - Two services, asynchronous communication 
 Service A Method A 
 Service B Method B Asynchronous Communication

Slide 129

Slide 129 text

HeurisCc #6: Evaluate Consistency Requirements Concurrency control? - Same service Read last write? - Two services, sync communication Eventual consistency? - Two services, async communication

Slide 130

Slide 130 text


 Service A Method A 
 Service B Method B Asynchronous Communication

Slide 131

Slide 131 text

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 …

Slide 132

Slide 132 text

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) }

Slide 133

Slide 133 text

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) }

Slide 134

Slide 134 text

Service HeurisCc #7: Public / Private Events

Slide 135

Slide 135 text

Service EmailChanged PhoneNumberChanged AddressChanged HeurisCc #7: Public / Private Events

Slide 136

Slide 136 text

Service EmailChanged PhoneNumberChanged AddressChanged HeurisCc #7: Public / Private Events

Slide 137

Slide 137 text

Service EmailChanged PhoneNumberChanged AddressChanged ContactDetailsChanged HeurisCc #7: Public / Private Events

Slide 138

Slide 138 text

Service EmailChanged PhoneNumberChanged AddressChanged ContactDetailsChanged Private event types (Implementation details) } Public event type (Public interface) } HeurisCc #7: Public / Private Events

Slide 139

Slide 139 text

HeurisCc #7: Public / Private Events Events?

Slide 140

Slide 140 text

HeurisCc #7: Public / Private Events Events? Domain Events

Slide 141

Slide 141 text

HeurisCc #7: Public / Private Events Events? Domain Events State Change
 Events

Slide 142

Slide 142 text

HeurisCc #7: Public / Private Events Events? Domain Events State Change
 Events Private Public

Slide 143

Slide 143 text

HeurisCc #8: Make Events Explicit Eliminate ambiguity

Slide 144

Slide 144 text

HeurisCc #8: Make Events Explicit Service AgentAssignedToLead

Slide 145

Slide 145 text

HeurisCc #8: Make Events Explicit Service AgentAssignedToLead AgentAssignedToLead AgentAssignedToLead

Slide 146

Slide 146 text

HeurisCc #8: Make Events Explicit Service AgentAssignedToLead AgentUnassignedToLead AgentAssignedToLead

Slide 147

Slide 147 text

HeurisCc #8: Make Events Explicit Service AgentAssignedToLead AgentUnassignedToLead AgentAssignedToLead

Slide 148

Slide 148 text

HeurisCc #9: Evaluate Reasons for Change Service A Service B

Slide 149

Slide 149 text

Same reasons for change? Same rate of change? Can be decoupled? Should be the same service? HeurisCc #9: Evaluate Reasons for Change

Slide 150

Slide 150 text

No content

Slide 151

Slide 151 text

HeurisCc #10: Evaluate Services’ “Doors”

Slide 152

Slide 152 text

HeurisCc #10: Evaluate Services’ “Doors” STAFF ONLY STAFF ONLY

Slide 153

Slide 153 text

HeurisCc #10: Evaluate Services’ “Doors” STAFF ONLY STAFF ONLY

Slide 154

Slide 154 text

vladikk WRAP UP 05

Slide 155

Slide 155 text

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

Slide 156

Slide 156 text

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

Slide 157

Slide 157 text

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”

Slide 158

Slide 158 text

Big Ball Of Mud Bounded Contexts Microservices Distributed Big Ball Of Mud Avg. Service Size

Slide 159

Slide 159 text

Bibliography 1. A Design Methodology for Reliable Soeware Systems, Barbara Liskov 2. Composite/Structured Design, Glenford Myers 3. Domain-Driven Design: Tackling Complexity in the Heart of Soeware, Eric Evans 4. Emerging Boundaries, Mathias Veraes 5. Implemen/ng Domain-Driven Design, Vaughn Vernon 6. Enterprise Integra/on Paherns, Gregory Hohpe, at al 7. Long Sad Story of Microservices, Greg Young 8. Managing Data in Microservices, Randy Shoup 9. Microservices, At Last Some Boundaries, Eric Evans 10. On the Criteria to be Used in Decomposing Systems Into Modules, David Parnas 11. Paherns of Enterprise Applica/on Architecture, Mar/n Fowler, at al 12. Principles of Design, Tim Berners-Lee 13. Programming WCF Services, Juval Lowy 14. What Every Programmer Should Know About Object Oriented Design, Melir Page-Jones

Slide 160

Slide 160 text

QUESTIONS? @vladikk vladikk.com

Slide 161

Slide 161 text

THANK YOU! @vladikk vladikk.com