Slide 1

Slide 1 text

Microservices Bounded Contexts And Everything in Between

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

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

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Decomposition Strategies Bounded Contexts, Business Domains, 
 Business En66es Design Heuristics Microservices Wrap-up Example Business Domain 1 2 3 4 5

Slide 10

Slide 10 text

Your Product Marketing
 Strategy Creatives Campaigns Sales
 Agents Optimization Profits

Slide 11

Slide 11 text

Decomposi9on Strategies Bounded Contexts Subdomains Business Entities and Processes

Slide 12

Slide 12 text

Bounded Contexts

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

Domain Expert Software Developer

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

Campaigns Sales
 Agents Your Product Marketing
 Strategy Creatives Optimization Profits

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

Conflicting models Different contexts Dividing the language/model Bounded Context

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

Marke9ng Service Sales Service Decomposi9on Strategy #1: Bounded Contexts

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

Subdomains

Slide 23

Slide 23 text

Business Domain: Customer Acquisi6on Bounded Context: Marke6ng Bounded Context: Sales Subdomain: Crea6ve Catalog Subdomain: Campaigns Mngmt Subdomain: Ads Op6miza6on Subdomain: Contracts Mngmt Subdomain: CRM Subdomain: Sales Op6miza6on Subdomain: Commissions Subdomain: Desks Mngmt

Slide 24

Slide 24 text

Decomposi9on Strategy #2: Subdomains Campaign Management Service Content Catalog Service Desks Management Service CRM Service Users Service Billing Service

Slide 25

Slide 25 text

Business En99es and Processes

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

Decomposi9on Strategy #3: En99es Website Asset Target Market Broker Distribu6on Customer

Slide 28

Slide 28 text

Decomposi9on Strategies Bounded Contexts Subdomains Business Entities and Processes

Slide 29

Slide 29 text

SHOW ME THE MICROSERVICES!

Slide 30

Slide 30 text

Bounded Contexts == Microservices ?

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

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

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

Bounded Contexts == Microservices? No

Slide 40

Slide 40 text

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

Slide 41

Slide 41 text

Microservices

Slide 42

Slide 42 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 43

Slide 43 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 44

Slide 44 text

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

Slide 45

Slide 45 text

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

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

Service Interface

Slide 48

Slide 48 text

Services ➜ Microservice

Slide 49

Slide 49 text

A microservice is a service with a micro interface

Slide 50

Slide 50 text

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

Slide 51

Slide 51 text

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

Slide 52

Slide 52 text

But!

Slide 53

Slide 53 text

1 Method = Perfect Microservice !!??

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

STAFF ONLY STAFF ONLY

Slide 59

Slide 59 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 60

Slide 60 text

Monolith Microservices Distributed
 Monolith Cost of Change

Slide 61

Slide 61 text

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

Slide 62

Slide 62 text

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

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 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 65

Slide 65 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 66

Slide 66 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 67

Slide 67 text

Services + Good Engineering = Microservices

Slide 68

Slide 68 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 69

Slide 69 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 70

Slide 70 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 71

Slide 71 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 72

Slide 72 text

Design Heuris9cs

Slide 73

Slide 73 text

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

Slide 74

Slide 74 text

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

Slide 75

Slide 75 text

Heuris9c #2: Don’t Benefits Addi6onal
 Complexity

Slide 76

Slide 76 text

Heuris9c #2: Don’t Benefits Addi6onal Complexity

Slide 77

Slide 77 text

Core Supporting Generic

Slide 78

Slide 78 text

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

Slide 79

Slide 79 text

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

Slide 80

Slide 80 text

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

Slide 81

Slide 81 text

Heuris9c #3: Buy/Adopt Generic Subdomains Your System 3rd party product An6-Corrup6on Layer

Slide 82

Slide 82 text

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

Slide 83

Slide 83 text

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

Slide 84

Slide 84 text

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

Slide 85

Slide 85 text

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

Slide 86

Slide 86 text

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

Slide 87

Slide 87 text

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

Slide 88

Slide 88 text

Heuris9c #5: Suppor9ng Subdomains - Early Can be decomposed beyond the subdomain’s boundaries.

Slide 89

Slide 89 text

Core Supporting Generic

Slide 90

Slide 90 text

Heuris9c #6: Evaluate Consistency Requirements Method A Method B

Slide 91

Slide 91 text

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

Slide 92

Slide 92 text

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

Slide 93

Slide 93 text

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

Slide 94

Slide 94 text

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

Slide 95

Slide 95 text


 Service A Method A 
 Service B Method B Asynchronous Communication

Slide 96

Slide 96 text

Heuris9c #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 97

Slide 97 text

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

Slide 98

Slide 98 text

Heuris9c #7: Public / Private Events Events?

Slide 99

Slide 99 text

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

Slide 100

Slide 100 text

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

Slide 101

Slide 101 text

Heuris9c #8: Make Events Explicit Eliminate ambiguity

Slide 102

Slide 102 text

Heuris9c #8: Make Events Explicit Service AgentAssignedToLead

Slide 103

Slide 103 text

Heuris9c #8: Make Events Explicit Service AgentAssignedToLead AgentAssignedToLead AgentAssignedToLead

Slide 104

Slide 104 text

Heuris9c #8: Make Events Explicit Service AgentAssignedToLead AgentUnassigned AgentAssignedToLead

Slide 105

Slide 105 text

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

Slide 106

Slide 106 text

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

Slide 107

Slide 107 text

Heuris9c #10: Evaluate Services’ “Doors”

Slide 108

Slide 108 text

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

Slide 109

Slide 109 text

Summary

Slide 110

Slide 110 text

1. A service is a unit of func6onality exposed to the world through its public interface. 2. A microservice is a service with micro interface 3. The “micro-interface” is rela6ve to the use cases of the system that the service is a part of

Slide 111

Slide 111 text

Heuris6c #1: Always decompose to Bounded Contexts Heuris6c #2: Don’t go further, unless you have to Heuris6c #3: Buy/adopt generic subdomains Heuris6c #4: Core Subdomains - don’t rush Heuris6c #5: Suppor6ng Subdomains can be decomposed early

Slide 112

Slide 112 text

Heuris6c #6: Evaluate Consistency Requirements Heuris6c #7: Private / Public Events Heuris6c #8: Explicitly Define Events Heuris6c #9: Evaluate Reasons for Change Heuris6c #10: Evaluate Services’ “Doors”

Slide 113

Slide 113 text

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

Slide 114

Slide 114 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. Implemen6ng Domain-Driven Design, Vaughn Vernon 6. Enterprise Integra6on 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 Applica6on Architecture, Mar6n 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 115

Slide 115 text

THANK YOU! @vladikk vladikk.com

Slide 116

Slide 116 text

QUESTIONS? @vladikk vladikk.com

Slide 117

Slide 117 text

THANK YOU! @vladikk vladikk.com