Slide 1

Slide 1 text

How to Split a Monolith: Service Architecture & Domain-Driven Design (DDD) Joy Ebertz Sr Staff Engineer

Slide 2

Slide 2 text

Today’s agenda • What do I mean by Service Architecture? • Why Worry About Service Architecture? • What is Domain-Driven Design or DDD? • What is Layered Architecture? • Mapping Back to Services

Slide 3

Slide 3 text

What do I mean by Service Architecture? (In the context of this talk)

Slide 4

Slide 4 text

Request API Gateway Authz Service AuthN Rate Limiting App Services Business Capability Services Foundational Capability Services Logging Event Bus Secrets Management Service Discovery

Slide 5

Slide 5 text

Typical SOA Architecture Request API Gateway Authz Service AuthN Rate Limiting App Services Business Capability Services Foundational Capability Services Logging Event Bus Secrets Management Service Discovery

Slide 6

Slide 6 text

Typical SOA Architecture App Services Business Capability Services Foundational Capability Services

Slide 7

Slide 7 text

Why worry about Service Architecture?

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Code Repetition

Slide 11

Slide 11 text

Code Repetition

Slide 12

Slide 12 text

Code Repetition

Slide 13

Slide 13 text

Hyper-localized Optimizations

Slide 14

Slide 14 text

Chaos

Slide 15

Slide 15 text

Chaos

Slide 16

Slide 16 text

Chaos

Slide 17

Slide 17 text

Chaos

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

FE BE

Slide 20

Slide 20 text

Domains/Bounded Contexts FE BE

Slide 21

Slide 21 text

Layers FE BE

Slide 22

Slide 22 text

What is Domain-Driven Design or (DDD)?

Slide 23

Slide 23 text

DDD is an approach to developing software for complex needs by deeply connecting the implementation to an evolving model of the core business concepts.

Slide 24

Slide 24 text

Since 2004

Slide 25

Slide 25 text

Business Value over Technical Strategy DDD Principles

Slide 26

Slide 26 text

DDD Principles Cross-functional Collaboration

Slide 27

Slide 27 text

over Point Solutions DDD Principles

Slide 28

Slide 28 text

Software Best Practices: Separation of Concerns DDD Principles

Slide 29

Slide 29 text

Software Best Practices: Simplicity. DDD Principles

Slide 30

Slide 30 text

DDD Principles

Slide 31

Slide 31 text

DDD Core Concepts • Domains and Subdomains

Slide 32

Slide 32 text

DDD Core Concepts • Domains and Subdomains • Bounded Contexts

Slide 33

Slide 33 text

DDD Core Concepts • Domains and Subdomains • Bounded Contexts • Ubiquitous Language

Slide 34

Slide 34 text

DDD Core Concepts • Domains and Subdomains • Bounded Contexts • Ubiquitous Language

Slide 35

Slide 35 text

Domains & Subdomains DDD Core Concepts Problem Space

Slide 36

Slide 36 text

Domains & Subdomains DDD Core Concepts

Slide 37

Slide 37 text

Domains & Subdomains DDD Core Concepts

Slide 38

Slide 38 text

Domains & Subdomains DDD Core Concepts

Slide 39

Slide 39 text

Domains & Subdomains DDD Core Concepts

Slide 40

Slide 40 text

Domains & Subdomains DDD Core Concepts

Slide 41

Slide 41 text

Domains & Subdomains DDD Core Concepts

Slide 42

Slide 42 text

Types of Subdomains: Core Subdomain

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

Types of Subdomains: Supporting Subdomain

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

Types of Subdomains: Generic Subdomain

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

API Gateway Authentication Service Authorization Service Logging/Monitoring Contacting Customers (Email/Phone) (Feature Flags and A/B Testing)

Slide 50

Slide 50 text

Core Subdomain Supporting Subdomain Generic Subdomain

Slide 51

Slide 51 text

Core Subdomain Supporting Subdomain Generic Subdomain

Slide 52

Slide 52 text

Core Subdomain Supporting Subdomain Generic Subdomain

Slide 53

Slide 53 text

Core Subdomain Supporting Subdomain Generic Subdomain

Slide 54

Slide 54 text

DDD Core Concepts • Domains and Subdomains • Bounded Contexts • Ubiquitous Language

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

Domains

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

Bounded Context

Slide 60

Slide 60 text

The problem space is defined by a domain which consists of one or more subdomains.

Slide 61

Slide 61 text

The problem space is defined by a domain which consists of one or more subdomains. The solution space is defined by a domain model which consists of one or more bounded contexts.

Slide 62

Slide 62 text

Characteristics of Bounded Contexts

Slide 63

Slide 63 text

Clear and Controlled Entry Points Bounded Context

Slide 64

Slide 64 text

Clear and Controlled APIs Bounded Context

Slide 65

Slide 65 text

Bounded Context

Slide 66

Slide 66 text

Bounded Context

Slide 67

Slide 67 text

Bounded Context

Slide 68

Slide 68 text

DDD Core Concepts • Domains and Subdomains • Bounded Contexts • Ubiquitous Language

Slide 69

Slide 69 text

Ubiquitous Language Domain Expert Marketing Developer

Slide 70

Slide 70 text

Ubiquitous Language Domain Expert Marketing Developer Application Code Test Code Specs and Documentation Discussions & whiteboarding

Slide 71

Slide 71 text

Subdomain Subdomain

Slide 72

Slide 72 text

What is a file?

Slide 73

Slide 73 text

Content Subdomain The container object that groups different versions of a piece of content and enables Box file- system capabilities. What is a file?

Slide 74

Slide 74 text

Content Subdomain Storage Subdomain The container object that groups different versions of a piece of content and enables Box file- system capabilities. A blob of customer-owned data identified by a uniq_name. What is a file?

Slide 75

Slide 75 text

Domains/Bounded Contexts FE BE

Slide 76

Slide 76 text

Layers FE BE

Slide 77

Slide 77 text

What is Layered Architecture?

Slide 78

Slide 78 text

Layered Architecture is a way of dividing up an architecture between front-end, middle tier and back-end logic to optimize for decoupling and re-use.

Slide 79

Slide 79 text

Application

Slide 80

Slide 80 text

Application Business Capability

Slide 81

Slide 81 text

Application Business Capability Foundational Capability

Slide 82

Slide 82 text

Application Business Capability Foundational Capability Infrastructure Services

Slide 83

Slide 83 text

Application Business Capability Foundational Capability Infrastructure Services

Slide 84

Slide 84 text

Backend For Frontend (BFF)

Slide 85

Slide 85 text

Your Servers Backend For Frontend (BFF)

Slide 86

Slide 86 text

Your Servers FE Engineers BE Engineers Backend For Frontend (BFF)

Slide 87

Slide 87 text

Your Servers FE Engineers BE Engineers Backend For Frontend (BFF)

Slide 88

Slide 88 text

Your Servers FE Engineers BE Engineers Backend For Frontend (BFF)

Slide 89

Slide 89 text

Backend For Frontend (BFF) Application Service FE Engineers

Slide 90

Slide 90 text

Application Service Application Service Application Service Backend For Frontend (BFF)

Slide 91

Slide 91 text

Application Service Application Service Application Service

Slide 92

Slide 92 text

No content

Slide 93

Slide 93 text

Application Business Capability Foundational Capability Infrastructure Services

Slide 94

Slide 94 text

No content

Slide 95

Slide 95 text

Business Capability Service

Slide 96

Slide 96 text

Physical Store Race Expo Website Buy Running Shoes

Slide 97

Slide 97 text

iPhone Buy Running Shoes

Slide 98

Slide 98 text

iPhone Buy Running Shoes

Slide 99

Slide 99 text

iPhone Buy Running Shoes Webapp

Slide 100

Slide 100 text

iPhone Buy Running Shoes Webapp

Slide 101

Slide 101 text

No content

Slide 102

Slide 102 text

Application Business Capability Foundational Capability Infrastructure Services

Slide 103

Slide 103 text

No content

Slide 104

Slide 104 text

No content

Slide 105

Slide 105 text

No content

Slide 106

Slide 106 text

Single Source of Truth

Slide 107

Slide 107 text

User Profile User Profile

Slide 108

Slide 108 text

User Profile User Billing

Slide 109

Slide 109 text

No content

Slide 110

Slide 110 text

Application Business Capability Foundational Capability Infrastructure Services

Slide 111

Slide 111 text

No content

Slide 112

Slide 112 text

Often Generic Subdomains

Slide 113

Slide 113 text

Mapping Back to Services

Slide 114

Slide 114 text

No content

Slide 115

Slide 115 text

Application Service Application Service

Slide 116

Slide 116 text

Application Service Application Service Foundational Backend Service Business Capability Backend Service

Slide 117

Slide 117 text

Application Service Application Service Foundational Backend Service Business Capability Backend Service

Slide 118

Slide 118 text

Application Service Application Service Foundational Backend Service Business Capability Backend Service Backend Service

Slide 119

Slide 119 text

Typical SOA Architecture Request API Gateway Authz Service AuthN Rate Limiting App Services Business Capability Services Foundational Capability Services Logging Event Bus Secrets Management Service Discovery

Slide 120

Slide 120 text

Recap • Service Architecture • Domain-Driven Design or DDD • Layered Architecture • Mapping Back to Services Joy Ebertz @jkebertz [email protected]

Slide 121

Slide 121 text

Thank you!

Slide 122

Slide 122 text

Further Resources • Eric Evans’ classic DDD book that started it all (the ‘Blue Book’): Domain Driven Design: Tackling Complexity in the Heart of Software • Vaughn Vernon has a book a bit more on the practical side (the ‘Red Book’): Implementing Domain Driven Design • If you want something a bit shorter Vaughn Vernon also has a shortened version: Domain Driven Design Distilled • For another shorter, more reference driven option, Eric Evans also has: Domain Driven Design Reference • A former colleague recommends Scott Millett’s book: Patterns, Priciples, and Practices of Domain Driven Design DDD Books

Slide 123

Slide 123 text

• Getting Started with Domain Driven Design: http://www.informit.com/articles/article.aspx?p=1944876&seqNum=5 • Strategic Domain Driven Design with Context Mapping: https://www.infoq.com/articles/ddd- contextmapping/ • My blog post, A Brief Intro to Domain Driven Design: https://austinstartups.com/a-brief-intro- to-domain-driven-design-326cf1669bbc • Is Design Dead? https://www.martinfowler.com/articles/designDead.html • How Can Domain-driven design help with large scale agile development? http://www.ben- morris.com/how-can-domain-driven-design-help-with-large-scale-agile-development/ DDD Articles Further Resources

Slide 124

Slide 124 text

• Thoughtworks has a really great blog post about this topic: https://www.thoughtworks.com/insights/blog/well-factored-approach-securing-roi- your-service-investment-part-2 . Part 1 is here: https://www.thoughtworks.com/insights/blog/well-factored-approach-securing-roi-your- service-investment, but honestly most of the good material is in part 2. • The language in this one is a little bit different, but Mulesoft fundamentally talks about a lot of the same concepts: https://cloud.box.com/s/ggttm7wjsposhrcjxxzdmb3f4uxzp6mg • Another one by Mulesoft. This one doesn't directly talk about the horizontal splitting but does have a great diagram: https://www.linkedin.com/pulse/build-business-capabilities-apis- nial-darbey Layered Architecture Articles Further Resources

Slide 125

Slide 125 text

• This also covers a lot more material, but in their Identifying Services section, IBM also touches on these concepts: https://www.redbooks.ibm.com/redbooks/pdfs/sg248357.pdf • This talks about more general layering principals, but has a lot of rules of thumb that still apply: https://www.linkedin.com/pulse/build-business-capabilities-apis-nial-darbey • Not directly about these concepts, but Jeff Coble's blog post is somewhat related and a good read: https://medium.com/@jeffcoble/from-product-to-platform-5d6857e55afb • My blog post (Microservices: Building things is easy, building the right thing is hard) also touches briefly on this: https://medium.com/box-tech-blog/microservices-building-things-is- easy-building-the-right-thing-is-hard-b88b6e2474c1 Layered Architecture Articles (continued…) Further Resources