Microservices &
Reactive Systems
Lessons learned
About me ...
- Passionate software engineer
- Focused mainly on JVM
- Interested in all software development phases
- Having erethic opinions
- Non politically correct, but just correct …
- Personal belief: “living in a distributed and reactive full of actors system”
@bogdan.dina03
Posting on: @dinabogdan03
Agenda
1. “The mess we’re in”
2. The need for microservices
3. Monoliths vs microservices?
4. The impact of the Reactive Manifesto
5. Principles of good design in a microservices or reactive world
6. Today’s conclusions and more
7. The future stands in front of us
“The mess we’re in”
“The mess we’re in”
- Microservices
“The mess we’re in”
- Microservices
- Miniservices
“The mess we’re in”
- Microservices
- Miniservices
- Self-Contained Systems (SCS)
“The mess we’re in”
- Microservices
- Miniservices
- Self-Contained Systems (SCS)
- Reactive microservices
“The mess we’re in”
- Microservices
- Miniservices
- Self-Contained Systems (SCS)
- Reactive microservices
- Reactive microsystems
“The mess we’re in”.
What about it?
“The mess we’re in”. What about it?
- Focus on the fundamental to-be followed ideas
“The mess we’re in”. What about it?
- Focus on the fundamental to-be followed ideas
- Think in terms of patterns
“The mess we’re in”. What about it?
- Focus on the fundamental to-be followed ideas
- Think in terms of patterns
- Forget about buzzy terminology
“The mess we’re in”. What about it?
- Focus on the fundamental to-be followed ideas
- Think in terms of patterns
- Forget about buzzy terminology
- Strive for achieving responsiveness, scalability and,
fault-tolerance
The need for
microservices
The need for microservices
Q: Why did microservices appeared?
The need for microservices
Q: Why did microservices appeared?
A: Because of monoliths!
The need for microservices
Q: Why did microservices appeared?
A: Because of monoliths!
* Don’t forget about “Monolith first” approach!
The need for microservices
Q: Why did microservices appeared?
A: Because of monoliths!
* Don’t forget about “Monolith first” approach!
** Avoid “Big Ball of Mud”!
The need for microservices
Q: Why did microservices appeared?
A: Because of monoliths!
* Don’t forget about “Monolith first” approach!
** Avoid “Big Ball of Mud”!
*** Avoid “Distributed Big Ball of mud”!
The need for
microservices - Not
agree?
The need for microservices - An iteration
The need for microservices - The next iteration
Monoliths vs
Microservices?
Monoliths vs Microservices? Adopting monoliths
again?
- The initial incarnation of microservices failed
Monoliths vs Microservices? Adopting monoliths
again?
- The initial incarnation of microservices failed
- “Correctly built distributed systems” should
raise an alarm!
Monoliths vs Microservices?
“[...] a monolithic application puts all its functionality into a single process and
scales by replicating the monolith on multiple servers”,
whilst
“[...] a microservices architecture puts each element of functionality into a separate
service and scales by distributing these services across servers, replicating as
needed”.
Martin Fowler
Monoliths vs
Microservices? Main
ideas
Monoliths vs Microservices? Main ideas
- Start with a monolith
Monoliths vs Microservices? Main ideas
- Start with a monolith
- Don’t forget to modularize it (Domain-Driven Design)
Monoliths vs Microservices? Main ideas
- Start with a monolith
- Don’t forget to modularize it
- Decompose into separate components when needed
(microservices)
The impact of
Reactive Manifesto
The impact of Reactive Manifesto
The impact of Reactive Manifesto
- Published in 2014
The impact of Reactive Manifesto
- Published in 2014
- Rethinking the old distributed systems
The impact of Reactive Manifesto
- Published in 2014
- Rethinking the old distributed systems
- Empowers correctly building of distributed systems
Principles of good
design in a
microservices or
reactive world
10 Principles of good design
1. Asynchronicity
2. Autonomy
3. Bulkheading
4. Single Responsibility Principle
5. Stateless
6. Distribution transparency
7. Past nature of information
8. Eventual consistency
9. Monitoring, observability and
distributed tracing
10. Recovering from errors
Embrace
Asynchronicity!
But Why?
Embrace Asynchronicity! But why?
Embrace Asynchronicity! But why?
- Loose coupling
Embrace Asynchronicity! But why?
- Loose coupling
- Concurrency in time
Embrace Asynchronicity! But why?
- Loose coupling
- Concurrency in time
- Mobility and distribution in space
Embrace Asynchronicity! But why?
- Loose coupling
- Concurrency in time
- Mobility and distribution in space
- Responsiveness and elasticity
Synchronous vs Asynchronous
Synchronous vs Asynchronous
Act autonomously
How to gain autonomy?
How to gain autonomy?
- The isolation level between them
How to gain autonomy?
- The isolation level between them
- The capacity to act independently in doing business
tasks
How to gain autonomy?
- The isolation level between them
- The capacity to act independently in doing business tasks
- The capacity to fail independently
How to gain autonomy?
- The isolation level between them
- The capacity to act independently in doing business tasks
- The capacity to fail independently
- The collaboration level between microservices
About autonomy when monolith vs microservices
Monolith vs microservices - autonomy POV
In the case of monolith:
- multiple software constructions
deployed as a single deployment unit
- no isolation between them
- components are not acting
autonomously
- if one fails => the rest will also fail
Monolith vs microservices - autonomy POV
In the case of monolith:
- multiple software constructions
deployed as a single deployment unit
- no isolation between them
- components are not acting
autonomously
- if one fails => the rest will also fail
In the case of microservices:
- individual deployment units
- isolated components
- autonomy
- if one will fail => the rest of other will
still be working
Bulkheading
Bulkheading
- it covers both monoliths and microservices
Bulkheading
- it covers both monoliths and microservices
- isolates application into separate pools => if one fails, the
rest will not
Bulkheading
- it covers both monoliths and microservices
- isolates application into separate pools => if one fails, the rest
will not
- coming from ships
Single Responsibility
Principle
A microservice asks: What is my responsibility ?!
- a microservice/monolith’s module must have a
single responsibility (SRP)
A microservice asks: What is my responsibility ?!
- a microservice/monolith’s module must have a single
responsibility (SRP)
- better decoupling
A microservice asks: What is my responsibility ?!
- a microservice/monolith’s module must have a single
responsibility (SRP)
- better decoupling
- higher autonomy degree
Stateless
Just take care of your own state!!!
- a microservice/monolith’s module takes responsibility
for its own state
Just take care of your own state!!!
- a microservice/monolith’s module takes responsibility for
its own state
- Law of Demeter
Just take care of your own state!!!
- a microservice/monolith’s module takes responsibility for
its own state
- Law of Demeter
- Tell, don’t ask
Law of Demeter
Tell, don’t ask!
Leads us to ...
- commands
- events
Distribution
transparency
Distribution transparency
- fundamental property of modern distributed
systems
Distribution transparency
- fundamental property of modern distributed systems
- components can be moved around
Distribution transparency
- fundamental property of modern distributed systems
- components can be moved around
- Location Transparency => 1/7
“Information is always
from the past” - Jonas
Bonér
Past nature of information
- think in terms of past events containing pieces of
information
Past nature of information
- think in terms of past events containing pieces of
information
- avoid querying for “current” state
Past nature of information
- think in terms of past events containing pieces of
information
- avoid querying for “current” state
- embrace commands (eg: “enrollNewCustomer”)
Past nature of information
- think in terms of past events containing pieces of
information
- avoid querying for “current” state
- send and receive commands (eg:
“enrollNewCustomer”)
- react to and emit events (eg: “customerEnrolled”)
Commands & Events
- loose coupling
- asynchronous communication
- isolation
Eventual Consistency
& Transactions
What about transactions?
- leverage Domain-Driven Design
What about transactions?
- leverage Domain-Driven Design
- one aggregate/microservice or monolith’s module
What about transactions?
- leverage Domain-Driven Design
- one aggregate/microservice or monolith’s module
- aggregate’s rule of thumb about transactions
What about transactions?
- leverage Domain-Driven Design
- one aggregate/microservice or monolith’s module
- aggregate’s rule of thumb about transactions
- forget about 2PC and heuristic decisions
What about transactions? More ...
- business processes involve more than a single
component
What about transactions? More ...
- business processes involve more than a single
component
- avoid inconsistent states
What about transactions? Solutions!
- SAGA Pattern/long-running business transaction
pattern
What about transactions? Solutions!
- SAGA Pattern/long-running business transaction pattern
- pairs like <Transaction, Compensation>
SAGA Pattern
Async but … I can’t
find the trace!
Distributed tracing
- async => finding trace :(
Distributed tracing
- async => finding trace :(
- leverage Distributed Tracing
Am I under
observation?
Someone should
supervise me! I could
die in thread.SLEEP()
Monitoring & Observability
- binary state: working or failed
Monitoring & Observability
- binary state: working or failed
- actively monitor and observe components
Monitoring & Observability
- binary state: working or failed
- actively monitor and observe components
- SRE practices: SLIs, SLOs & SLAs and error budgets
Monitoring & Observability
- binary state: working or failed
- actively monitor and observe components
- SRE practices: SLIs, SLOs & SLAs and error budgets
- preemptively eliminate possible failures
What about recovering
from failure?
Recovering from failure
- reactive systems must be resilient
Recovering from failure
- reactive systems must be resilient
- not avoid failures, but embrace them
Recovering from failure
- reactive systems must be resilient
- not avoid failures, but embrace them
- replication
Recovering from failure
- reactive systems must be resilient
- not avoid failures, but embrace them
- replication
- isolation
Recovering from failure
- reactive systems must be resilient
- not avoid failures, but embrace them
- replication
- isolation
- delegation
Recovering from failure
- reactive systems must be resilient
- not avoid failures, but embrace them
- replication
- isolation
- delegation
- elasticity matters
The hard part comes
now ...
Today’s conclusions
- starting point for creating individual microservices
Today’s conclusions
- starting point for creating individual microservices
- easy to reason with
Today’s conclusions
- starting point for creating individual microservices
- easy to reason with
- “A microservice is not of much use, they always come
as systems” - Jonas Bonér
Systems of microservices includes ...
- coordination (orchestration vs choreography)
Systems of microservices includes ...
- coordination (orchestration vs choreography)
- security of the entire system
Systems of microservices includes ...
- coordination (orchestration vs choreography)
- security of the entire system
- replication
Systems of microservices includes ...
- coordination (orchestration vs choreography)
- security of the entire system
- replication
- data consistency
Systems of microservices includes ...
- coordination (orchestration vs choreography)
- security of the entire system
- replication
- data consistency
- deployment models
Systems of microservices includes ...
- coordination (orchestration vs choreography)
- security of the entire system
- replication
- data consistency
- deployment models
- integration models
The future stands in
front of us
What brings the future
What brings the future
- ACID 2.0
What brings the future
- ACID 2.0
- event streaming
What brings the future
- ACID 2.0
- event streaming
- managing state
What brings the future
- ACID 2.0
- event streaming
- managing state
- cloud-native deployment strategies
What brings the future
- ACID 2.0
- event streaming
- managing state
- cloud-native deployment strategies
- service mesh
Thank you !
● Don’t forget to follow me on @dinabogdan03
● Don’t forget to read my articles on @bogdan.dina03

Microservices &amp; reactive systems