Microservices - DDD = Micromonolith

1.

Microservices - DDD = Micromonolith
#ThumbtackJavaMeetup
27/03/2019
Vadim Anosov

2.

Agenda
I. What is Domain-Driven Design?
II. What are the key concepts of the DDD approach?
III. How DDD helps to define an application’s microservice architecture?
IV. Why design microservice architecture without DDD concepts is the
way to Micro-monolith?

3.

Trends: Microservices vs Domain-Driven
Design

4.

Trends: Microservices vs Domain-Driven
Design
"Data source: Google Trends (www.google.com/trends)"

5.

6.

What is the right size of a service in the microservice
architecture?

7.

What is the right size of a service in the microservice
architecture?

8.

What is the right size of a service in the microservice
architecture?
Microservice
=
Business capability
★ The most meaningful separation guided by domain knowledge
★ The emphasis isn't on the size, but instead on business capabilities

9.

Agenda
I. What is Domain-Driven Design?
II. What are the key concepts of the DDD approach?
III. How DDD helps to define an application’s microservice architecture?
IV. Why design microservice architecture without DDD concepts is the
way to Micro-monolith?

10.

Domain-Driven Design
“Implementing Domain-Driven Design”
by Vaughn Vernon
“Domain-Driven Design: Tackling
Complexity in the Heart of
Software” by Eric Evans

11.

Domain-Driven Design
DDD is an approach for building complex software applications that is
centered on the development of an object-oriented domain model.

12.

Agenda
I. What is Domain-Driven Design?
II. What are the key concepts of the DDD approach?
III. How DDD helps to define an application’s microservice architecture?
IV. Why design microservice architecture without DDD concepts is the
way to Micro-monolith?

13.

Domain-Driven Design
Strategic patterns
Sub-domain
Ubiquitous
Language
Tactical patterns
Entities
Continuous
Integration
Domain
Modules
Factories
Bounded
Context
Context
Map
Services
Repositories
Layers
Domain
model
Aggregates
Value
Objects

14.

Agenda
I. What is Domain-Driven Design?
II. What are the key concepts of the DDD approach?
III. How DDD helps to define an application’s microservice architecture?
IV. Why design microservice architecture without DDD concepts is the
way to Micro-monolith?

15.

Microservices dilemma
Monolith first
Microservices first

16.

Three steps to defining an application’s
microservice architecture
★ Identify system operations
★ Identify services
★ Define service APIs and collaborations

17.

Three steps to defining an application’s
microservice architecture
★ Identify system operations:

18.

DDD toolbox: Ubiquitous Language

19.

DDD toolbox: Ubiquitous Language
Turn on
Turn off

20.

Ubiquitous Language: Extracting a Hidden Concept

21.

Ubiquitous Language: Extracting a Hidden Concept

22.

Ubiquitous Language: Extracting a Hidden Concept

23.

DDD toolbox: Domain, Subdomain

24.

Result of using Ubiquitous Language, Domain
and Subdomain

25.

Three steps to defining an application’s
microservice architecture
★ Identify services:

26.

Patterns for decomposing an application into
services
Decompose by
business capability
Decompose by
subdomain

27.

DDD toolbox: Bounded Context
Explicitly define the context within
Keep the model strictly
which a model is applied
consistent within these bounds
Explicitly set boundaries in terms
of team organization

28.

Bounded Context: possible problems
Duplicate concepts
Customer
Client
False cognates
Order

29.

God classes preventing decomposition

30.

God classes preventing decomposition

31.

DDD toolbox: Aggregate
Only accessed through its
Root Entity.
Responsible for maintaining
any/all business invariants.
A cluster of objects treated
as a single unit.
The atomic unit for any
transactional behavior.

32.

Aggregate: Rule #1
Reference other aggregate roots
via identity (primary key)

33.

Aggregate: Rule #2
X
X
One transaction creates or
updates one aggregate
(Transaction scope = service)

34.

Aggregate granularity
Customer
Product
Order
Consistency
Customer
Customer
Product
Product
Order
Order
Scalability

35.

DDD & Microservices
★ Apply strategic DDD to identify microservices (bounded context,
ubiquitous language, context map)
★ Apply tactical DDD to design individual services (aggregator, value
object, service)

36.

What is the right size of a service in the microservice
architecture?
“...Microservice should be no smaller than an aggregate, and no larger
than a bounded context...”

37.

What is the right size of a service in the microservice
architecture?

38.

Useful links
Domain-Driven Design: Tackling Complexity in the Heart
of Software
Implementing Domain-Driven Design
Microservices Patterns: With examples in Java
Building Microservices: Designing Fine-Grained Systems
Martin Fowlers blog: DDD
DDD Europe

39.

Thank you for your attention!
English     Русский Правила