Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Microservices, Bounded Contexts, and Everything in Between

Microservices, Bounded Contexts, and Everything in Between

DDD eXchange 2018

Vladik Khononov

April 26, 2018
Tweet

More Decks by Vladik Khononov

Other Decks in Technology

Transcript

  1. ”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
  2. ”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
  3. Decomposition Strategies Bounded Contexts, Business Domains, 
 Business En66es Design

    Heuristics Microservices Wrap-up Example Business Domain 1 2 3 4 5
  4. Marke9ng Sales Lead Lead Funnel Campaign Placement Landing Page Agency

    Insertion Order Message Campaign Proposition Desk Conversion Contact CDR Bounded Contexts
  5. Marke9ng Sales Commissions Desks Sales
 Optimization CRM Telephony Creative Catalog

    Contracts Billing Campaign Management Identity & Access Ads Optimization Identity & Access
  6. 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
  7. Decomposi9on Strategy #2: Subdomains Campaign Management Service Content Catalog Service

    Desks Management Service CRM Service Users Service Billing Service
  8. Marke9ng Creative Catalog Contracts Billing Campaign Management Identity & Access

    Optimization Campaign Management Campaign Placement Funnel Banner Landing Page Website Zone Asset Publisher Target Market
  9. Marke9ng Sales Lead Lead Funnel Campaign Placement Landing Page Agency

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

    Insertion Order Message Campaign Proposition Desk Conversion Contact CDR
  11. Marke9ng Sales Commissions Desks Optimization CRM Telephony Creative Catalog Contracts

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

    Billing Campaign Management Identity & Access Optimization Identity & Access Lead Lead
  13. Marke9ng Creative Catalog Campaign Management Optimization Lead Sales Commissions Optimization

    CRM Lead Desks Telephony Support Contracts Billing Identity & Access
  14. Bounded Context Consistency boundary of the language / model Define

    the biggest valid monoliths Required decomposition boundary
  15. 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?
  16. 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
  17. “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
  18. Microservice = Microinterface Reducing coupling between services Limits reasons for

    change Easier to understand Better fault isolation More autonomy between services
  19. Microservice & Databases Microservices should own its database No external

    access Access through Microservice’s API only Database = infinite interface!
  20. 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.
  21. Campaign Management Campaign Placement Funnel Banner Landing Page Website Zone

    Asset Publisher Target Market Campaign Website Placement Funnel Subdomains? En99es?
  22. ”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
  23. ”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
  24. 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
  25. 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
  26. 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
  27. 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.
  28. 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?
  29. Heuris9c #1: Decompose to Bounded Contexts Do not implement conflicting

    models in the same service. Always decompose to Bounded Contexts.
  30. Heuris9c #2: Don’t ”First Law of Distributed Object Design: 


    “Don’t distribute your objects” Mar9n Fowler
  31. Marke9ng Sales Commissions Desks Optimization CRM Telephony Creative Catalog Contracts

    Billing Campaign Management Identity & Access Optimization Identity & Access Generic
  32. Heuris9c #4: Core Subdomains - Don’t Rush Adhere to subdomain’s

    boundaries. Decompose further only when you acquire domain knowledge.
  33. Marke9ng Sales Commissions Desks Sales Optimization CRM Telephony Creative Catalog

    Contracts Billing Campaign Management Identity & Access Ad Optimization Identity & Access Generic Core Supporting
  34. Heuris9c #6: Evaluate Consistency Requirements Read last write? - Two

    services, synchronous communication 
 Service A Method A 
 Service B Method B Sync call
  35. Heuris9c #6: Evaluate Consistency Requirements Eventual consistency? - Two services,

    asynchronous communication 
 Service A Method A 
 Service B Method B Asynchronous Communication
  36. Heuris9c #6: Evaluate Consistency Requirements Concurrency control? - Same service

    Read last write? - Two services, sync communication Eventual consistency? - Two services, async communication
  37. 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) }
  38. Same reasons for change? Same rate of change? Can be

    decoupled? Should be the same service? Heuris9c #9: Evaluate Reasons for Change
  39. 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
  40. 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
  41. 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”
  42. 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