DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires...
Transcript of DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires...
![Page 1: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/1.jpg)
DDD & MicroservicesAt last, some boundaries!
Eric Evans @ericevans0
domainlanguage.com
Complex business logic
Domain-driven Design Domain modeling
Ubiquitous language
![Page 2: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/2.jpg)
You say ‘bandwagon’ like it’s a bad thing!
Adrian Cockcroft
![Page 3: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/3.jpg)
Why do I like microservices?
• Autonomous teams with isolated implementation.
• Acknowledge the rough and tumble of enterprises.
• Cattle not pets.
• A philosophical break from the past — gives us a chance to shake assumptions.
• But! Different people mean different things.
![Page 4: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/4.jpg)
Services and Messages
Sm mm m mm
![Page 5: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/5.jpg)
Am
m
m m
m mB
![Page 6: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/6.jpg)
Aa
b
a a
b bB
How do they understand the messages?
![Page 7: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/7.jpg)
Bounded Context
• context The setting in which a word or statement appears that determines its meaning
• bounded context The conditions under which a particular model is defined and applicable.
![Page 8: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/8.jpg)
Aa
b
a a
b bB
partnersA B
Context Map translator
bounded contexts
![Page 9: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/9.jpg)
partnersA B
Context Map
Aa
b
a a
b bB
C
a
a
a
![Page 10: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/10.jpg)
Asymmetrical Relationships
Context Name Context Namerelationship
(point toward power)
![Page 11: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/11.jpg)
Context Map
Aa
b
a a
b bB
C
a
a
a
partnersA B
C
![Page 12: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/12.jpg)
Context Map
Aa
b
a a
b bB
C
a
a
a
partnersA B
C
conforms
![Page 13: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/13.jpg)
Context Map
partnersA B
C
conforms
Aa
b
a a
b bB
C
a
a
a
D
aa
a
![Page 14: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/14.jpg)
Context Map
Aa
b
a a
b bB
C
a
a
a
D
aa
a
partnersA B
C
conforms
D
AC
![Page 15: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/15.jpg)
Context Map
partnersA B
C
conforms
D
AC
Aa
b
a a
b bB
C
a
a
a
D
aa
a
E a a
![Page 16: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/16.jpg)
Context Map
Aa
b
a a
b bB
C
a
a
a
D
aa
a
E a a
partnersA B
C
conforms
D
AC
E conforms
![Page 17: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/17.jpg)
Context Map
partnersA B
C
conforms
D
AC
E conforms
Aa
b
a a
b bB
C
a
a
a
D
aa
a
E a aa
a
a
![Page 18: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/18.jpg)
Context Map
partnersA B
C
conforms
D
AC
E conforms
Aa
b
a a
b bB
C
a
a
a
D
aa
a
E a a
F
bb
a
a
a
f
![Page 19: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/19.jpg)
Context Map
Aa
b
a a
b bB
C
a
a
a
D
aa
a
E a a
F
bb
a
a
a
f
partnersA B
C
conforms
D
AC
E conforms
Fconforms
AC
![Page 20: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/20.jpg)
There are always multiple models.
enterprise model shared database schema
unified field theory one ring
![Page 21: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/21.jpg)
Models need to be clear, not big.
• Useful models need crisp definitions.
• Definitions require clear context.
• Useful models need simple assertions.
• Assertions require boundaries.
![Page 22: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/22.jpg)
Context Map
Aa
b
a a
b bB
C
a
a
a
D
aa
a
E a a
F
bb
a
a
a
f
partnersA B
C
conforms
D
AC
E conforms
Fconforms
AC
![Page 23: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/23.jpg)
Context Map
partnersA B
C
conforms
D
AC
E conforms
Fconforms
AC
Aa
b
a a
b bB
C
a
a
a
D
aa
a
E a a
F
bb
a
a
a
f
![Page 24: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/24.jpg)
Context Map
Aa
b
a a
b bB
C
a
a
a
D
aa
a
E a a
F
bb
a
a
a
f
partnersA B
C
conforms
D
AC
E conforms
Fconforms
AC
BBoM
![Page 25: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/25.jpg)
Context Map
Aa
b
a a
b bB
C
a
a
a
D
aa
a
E a a
F
bb
a
a
a
f
partners
A B
C
conforms
D
AC
E conforms
Fconforms
AC
BBoMBBoM
![Page 26: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/26.jpg)
Context Map
partnersA B
C
conforms
D
AC
E conforms
Fconforms
AC
BBoMBBoM
Aa
b
a a
b bB
C
a
a
a
D
aa
a
E ae ae
F
bb
ae
ae
ae
f
Fiction! Map what is.
![Page 27: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/27.jpg)
Context Map
Aa
b
a a
b bB
C
a
a
a
D
aa
a
E ae ae
F
bb
ae
ae
ae
f
What can be done?
partners
A B
C
conforms
D
AC
E
Fconforms
AC
BBoMBBoM
BBoM
![Page 28: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/28.jpg)
Not all of a large system will be well designed.
![Page 29: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/29.jpg)
Context Map
Aa
b
a a
b bB
C
a
a
a
D
aa
a
E ae ae
F
bb
ae
ae
ae
f
partnersA B
C
conforms
D
AC
E
Fconforms
AC
BBoMBBoM
BBoM
???
???
Mitigation
![Page 30: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/30.jpg)
Context Map
Aa
b
a a
b bB
C
a
a
a
D
aa
a
E ae ae
F
bb
ae
ae
ae
f
partnersA B
C
conforms
D
AC
E
Fconforms
AC
BBoMBBoM
AC
ACBBoM
![Page 31: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/31.jpg)
Microservice as Context Boundary
• Allow high-concept modeling in a messy world.
• Allow specialized models for distinct problems.
• Mitigate consequences of design mistakes.
• Acknowledge the rough and tumble of enterprises.
• But…
• Very interesting stuff is not inside the services!
![Page 32: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/32.jpg)
Interchange context
![Page 33: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/33.jpg)
Context Map
Aa
b
a a
b bB
C
a
a
a
D
aa
a
E a a
F
bb
a
a
a
f
partnersA B
C
conforms
D
AC
E conforms
Fconforms
AC
![Page 34: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/34.jpg)
Context Map
partnersA B
C
conforms
D
AC
E conforms
Fconforms
AC
Aa
b
a a
b bB
C
i
i
i
D
ii
i
E i i
F
bb
i
i
i
f
![Page 35: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/35.jpg)
Context Map
Aa
b
a a
b bB
C
i
i
i
D
ii
i
E i i
F
bb
i
i
i
f
partnersI
B
C
conforms
D
AC
E conforms
Fconforms
AC
AAC
![Page 36: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/36.jpg)
`• A relatively generic data model for sharing.
• or…
• A place to model protocols of interaction.
• Modeling and design of higher-level solutions.
• A domain language tuned to these purposes.
![Page 37: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/37.jpg)
Interchange Context• Expressed in terms of service interfaces/messages.
• Distinct from the objects/functions of the internals of a service.
• Prevents distortion/freezing of early-dominant contexts.
• Gives big-picture understanding when we have many services.
• Usually more than one! (Avoid enterprise model.)
![Page 38: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/38.jpg)
Why not logical boundaries?
• Smart people I respect point out that most of what I want is the logical partitioning of the system.
• We’ve had decades to get that to work.
• Some techniques are too subtle to survive the rough and tumble.
![Page 39: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/39.jpg)
Wrap up• Subtle design (such as DDD) requires concrete
boundaries. Microservices have them.
• Proliferation of services recreate some of the old problems.
• Context Maps help visualize and communicate about those problems.
• Modest use of interchange contexts can help produce coherent sets of microservices.
![Page 40: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/40.jpg)
Not all of a large system will be well designed.
![Page 41: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate](https://reader035.fdocuments.net/reader035/viewer/2022062919/5ee121ebad6a402d666c1fe0/html5/thumbnails/41.jpg)
DDD & MicroservicesAt last, some boundaries!
Eric Evans @ericevans0
domainlanguage.com