SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Masashi Narumoto
Principal PM Lead
AzureCAT patterns&practices
Modeling microservices
using Domain Driven Design
Modeling microservices
• How can I identify services?
• How can I find service boundaries?
• What is the right level of granularity?
• How do I manage workflow?
• How do I design inter-service communication?
• How can I manage service dependency?
Domain Driven Design
Domain Driven Design
• Approach to design software by modeling the business domain
• Strategic modeling
• Ubiquitous language
• Domain
• Bounded context
• Context mapping
• Tactical modeling
• Model inside bounded context
• Building block patterns
• Architecture
• Hexagonal, Layers, CQRS, Microservices
When to use DDD?
Source: Pattern of Enterprise Application Architecture: Martin Fowler
Rough sketch of drone delivery domain
Drone
management
Drone sharing
3rd party
transportation
Shipping (Core)
Call center
Accounts
Drone management
3rd party
transportation
Call center
Video
surveillance
Drone
sharing
Shipping
Domain model
Surveillance
Accounts
Context map – managing dependencies
• Tightly vs. Loosely coupled mapping patterns
• Shared kernel, Partnership, Conformist, Customer-supplier, Big Ball of Mud
• Anti-corruption layer, Separate ways, Open host service, Published language
Shared assets
Code
Data model
Infrastructure
Bounded context A Bounded context B
Shared kernel pattern
Shared assets
Tactical modeling – Building blocks
• Value object
• Entity
• Aggregate
• Domain event
• Domain Service
• Application Service
• Repository
• Factory
Value object
• Immutable object w/ business logic
• Benefits
• API clarity
• In-place validation
• Error handling
• Data handling
• Testability
• Used as API parameters, events, identity, etc.
• Example: email address, phone number
Power use of value objects in DDD by Dan Bergh Johnsson
Entity
• Has identity and lifecycle (not immutable)
• Attributes and behavior
• Can hold reference to other entities
• Track changes using domain event (Event sourcing)
• Example: User, Product
Aggregates
• Group of entities and value objects
• Defines consistency boundary
• Keep invariants in consistency boundary
• Modify one aggregate per transaction
• Size
• Large aggregate causes R/W overhead and more chance for optimistic CC to fail
• Split a large aggregate to multiple smaller ones
• Smaller ones perform/scale better
• Too small aggregates causes invariants to be fragmented in multiple aggregates
• Relationship
• Reference other aggregates by ID
• Example: User account, Subscription
Domain events
• Events in business process
• Events could be
• Result of commands on Aggregates
• Others
• Event sourcing to store the history of events
• Pub-Sub to notify multiple consumers
• Example: Order placed, Delivery completed
Domain services
• Stateless operations across multiple aggregates
• Implement business logic
• Significant business process
• Transform domain object from one composition to another
• Calculate a value with inputs from multiple domain objects
• Don’t overuse services
• Example: Delivery scheduling process
Application Service
• Client of the domain service
• No business logic
• Typical tasks
• Task coordination of use case flow
• Assemble and send DTO over the wire
• Create view model as resources in RESTful interface
• Ensure ACID transactions
• User authentication
• Keep application service thin
• Example: User authentication, Transferring DTO
Identify Microservices
Aggregates
Domainservices
Reference
Applicationservices
DTO
Aggregates
Events
Aggregates
Root entity
Other entities
Value object
Identify Microservices
Drone
Scheduler
Drone ID
Req
Delivery History
Delivery Events
Delivery
Gateway
Status
ADLS
Cosmos
Cassandra
Identify Microservices
Drone
Scheduler
Drone ID
Req
Delivery History
Delivery Events
Delivery
Gateway
Status
Drone
Delegating to remote service
Other
bounded context
Hexagonal architecture
Source: http://alistair.cockburn.us/Hexagonal+architecture
User interface
Applicationservices
Aggregates
Aggregates
Events
Applicationservices&
Infrastructure
DTO
Application services & Infrastructure
Identity provider
Remote services
Application services & Infrastructure
Domainservices
Find service boundary
• Bounded context is the service boundary
• BC is a linguistic boundary
• Analyze building blocks
• Aggregate, Domain Service, App Service are good candidates for microservices
• Break down further per each service characteristics
• Lifecycle (Rate of change)
• Quality attributes
• Technology used
• Team
Verify service granularity
• Responsibility
• Single responsibility
• Lifecycle
• Sharing the fate
• Team size
• 2 pizza rule
• Dependency
• No chatty calls between services
• Other metrics
• KPI such as velocity, team productivity, management cost etc.
• Too small granularity causes issues
• Communication overhead
• Tight coupling
• Lock-step deployment
• Data consistency
Designing services for drone delivery
Process of designing microservices using DDD
Accounts
Drone management
3rd party
transportation
Call center
Video
surveillance
Drone
sharing
Drone
management
Drone sharing
3rd party
transportation
Shipping (Core)
Call center
Shipping
Surveillance
Accounts
Bounded context
Aggregate Aggregate
Aggregate Domain Service
Domain ServiceAggregate
Application Service
Aggregate
Event
Domain model Domain building blocks
Service mapping
Shipping
Drone Package
Delivery DeliveryScheduler
DeliverySupervisor
Account
3rd party
transportation
Authentication
Service in BC
Service in BC
Service
In BC
Service
In BC
Service
outside
Service
outside
Service
outside
Service
outside
Further refinement
Breakdown per BC
Service interaction design
DeliveryScheduler
Package
Drone
Delivery
Mobile
app
Query
Delivery
History
DeliveryEvents
RequestEvents
GW
Status
3rd party
Service
Account
Service
DroneMgmt
Service
AAD
Account
Service
Auth
Service
3rd party
transportation
Account
RequestHandler
Delivery
Analysis
Archive
Supervisor
Failed ops
Drone events
Ubiquitous language to model each domain
Drone
management
Drone sharing
3rd party
transportation
Shipping (Core)
Call center
Accounts
Drone management
3rd party
transportation
Call center
Video
surveillance
Drone
sharing
Shipping
Context map – Drone delivery service
Surveillance
Accounts
Shipping
Tactical patterns in shipping domain
Shipping
Drone History
Delivery DeliveryScheduler
DeliverySupervisor
Account
3rd party
transportation
Authentication
Aggregate
Domain
service
Delivery
event
Event
Microservices in shipping domain
Shipping
Drone History
Delivery DeliveryScheduler
DeliverySupervisor
Account
3rd party
transportation
Authentication
DeliveryScheduler
DeliverySupervisorHistory
Authentication
Drone
Account
3rd party
transportation
Microservices
Microservices
In different BC
Delivery
event
Delivery
Scheduler
Package
Drone
Delivery
Mobile
app
Query
Delivery
History
DeliveryEvents
RequestEvents
GW
Status
3rd party
Service
Account
Service
DroneMgmt
Service
Further breakdown
AAD
Account
Service
Auth
Service
3rd party
transportation
Account
Ingestion
Delivery
Analysis
Archive
Supervisor
Failed ops
Drone events
Too much responsibility
Different scalability
Dealing with
failure
Scheduler
Package
Drone
Delivery
Mobile
app
Query
Delivery
History
RequestEvents
GW
Status
3rd party
Service
Account
Service
DroneMgmt
Service
Design patterns
AAD
Auth
Service
3rd party
transportation
Account
Ingestion
Delivery
Analysis
Archive
Supervisor
Drone events
Load levelingGW- routing
Throttling
Circuit breaker
Bulkhead
Sidecar
GW- offloading
Event sourcing
Ambassador
Materialized
View
Scheduler-agent-Supervisor
Modeling microservices using DDD

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservicesAnil Allewar
 
Microservices, Containers, Kubernetes, Kafka, Kanban
Microservices, Containers, Kubernetes, Kafka, KanbanMicroservices, Containers, Kubernetes, Kafka, Kanban
Microservices, Containers, Kubernetes, Kafka, KanbanAraf Karsh Hamid
 
Hexagonal Architecture.pdf
Hexagonal Architecture.pdfHexagonal Architecture.pdf
Hexagonal Architecture.pdfVladimirRadzivil
 
Micro services vs Monolith Architecture
Micro services vs Monolith ArchitectureMicro services vs Monolith Architecture
Micro services vs Monolith ArchitectureMohamedElGohary71
 
The Architecture of an API Platform
The Architecture of an API PlatformThe Architecture of an API Platform
The Architecture of an API PlatformJohannes Ridderstedt
 
Refactoring for Domain Driven Design
Refactoring for Domain Driven DesignRefactoring for Domain Driven Design
Refactoring for Domain Driven DesignDavid Berliner
 
Microservices architecture
Microservices architectureMicroservices architecture
Microservices architectureAbdelghani Azri
 
Microservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsMicroservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsAraf Karsh Hamid
 
(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive Overview(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive OverviewBob Killen
 
Apache Kafka in Financial Services - Use Cases and Architectures
Apache Kafka in Financial Services - Use Cases and ArchitecturesApache Kafka in Financial Services - Use Cases and Architectures
Apache Kafka in Financial Services - Use Cases and ArchitecturesKai Wähner
 
Microservice Architecture Patterns, by Richard Langlois P. Eng.
Microservice Architecture Patterns, by Richard Langlois P. Eng.Microservice Architecture Patterns, by Richard Langlois P. Eng.
Microservice Architecture Patterns, by Richard Langlois P. Eng.Richard Langlois P. Eng.
 
Domain Driven Design: Zero to Hero
Domain Driven Design: Zero to HeroDomain Driven Design: Zero to Hero
Domain Driven Design: Zero to HeroFabrício Rissetto
 
Monoliths and Microservices
Monoliths and Microservices Monoliths and Microservices
Monoliths and Microservices Bozhidar Bozhanov
 
Azure API Management
Azure API ManagementAzure API Management
Azure API ManagementDaniel Toomey
 
Domain Driven Design(DDD) Presentation
Domain Driven Design(DDD) PresentationDomain Driven Design(DDD) Presentation
Domain Driven Design(DDD) PresentationOğuzhan Soykan
 
Integration Patterns and Anti-Patterns for Microservices Architectures
Integration Patterns and Anti-Patterns for Microservices ArchitecturesIntegration Patterns and Anti-Patterns for Microservices Architectures
Integration Patterns and Anti-Patterns for Microservices ArchitecturesApcera
 

Was ist angesagt? (20)

Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservices
 
Microservices, Containers, Kubernetes, Kafka, Kanban
Microservices, Containers, Kubernetes, Kafka, KanbanMicroservices, Containers, Kubernetes, Kafka, Kanban
Microservices, Containers, Kubernetes, Kafka, Kanban
 
Hexagonal Architecture.pdf
Hexagonal Architecture.pdfHexagonal Architecture.pdf
Hexagonal Architecture.pdf
 
Micro services vs Monolith Architecture
Micro services vs Monolith ArchitectureMicro services vs Monolith Architecture
Micro services vs Monolith Architecture
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
The Architecture of an API Platform
The Architecture of an API PlatformThe Architecture of an API Platform
The Architecture of an API Platform
 
Refactoring for Domain Driven Design
Refactoring for Domain Driven DesignRefactoring for Domain Driven Design
Refactoring for Domain Driven Design
 
Microservices architecture
Microservices architectureMicroservices architecture
Microservices architecture
 
Microservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsMicroservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native Apps
 
(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive Overview(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive Overview
 
Apache Kafka in Financial Services - Use Cases and Architectures
Apache Kafka in Financial Services - Use Cases and ArchitecturesApache Kafka in Financial Services - Use Cases and Architectures
Apache Kafka in Financial Services - Use Cases and Architectures
 
Microservices
MicroservicesMicroservices
Microservices
 
Serverless
ServerlessServerless
Serverless
 
DevOps introduction
DevOps introductionDevOps introduction
DevOps introduction
 
Microservice Architecture Patterns, by Richard Langlois P. Eng.
Microservice Architecture Patterns, by Richard Langlois P. Eng.Microservice Architecture Patterns, by Richard Langlois P. Eng.
Microservice Architecture Patterns, by Richard Langlois P. Eng.
 
Domain Driven Design: Zero to Hero
Domain Driven Design: Zero to HeroDomain Driven Design: Zero to Hero
Domain Driven Design: Zero to Hero
 
Monoliths and Microservices
Monoliths and Microservices Monoliths and Microservices
Monoliths and Microservices
 
Azure API Management
Azure API ManagementAzure API Management
Azure API Management
 
Domain Driven Design(DDD) Presentation
Domain Driven Design(DDD) PresentationDomain Driven Design(DDD) Presentation
Domain Driven Design(DDD) Presentation
 
Integration Patterns and Anti-Patterns for Microservices Architectures
Integration Patterns and Anti-Patterns for Microservices ArchitecturesIntegration Patterns and Anti-Patterns for Microservices Architectures
Integration Patterns and Anti-Patterns for Microservices Architectures
 

Ähnlich wie Modeling microservices using DDD

Designing microservices part2
Designing microservices part2Designing microservices part2
Designing microservices part2Masashi Narumoto
 
Achieve business agility with Cloud APIs, Cloud-aware Apps, and Cloud DevOps ...
Achieve business agility with Cloud APIs, Cloud-aware Apps, and Cloud DevOps ...Achieve business agility with Cloud APIs, Cloud-aware Apps, and Cloud DevOps ...
Achieve business agility with Cloud APIs, Cloud-aware Apps, and Cloud DevOps ...WSO2
 
Pros & Cons of Microservices Architecture
Pros & Cons of Microservices ArchitecturePros & Cons of Microservices Architecture
Pros & Cons of Microservices ArchitectureAshwini Kuntamukkala
 
Introduction to PaaS
Introduction to PaaSIntroduction to PaaS
Introduction to PaaSChris Haddad
 
Micro services - Practicalities & things to watch out for
Micro services - Practicalities & things to watch out forMicro services - Practicalities & things to watch out for
Micro services - Practicalities & things to watch out forParthiban J
 
Achieve business agility with Cloud APIs, Cloud-aware Apps, and Cloud DevOps ...
Achieve business agility with Cloud APIs, Cloud-aware Apps, and Cloud DevOps ...Achieve business agility with Cloud APIs, Cloud-aware Apps, and Cloud DevOps ...
Achieve business agility with Cloud APIs, Cloud-aware Apps, and Cloud DevOps ...Chris Haddad
 
Microservice.net by sergey seletsky
Microservice.net by sergey seletskyMicroservice.net by sergey seletsky
Microservice.net by sergey seletskySergey Seletsky
 
Chapter 1 & 2 - Introduction-to-Cloud-Computing.pptx
Chapter 1 & 2 - Introduction-to-Cloud-Computing.pptxChapter 1 & 2 - Introduction-to-Cloud-Computing.pptx
Chapter 1 & 2 - Introduction-to-Cloud-Computing.pptxhaileysuszelalem
 
Cloud Computing Introduction and Awareness
Cloud Computing Introduction and AwarenessCloud Computing Introduction and Awareness
Cloud Computing Introduction and Awarenesswlammert
 
Modern Software Architecture - Cloud Scale Computing
Modern Software Architecture - Cloud Scale ComputingModern Software Architecture - Cloud Scale Computing
Modern Software Architecture - Cloud Scale ComputingGiragadurai Vallirajan
 
Cloudhnologysstecociat
CloudhnologysstecociatCloudhnologysstecociat
CloudhnologysstecociatAnne Starr
 
Microservices architecture
Microservices architectureMicroservices architecture
Microservices architectureMohammad Dameer
 
Lighthouse20100120
Lighthouse20100120Lighthouse20100120
Lighthouse20100120sureddy
 
dtechnClouologyassociatepart2
dtechnClouologyassociatepart2dtechnClouologyassociatepart2
dtechnClouologyassociatepart2Anne Starr
 
Tokyo Azure Meetup #5 - Microservices and Azure Service Fabric
Tokyo Azure Meetup #5 - Microservices and Azure Service FabricTokyo Azure Meetup #5 - Microservices and Azure Service Fabric
Tokyo Azure Meetup #5 - Microservices and Azure Service FabricTokyo Azure Meetup
 
ArchitectNow - Designing Cloud-Native apps in Microsoft Azure
ArchitectNow  -  Designing Cloud-Native apps in Microsoft AzureArchitectNow  -  Designing Cloud-Native apps in Microsoft Azure
ArchitectNow - Designing Cloud-Native apps in Microsoft AzureKevin Grossnicklaus
 

Ähnlich wie Modeling microservices using DDD (20)

Designing microservices part2
Designing microservices part2Designing microservices part2
Designing microservices part2
 
Achieve business agility with Cloud APIs, Cloud-aware Apps, and Cloud DevOps ...
Achieve business agility with Cloud APIs, Cloud-aware Apps, and Cloud DevOps ...Achieve business agility with Cloud APIs, Cloud-aware Apps, and Cloud DevOps ...
Achieve business agility with Cloud APIs, Cloud-aware Apps, and Cloud DevOps ...
 
Pros & Cons of Microservices Architecture
Pros & Cons of Microservices ArchitecturePros & Cons of Microservices Architecture
Pros & Cons of Microservices Architecture
 
Introduction to PaaS
Introduction to PaaSIntroduction to PaaS
Introduction to PaaS
 
Micro services
Micro servicesMicro services
Micro services
 
Micro services - Practicalities & things to watch out for
Micro services - Practicalities & things to watch out forMicro services - Practicalities & things to watch out for
Micro services - Practicalities & things to watch out for
 
Achieve business agility with Cloud APIs, Cloud-aware Apps, and Cloud DevOps ...
Achieve business agility with Cloud APIs, Cloud-aware Apps, and Cloud DevOps ...Achieve business agility with Cloud APIs, Cloud-aware Apps, and Cloud DevOps ...
Achieve business agility with Cloud APIs, Cloud-aware Apps, and Cloud DevOps ...
 
Microservice.net by sergey seletsky
Microservice.net by sergey seletskyMicroservice.net by sergey seletsky
Microservice.net by sergey seletsky
 
Chapter 1 & 2 - Introduction-to-Cloud-Computing.pptx
Chapter 1 & 2 - Introduction-to-Cloud-Computing.pptxChapter 1 & 2 - Introduction-to-Cloud-Computing.pptx
Chapter 1 & 2 - Introduction-to-Cloud-Computing.pptx
 
652.ppt
652.ppt652.ppt
652.ppt
 
Cloud Computing Introduction and Awareness
Cloud Computing Introduction and AwarenessCloud Computing Introduction and Awareness
Cloud Computing Introduction and Awareness
 
Modern Software Architecture - Cloud Scale Computing
Modern Software Architecture - Cloud Scale ComputingModern Software Architecture - Cloud Scale Computing
Modern Software Architecture - Cloud Scale Computing
 
Cloudhnologysstecociat
CloudhnologysstecociatCloudhnologysstecociat
Cloudhnologysstecociat
 
Microservices architecture
Microservices architectureMicroservices architecture
Microservices architecture
 
Lighthouse 20100120
Lighthouse 20100120Lighthouse 20100120
Lighthouse 20100120
 
Lighthouse20100120
Lighthouse20100120Lighthouse20100120
Lighthouse20100120
 
Designing microservices
Designing microservicesDesigning microservices
Designing microservices
 
dtechnClouologyassociatepart2
dtechnClouologyassociatepart2dtechnClouologyassociatepart2
dtechnClouologyassociatepart2
 
Tokyo Azure Meetup #5 - Microservices and Azure Service Fabric
Tokyo Azure Meetup #5 - Microservices and Azure Service FabricTokyo Azure Meetup #5 - Microservices and Azure Service Fabric
Tokyo Azure Meetup #5 - Microservices and Azure Service Fabric
 
ArchitectNow - Designing Cloud-Native apps in Microsoft Azure
ArchitectNow  -  Designing Cloud-Native apps in Microsoft AzureArchitectNow  -  Designing Cloud-Native apps in Microsoft Azure
ArchitectNow - Designing Cloud-Native apps in Microsoft Azure
 

Mehr von Masashi Narumoto

Azure reference architectures
Azure reference architecturesAzure reference architectures
Azure reference architecturesMasashi Narumoto
 
Microservices design patterns
Microservices design patternsMicroservices design patterns
Microservices design patternsMasashi Narumoto
 
Azure Application Architecture Guide
Azure Application Architecture GuideAzure Application Architecture Guide
Azure Application Architecture GuideMasashi Narumoto
 
Cloud Design Pattern part2
Cloud Design Pattern part2Cloud Design Pattern part2
Cloud Design Pattern part2Masashi Narumoto
 
Cloud Design Pattern part1
Cloud Design Pattern part1Cloud Design Pattern part1
Cloud Design Pattern part1Masashi Narumoto
 
Designing apps for resiliency
Designing apps for resiliencyDesigning apps for resiliency
Designing apps for resiliencyMasashi Narumoto
 

Mehr von Masashi Narumoto (7)

Azure reference architectures
Azure reference architecturesAzure reference architectures
Azure reference architectures
 
Microservices design patterns
Microservices design patternsMicroservices design patterns
Microservices design patterns
 
Cloud design principles
Cloud design principlesCloud design principles
Cloud design principles
 
Azure Application Architecture Guide
Azure Application Architecture GuideAzure Application Architecture Guide
Azure Application Architecture Guide
 
Cloud Design Pattern part2
Cloud Design Pattern part2Cloud Design Pattern part2
Cloud Design Pattern part2
 
Cloud Design Pattern part1
Cloud Design Pattern part1Cloud Design Pattern part1
Cloud Design Pattern part1
 
Designing apps for resiliency
Designing apps for resiliencyDesigning apps for resiliency
Designing apps for resiliency
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 

Kürzlich hochgeladen (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 

Modeling microservices using DDD

  • 1. Masashi Narumoto Principal PM Lead AzureCAT patterns&practices Modeling microservices using Domain Driven Design
  • 2. Modeling microservices • How can I identify services? • How can I find service boundaries? • What is the right level of granularity? • How do I manage workflow? • How do I design inter-service communication? • How can I manage service dependency?
  • 4. Domain Driven Design • Approach to design software by modeling the business domain • Strategic modeling • Ubiquitous language • Domain • Bounded context • Context mapping • Tactical modeling • Model inside bounded context • Building block patterns • Architecture • Hexagonal, Layers, CQRS, Microservices
  • 5. When to use DDD? Source: Pattern of Enterprise Application Architecture: Martin Fowler
  • 6. Rough sketch of drone delivery domain
  • 7. Drone management Drone sharing 3rd party transportation Shipping (Core) Call center Accounts Drone management 3rd party transportation Call center Video surveillance Drone sharing Shipping Domain model Surveillance Accounts
  • 8. Context map – managing dependencies • Tightly vs. Loosely coupled mapping patterns • Shared kernel, Partnership, Conformist, Customer-supplier, Big Ball of Mud • Anti-corruption layer, Separate ways, Open host service, Published language Shared assets Code Data model Infrastructure Bounded context A Bounded context B Shared kernel pattern Shared assets
  • 9. Tactical modeling – Building blocks • Value object • Entity • Aggregate • Domain event • Domain Service • Application Service • Repository • Factory
  • 10. Value object • Immutable object w/ business logic • Benefits • API clarity • In-place validation • Error handling • Data handling • Testability • Used as API parameters, events, identity, etc. • Example: email address, phone number Power use of value objects in DDD by Dan Bergh Johnsson
  • 11. Entity • Has identity and lifecycle (not immutable) • Attributes and behavior • Can hold reference to other entities • Track changes using domain event (Event sourcing) • Example: User, Product
  • 12. Aggregates • Group of entities and value objects • Defines consistency boundary • Keep invariants in consistency boundary • Modify one aggregate per transaction • Size • Large aggregate causes R/W overhead and more chance for optimistic CC to fail • Split a large aggregate to multiple smaller ones • Smaller ones perform/scale better • Too small aggregates causes invariants to be fragmented in multiple aggregates • Relationship • Reference other aggregates by ID • Example: User account, Subscription
  • 13. Domain events • Events in business process • Events could be • Result of commands on Aggregates • Others • Event sourcing to store the history of events • Pub-Sub to notify multiple consumers • Example: Order placed, Delivery completed
  • 14. Domain services • Stateless operations across multiple aggregates • Implement business logic • Significant business process • Transform domain object from one composition to another • Calculate a value with inputs from multiple domain objects • Don’t overuse services • Example: Delivery scheduling process
  • 15. Application Service • Client of the domain service • No business logic • Typical tasks • Task coordination of use case flow • Assemble and send DTO over the wire • Create view model as resources in RESTful interface • Ensure ACID transactions • User authentication • Keep application service thin • Example: User authentication, Transferring DTO
  • 17. Identify Microservices Drone Scheduler Drone ID Req Delivery History Delivery Events Delivery Gateway Status ADLS Cosmos Cassandra
  • 18. Identify Microservices Drone Scheduler Drone ID Req Delivery History Delivery Events Delivery Gateway Status Drone Delegating to remote service Other bounded context
  • 20. User interface Applicationservices Aggregates Aggregates Events Applicationservices& Infrastructure DTO Application services & Infrastructure Identity provider Remote services Application services & Infrastructure Domainservices
  • 21. Find service boundary • Bounded context is the service boundary • BC is a linguistic boundary • Analyze building blocks • Aggregate, Domain Service, App Service are good candidates for microservices • Break down further per each service characteristics • Lifecycle (Rate of change) • Quality attributes • Technology used • Team
  • 22. Verify service granularity • Responsibility • Single responsibility • Lifecycle • Sharing the fate • Team size • 2 pizza rule • Dependency • No chatty calls between services • Other metrics • KPI such as velocity, team productivity, management cost etc. • Too small granularity causes issues • Communication overhead • Tight coupling • Lock-step deployment • Data consistency
  • 23. Designing services for drone delivery
  • 24. Process of designing microservices using DDD Accounts Drone management 3rd party transportation Call center Video surveillance Drone sharing Drone management Drone sharing 3rd party transportation Shipping (Core) Call center Shipping Surveillance Accounts Bounded context Aggregate Aggregate Aggregate Domain Service Domain ServiceAggregate Application Service Aggregate Event Domain model Domain building blocks Service mapping Shipping Drone Package Delivery DeliveryScheduler DeliverySupervisor Account 3rd party transportation Authentication Service in BC Service in BC Service In BC Service In BC Service outside Service outside Service outside Service outside Further refinement Breakdown per BC Service interaction design DeliveryScheduler Package Drone Delivery Mobile app Query Delivery History DeliveryEvents RequestEvents GW Status 3rd party Service Account Service DroneMgmt Service AAD Account Service Auth Service 3rd party transportation Account RequestHandler Delivery Analysis Archive Supervisor Failed ops Drone events
  • 25. Ubiquitous language to model each domain
  • 26. Drone management Drone sharing 3rd party transportation Shipping (Core) Call center Accounts Drone management 3rd party transportation Call center Video surveillance Drone sharing Shipping Context map – Drone delivery service Surveillance Accounts Shipping
  • 27. Tactical patterns in shipping domain Shipping Drone History Delivery DeliveryScheduler DeliverySupervisor Account 3rd party transportation Authentication Aggregate Domain service Delivery event Event
  • 28. Microservices in shipping domain Shipping Drone History Delivery DeliveryScheduler DeliverySupervisor Account 3rd party transportation Authentication DeliveryScheduler DeliverySupervisorHistory Authentication Drone Account 3rd party transportation Microservices Microservices In different BC Delivery event Delivery
  • 29. Scheduler Package Drone Delivery Mobile app Query Delivery History DeliveryEvents RequestEvents GW Status 3rd party Service Account Service DroneMgmt Service Further breakdown AAD Account Service Auth Service 3rd party transportation Account Ingestion Delivery Analysis Archive Supervisor Failed ops Drone events Too much responsibility Different scalability Dealing with failure
  • 30. Scheduler Package Drone Delivery Mobile app Query Delivery History RequestEvents GW Status 3rd party Service Account Service DroneMgmt Service Design patterns AAD Auth Service 3rd party transportation Account Ingestion Delivery Analysis Archive Supervisor Drone events Load levelingGW- routing Throttling Circuit breaker Bulkhead Sidecar GW- offloading Event sourcing Ambassador Materialized View Scheduler-agent-Supervisor

Hinweis der Redaktion

  1. Modeling software is a challenge. Modeling MSA is even harder. In modeling process, you need to answer these questions. Netflix runs 800 microservices. Uber runs 500. How can we find these services out on the drone delivery business? Changing boundaries are very expensive process.
  2. DDD can give you answers to all of these questions.
  3. In a nutshell, it’s an approach to design software by putting model as a center of the process. 2 different kinds of modeling, strategic and tactical. It can be applied to different kinds of architecture styles. A3G is a good place to learn these arch styles.
  4. Context map shows mapping among bounded context as well as domains and BC Domain represents problem space BC represents solution space
  5. Design time: Build, test, release If you expose language specific format or custom class/interface, it creates dependencies If you share data schema, library package, framework, etc. it creates dependencies If you share messaging infrastructure, storage it creates dependencies We should mitigate the area of shared kernel. Published language = Open API doc. You can mitigate the shared area by using nuget package etc.
  6. VO is immutable, there’s no history maintained. Can be used as parameter, event https://www.infoq.com/presentations/Value-Objects-Dan-Bergh-Johnsson Phone number Extract it out from an string argument Is it valid? Area code?
  7. P357: 70% of aggregates have one root entity + value object, 30% have 2 to 3 entities. Account = Admin + Members + Organization + Credit + Status
  8. Entities in aggregates have lifecycle. You may want to maintain the history of their status.
  9. DTO assembler to create DTO from domain object DTO is app specific, Value object is domain specific
  10. What’s the difference between microservices and their components? Should API layer a microservice?
  11. Team size = 2,3 upto 5,6 Lock-step deployment
  12. these are the considerations that you may going further down. Team size should be 2 to 6 guys. small teams make it easier to communicate more effectively rather than more, to stay decentralized and moving fast, and encourage high autonomy and innovation. http://blog.idonethis.com/two-pizza-team/ Too coarse grained causes dependency issues in build, release Too small grained causes overhead in communication, management, consistency It’s not like the more is the better.
  13. Easier said than done so we started our own project to show how to model service around business. Simply put, this service is to deliver good for you in a matter of minutes using drones.
  14. It doesn’t need to be mechanical translation by finding nouns, and verbs. It’s an iterative process to extract entities, service, aggregates, events etc.
  15. Context map shows mapping among bounded context as well as domains and BC Domain represents problem space BC represents solution space
  16. There’s no mechanical way to make decisions. Some aggregates deserve to be microservices, others don’t. Some aggregates should count on the ones in different BC. Responsibility of aggregates Delta Team size Dependency Latency
  17. How delivery service know its status? Is it coming from delivery mgmt service? (pull or push) Do we want to merge requestHandler and GW? GW does only token checking, delegate auth to auth service in account BC Why it has Package, Drone, Delivery as service but no service for account and 3rd party? Do we need them? Why doesn’t delivery service contain drone and package aggregate? Does drone need persistent storage or cache? What is the best API style? Depending on the responsibility and latency req of the drone service in this context, it can be just caching status Every event from drone come via EventHub to only DroneMgmt or + Delivery service? Scheduler does validation and return 501 (bad request) if it fails Account service subscribes delivery events and do the following once it’s completed Collect ratings, send emails, schedule payment
  18. How delivery service know its status? Is it coming from delivery mgmt service? (pull or push) Do we want to merge requestHandler and GW? GW does only token checking, delegate auth to auth service in account BC Why it has Package, Drone, Delivery as service but no service for account and 3rd party? Do we need them? Why doesn’t delivery service contain drone and package aggregate? Does drone need persistent storage or cache? What is the best API style? Depending on the responsibility and latency req of the drone service in this context, it can be just caching status Every event from drone come via EventHub to only DroneMgmt or + Delivery service? Scheduler does validation and return 501 (bad request) if it fails Account service subscribes delivery events and do the following once it’s completed Collect ratings, send emails, schedule payment