In this talk i'll try to show you how DDD can help us solve some of the hardest challenges in architecting a micro-services eco-system:
1. Making sure that things which change for same reason are co-located inside the same microservice.
2. Elegant and efficient event driven integration of microservices
2. #indoerswetrust
ABOUT ME
Erik Ashepa
● 10 years of software development and
management experience
● 5 years practicing DDD
● Currently R&D Group Manager @
Fiverr
3. #indoerswetrust
THIS PRESENTATION
Part 1: Bounded contexts and microservices
● Definitions
● Why split the monolith?
● How to do it?
● Examples
Part 2: Integrating microservices
● Definitions
● Why integrate?
● How to do it?
● Examples
5. #indoerswetrust
Domain-driven design (DDD)
an approach to developing software
for complex needs by deeply
connecting the implementation to an
evolving model of the core business
concepts
DEFINITIONS
7. #indoerswetrust
WHY?
Models should be designed to answer
specific questions and not be general
purpose do everything spaghetti
monsters.
Avoid big ball of mud
12. #indoerswetrust
Bounded contexts boundaries should
be driven by:
● Semantics (context and meaning in
different sub-domains)
● Business-processes steps or activities
● Preferably *not* data which can be
duplicated
PAGE TITLE
HOW?
21. #indoerswetrust
Properties of effective domain events
● Capture the intent of the user
● Always in the past tense.
● Naming aligned with the business
PAGE TITLE
HOW?
22. #indoerswetrust
INTEGRATING MICROSERVICES
Cascade command triggers using domain events and event handlers
1. Commands create events which are handled by event handlers (i.e: PlaceOrderCommand
triggers OrderPlacedEvent and handled by OrderPlacedEventHandler)
2. Publish events so other bounded contexts will get a chance to handle them.
24. #indoerswetrust
INTEGRATING MICROSERVICES
Synchronize State Changes
● Query database table directly.
● API for getting the latest version of an object. (/users/3/orders/1234)
● Use state captured on Domain Events
● Publish and Consume State Change Events (i.e: OrderCreated, OrderUpdated)
25. #indoerswetrust
TRANSPORTING DATA
How to publish Domain Evens and
Synchronize State between Microservices:
● Request Reply (RPC, REST)
● Publish and Subscribe (Message Broker)
26. #indoerswetrust
TRANSPORTING DATA
Request Reply (RPC, REST)
● Simple: Easy to set up and synchronous.
● No indirection: Services call each other explicitly.
● Temporal Coupling: Communicating services must be running to exchange information.
27. #indoerswetrust
TRANSPORTING DATA
Publish and Subscribe (Message Broker)
● Complex: More moving parts and asynchronous.
● Indirection: Services don’t call each other, they use an intermediary.
● No Temporal Coupling: Eventually communicating services will consume the information.
28. #indoerswetrust
EXAMPLES
● REST API for consuming domain events (/user/2/events)
● WebSocket API for consuming state change events (/user/2/sce/)
● REST API for querying user resource (/user/2/)
● Kafka topic for publishing and consuming domain events/state change events
● Database table for storing domain events (A.K.A event sourcing)