In order to explain certain astronomical observations, physicists created the mysterious concepts of dark energy and dark matter.
Dark energy is a repulsive force.
It’s an anti-gravity that is forcing matter apart and accelerating the expansion of the universe.
Dark matter has the opposite attraction effect.
Although it’s invisible, dark matter has a gravitational effect on stars and galaxies.
In this presentation, you will learn how these metaphors apply to the microservice architecture.
I describe how there are multiple repulsive forces that drive the decomposition of your application into services.
You will learn, however, that there are also multiple attractive forces that resist decomposition and bind software elements together.
I describe how as an architect you must find a way to balance these opposing forces.
2. @crichardson
What you will learn
When defining a microservice
architecture
you must resolve
the competing forces of
attraction and repulsion
between subdomains
5. @crichardson
Agenda
• Dark energy, dark matter and subdomains
• Dark energy and repulsion
• Dark matter and attraction
• Resolving repulsive and attractive forces
6. @crichardson
Microservice architecture =
architectural style
Small team
Loosely coupled
Independently deployable
<15 minute lead time
Service B
Service A
Service C
API Gateway
Owns
Owns
Owns
Deployment pipeline Production
7. @crichardson
How to define a Microservice
Architecture…
Application
≪subdomain≫
Customer
≪aggregate≫
Customer
≪subdomain≫
Order
≪aggregate≫
Order
createCustomer()
createOrder()
findOrder()
findOrderHistory()
System operations
Distill
Requirements
Event storming
Functional requirements
As a consumer
I want to place an Order
So that I can ….
As a Restaurant
I want to accept an Order
So that I can ….
User stories
• SLA: Reliability/Latency
• Scalability
• …
System quality attributes
The “requests” - read/write aggregates
8. @crichardson
Application
… how to define a
Microservice Architecture
Application
≪subdomain≫
Customer
≪aggregate≫
Customer
≪subdomain≫
Order
≪aggregate≫
Order
createCustomer()
createOrder()
findOrder()
findOrderHistory()
System operations Service
Service
Service
≪subdomain≫
≪subdomain≫
≪subdomain≫
≪subdomain≫
How to
group
subdomains
to form
services?
10. @crichardson
Dark energy, dark matter and
services
≪subdomain≫
Customer
≪aggregate≫
Customer
≪subdomain≫
Order
≪aggregate≫
Order
Attraction
Repulsion
Generated by
system operations
Team-sized services
…
Dark energy: an anti-
gravity that’s accelerating
the expansion of the
universe
Dark matter: an invisible
matter that has a
gravitational effect on stars
and galaxies.
https://www.nasa.gov/feature/goddard/2020/new-hubble-data-explains-missing-dark-matter
Transactional coupling
Runtime coupling
Design time coupling
…
11. @crichardson
Attraction vs repulsion at
every level
Customer Service
Order Service
Order Service
«Subdomain»
Orders
«Subdomain»
Customers
VS. «Subdomain»
Orders
«Subdomain»
Customers
«Subdomain» Orders
«Aggregate»
Order
«Subdomain» Customers
«Aggregate»
Customer
«Subdomain» Orders
«Aggregate»
Order
«Aggregate»
Customer
VS.
create()
reserveCredit()
releaseCredit()
name
creditLimit
availableCredit
«Aggregate»
Customer
create()
name
«Aggregate»
Customer
reserveCredit()
releaseCredit()
creditLimit
availableCredit
«Aggregate»
CustomerCredit
VS.
Team size
13. @crichardson
Agenda
• Dark energy, dark matter and subdomains
• Dark energy and repulsion
• Dark matter and attraction
• Resolving repulsive and attractive forces
14. Dark energy = anti-gravity
force
https://hubblesite.org/contents/media/images/2001/09/1034-Image.html?news=true
https://genius.com/Barenaked-ladies-the-big-bang-theory-lyrics
Expected
deceleration
Unexpected
acceleration!
Our whole universe was in a
hot, dense state
Then nearly fourteen billion
years ago expansion
started….
15. @crichardson
Repulsive forces subdomains
in different services
Service
Service
Module A
«Aggregate»
X
Module B
«Aggregate»
Y
Team-sized services
15 minute lead time
Diversity of technology stacks
Increasing scalability
Different regulatory requirements
Different SLAs
18. @crichardson
<15 minute lead time
@mipsytipsy
https://speakerdeck.com/charity/cd?slide=17
Service
Service
Subdomain
Subdomain
Subdomain
Shorter
lead time
Simpler
build
Longer
lead time
More
complex
build* * Parallelizing building/testing partially helps
19. @crichardson
Service
Tech. Stack
B
Service
Tech. Stack
A
Service
Tech. Stack
Requirement to use different
technology stacks
Subdomain
A
Subdomain
A
Subdomain
B
Subdomain
B
Single technology stack
Upgrade together
Separate technology stacks
Right tool for the job
Upgrade independently
versus
21. @crichardson
Separate by regulatory
requirements
• Quality Management System that complies with ISO 13485
• Software development lifecycle processes like ISO/IEC 62304
Obstacles to DevOps continuous integration/deployment
Canary deployments are generally a bad idea
22. @crichardson
Service
Service
Service
Freedom to use different
development processes
SaMD
Subdomain
SaMD
Subdomain
Other
Subdomain
Other
Subdomain
ISO 13485
ISO/IEC 62304
ISO 13485
ISO/IEC 62304 DevOps
Slower Faster
25. @crichardson
Agenda
• Dark energy, dark matter and subdomains
• Dark energy and repulsion
• Dark matter and attraction
• Resolving repulsive and attractive forces
26. @crichardson
About dark matter: orbital
velocity of stars
https://en.wikipedia.org/wiki/Galaxy_rotation_curve
Most mass
Violates Kepler’s 3rd law
27. About Dark matter
It’s invisible
Its composition is unknown
85% of the matter in the universe
Has a gravitational effect
Responsible for stars orbiting at higher
velocities
Responsible for the formation of galaxies:
Early universe was very hot
Dark matter was immune to radiation
pressure
Clumped together
https://en.wikipedia.org/wiki/Dark_matter
28. @crichardson
System operations generate attraction
forces between subdomains
Create
Order()
Order Subdomain
Customer Subdomain
reserveCredit()
createOrder()
Customer
Order
Application
Runtime coupling
Design time coupling
Transactional coupling
Communication cost
Data access cost
Generate
Forces vary
for each
operation
30. @crichardson
ACID transactions the span services
are problematic => use sagas
Order
Service
Customer
Service
POST /order
Credit Reserved
Order created
Order events
Customer events
https://microservices.io/patterns/data/saga.html
BUT Sagas are more complex and require:
• Compensating transactions
• Countermeasures to handle ACD
32. @crichardson
Multi-service command: higher
latency and lower availability
Customer
Service
Order
Service
Order
Subdomain
Customer
Subdomain
POST /orders
Response
reserveCredit()
Response
Lower availability
availability(createOrder) =
availability(OrderService) x
availability(CustomerService)
Higher latency
😢
Synchronous or
asynchronous!
35. @crichardson
Design time coupling: risk of
lock step changes
Order
Subdomain
Customer
Subdomain
reserveCredit()
createOrder()
Customer
Order
Design time coupling
Minimize with careful design
BUT
You can’t always eliminate it
Risk of lock step changes
API
Knows about
available credit
36. @crichardson
Key distributed data patterns
involve design-time coupling
API
Composer
Order
Service
Customer
Service
Saga
Coordinator
Order
Service
Customer
Service
CQRS
View
Order
Service
Customer
Service
https://microservices.io/patterns/data/saga.html
https://microservices.io/patterns/data/cqrs.html
https://microservices.io/patterns/data/api-composition.html
Coupled
to services
Coupled
37. @crichardson
Order
Service
Minimize design-time coupling
between services
Service
Order
Subdomain
Customer
Subdomain
Customer
Service
Order
Subdomain
Customer
Subdomain
1. Change
2. Change
3. Build
4. Test
5. Deploy
1. Change
3. Build
4. Test
5. Deploy
3. Build
4. Test
5. Deploy
API
Straightforward
Complicated
2. Change
1. Change
2. Change
38. @crichardson
Agenda
• Dark energy, dark matter and subdomains
• Dark energy and repulsion
• Dark matter and attraction
• Resolving repulsive and attractive forces
41. @crichardson
Service
Define team sized services but
how?
Vs.
Service
Complicated
Order Mgmt
Simple
Customer Mgmt
Complicated
Fulfillment
findOrder()
createOrder()
Service
Service
Complicated
Order Mgmt
Simple
Customer Mgmt
Complicated
Fulfillment
findOrder()
createOrder()
Need to analyze the forces….
42. @crichardson
Service
Service
The gravitational forces depend
on the (operation, subdomain)
Complicated
Order Mgmt
Simple
Customer Mgmt
Complicated
Fulfillment
findOrder()
createOrder()
Command/
Frequent/
Higher SLA
Query/
Less frequent/
Lower SLA
Tight
Loose
Loose
reserveCredit()
createOrder()
createShipment()