SlideShare a Scribd company logo
Reactive MicroServices
Leveraging Reactive principles
in a technology agnostic way
Lorenzo Nicora
Senior Consultant @ OpenCredo
@nicusX
https://opencredo.com/author/lorenzo
“Reactive” is…
Reactive
Semantically overloaded term
adj. “Readily responsive to stimulus” [Merrian-Webster dictionary]
From Latin “reagere”: act in return
Lorenzo Nicora Reactive μServices
Reactive as…
Reactive as
Reactive Manifesto
Lorenzo Nicora Reactive μServices
Reactive Manifesto
Lorenzo Nicora Reactive μServices
ü Responsive à Low latency
ü Resilient à Stay responsive on failure
ü Elastic à Scale as needed
ü Message-Driven à Asynchronous messages
as only communication between components
Simplifying
Lorenzo Nicora Reactive μServices
✗ No Blocking operation
✗ No Synchronization à No Contention
✗ No Resource hogging
Reactive Manifesto promotes
Decoupling and isolation in…
üTime à Concurrent processing
üSpace à Components location decoupling
Lorenzo Nicora Reactive μServices
Reactive as..
Akka Spring Boot
a set of
Architectural
Patterns and Principles
Not necessarily
related to
a specific technology
a set of technologies
Lorenzo Nicora Reactive μServices
A set of architectural patterns and principles
applicable to MicroServices
ü Non-blocking processing
ü Message-based communication
ü Asynchronous delegation
ü Resilience: Isolation & Replication; Backpressure
ü Elasticity
ü Location transparency
Reactive as Architectural Patterns
Lorenzo Nicora Reactive μServices
a MicroService is..
• Communicate with others over the network
• Part of a distributed system
• Independently deployed
• Independently scalable
MicroServices
Lorenzo Nicora Reactive μServices
Macro level
at μService boundaries
Between Services; external resources
Across the MicroService Stack
Micro level
within the μService
Between internal components
Lorenzo Nicora Reactive μServices
Do not block threads
Never block a thread
doing nothing and
waiting for
an Input or a Response
Threads are limited resources
(Thread starving)
(React to Input / Response)
Lorenzo Nicora Reactive μServices
Non-blocking à Faster
Lorenzo Nicora Reactive μServices
Non-blocking Communication
Macro (at service boundaries)
✗ Limit Request/Response pattern
üOne-way messaging (fire and forget)
üPrefer messaging protocols rather than HTTP
Non-blocking
Lorenzo Nicora Reactive μServices
Non-blocking Communication and IO
Micro (within the Service)
✗ Limit blocking/direct method calls
üFutures, Promises, Callbacks
üInternal messaging (e.g. Actor model)
üNon-blocking IO and drivers
Non-blocking
Lorenzo Nicora Reactive μServices
Non-blocking + Blocking = Blocking
✗ Many resources only provide blocking API
• Prefer technologies with non-blocking API
✗ Do not block on a Future…
• To extract the result
• To handle exceptions
❗ Know where your thread come from
• Thread pools
Non-blocking pitfalls
Lorenzo Nicora Reactive μServices
Delegation
* External components
Delegate a task asynchronously
to other components*
Macro (at Service boundaries)
o Delegate tasks to other μServices
o Send Request as a Message
o When required, Response come back as a Message
Lorenzo Nicora Reactive μServices
Delegation
* Internal component
Delegate a task asynchronously
to other components*
Micro (within the Service)
o Execute sub-tasks in separate threads
• Futures/Promises, Callbacks…
o Run multiple tasks in parallel
Lorenzo Nicora Reactive μServices
Parallel Delegation
Lorenzo Nicora Reactive μServices
Resilience:
Stay responsive in face of failure
Resilience
Design expecting failure
Failure
happens!
Fail-Safe
Lorenzo Nicora Reactive μServices
• Failure (e.g. connection failure, timeout…)
• Unexpected event
• Not recoverable
• No meaningful response to your client
• Error (e.g. user input error)
• Expected condition
• A specific response to the client (your protocol)
Failure ≠ Error
Lorenzo Nicora Reactive μServices
Resilience: Isolation + Replication
Resilience à Isolation + Replication
Macro
o Deployment Isolation
o Bulkheads
• Prevent cascading failures
• Neither to peer services, nor upstream/downstream
Lorenzo Nicora Reactive μServices
Resilience à Isolation + Replication
o Replication
• Legacy (always valid) HA approach
• Multiple peer services
• Data Replication
Resilience: Isolation + Replication
Lorenzo Nicora Reactive μServices
Fail silent; Fail fast
then Recover, when possible
o Prevent cascading failures
o Isolate failing collaborators
• Downstream μServices
• External services
• Resources (DB…)
Resilience: Circuit Breakers
Lorenzo Nicora Reactive μServices
Expect Failure…
Resilience: Handle failure
… Handle Failure
Lorenzo Nicora Reactive μServices
Handle
Errors and Failures
separately
Consistently report Errors to your client
Error is part of your “protocol” (business logic)
Gracefully degrade on Failure
Avoid ”All or nothing” logic
à Partial Responses
Handling Failure
Lorenzo Nicora Reactive μServices
Explicitly set and handle timeouts
on every asynchronous interaction
Never rely on default
settings and handling
for timeouts
Timeouts - Failures
When collaboration is asynchronous (messaging)
a Failure becomes a Time-out
Lorenzo Nicora Reactive μServices
Prevent fast publishers
from overrunning slow consumers
✗ Drop messages (acceptable?)
✗ Cause catastrophic cascade failures
Back-pressure
Lorenzo Nicora Reactive μServices
Buffers overflow!
and will not save you
Back-pressure
à Backpressure
Consumer…
ü Give feedback to publisher
ü Drive the pace
Lorenzo Nicora Reactive μServices
Ability to scale when required
Macro
ü Scale services and resources
• Add/Remove VM, Container, Cluster nodes
❗ Scaling data (application state)
• Only Partitioning, Sharding
Elasticity
Scaling: an infrastructure concern,
but application must be designed for it
Lorenzo Nicora Reactive μServices
Your collaborator may be anywhere
Local or Remote
Architecture may evolve
Local à Remote
“There ain’t no such thing as a
transparent synchronous remotisation”
Async Messaging work the same local and remote
Location Transparency
Lorenzo Nicora Reactive μServices
You need to find your collaborator
o Service Discovery
• Dynamic service registration
• Heartbeat, Gossip, Health Check (is a service dead?)
• DNS
o Load Balancers
Location Transparency
Lorenzo Nicora Reactive μServices
Conclusions
Lorenzo Nicora Reactive μServices
ü Reactive as a set of
Architectural Patterns and Principles
Ø low latency/high throughput
Ø scale linearly
Ø resiliency
Ø …
ü When not using a ”Reactive” technology
apply discipline,
but still enforce Reactive Principles
ü Keep in mind when designing both…
Macro: μService architecture
Micro: internal software design
Conclusions
Lorenzo Nicora Reactive μServices
Reactive Manifesto: http://www.reactivemanifesto.org/
à Glossary http://www.reactivemanifesto.org/glossary
References
Lorenzo Nicora Reactive μServices
Q&A
Thanks.
Lorenzo Nicora Reactive μServices

More Related Content

PPTX
Event driven systems
PDF
Echidna, sistema de respuesta a incidentes open source [GuadalajaraCON 2013]
PDF
Messaging
PDF
From C to Q one event at a time: Event Sourcing illustrated
PDF
A visual introduction to Event Sourcing and CQRS
PDF
The Actor model: an alternative approach to concurrency
PDF
From Islands to Cities – Applications for Smart Energy Storage - Dr. Wolfram ...
PDF
Security, Privacy & Convenience – key drivers for mobile adoption from a cons...
Event driven systems
Echidna, sistema de respuesta a incidentes open source [GuadalajaraCON 2013]
Messaging
From C to Q one event at a time: Event Sourcing illustrated
A visual introduction to Event Sourcing and CQRS
The Actor model: an alternative approach to concurrency
From Islands to Cities – Applications for Smart Energy Storage - Dr. Wolfram ...
Security, Privacy & Convenience – key drivers for mobile adoption from a cons...

Viewers also liked (20)

PPT
Achieving best practice in delivering government information and services online
PPTX
Towards a Political Aesthetic of Everyday Life
PPT
Government Controlled Mobile VoIP
PPT
MGov2010
PPTX
Mobile Seva: Bringing Citizens and Government Together Through Mobiles, India
PDF
The importance of a mobile government
PPT
Mobile Governance Applications
PPTX
Zia Government Solutions from Paper to Mobile
PPTX
OECD GOV Observatory for Public Sector Innovation
PDF
ICT, Knowledge-based Society and Innovation 2.0
PPTX
OECD GOV Open government data
PDF
Google Apps for Government - GovLoop LIVE CHAT
PDF
Transcending e-Government: a Case of Mobile Government in Beijing
PPT
m-government & android application development
PDF
M-Government
PDF
Open Data Strategies & Mobile Government (GCC Perspective)
PPT
Government on the move: trends in mobile technology and how government can ge...
PDF
MOBILE SOLUTIONS GUIDE FOR GOVERNMENT
DOCX
E commerece,m-commerece & m-governance
PPTX
Empowering citizens and local government with mobile data
Achieving best practice in delivering government information and services online
Towards a Political Aesthetic of Everyday Life
Government Controlled Mobile VoIP
MGov2010
Mobile Seva: Bringing Citizens and Government Together Through Mobiles, India
The importance of a mobile government
Mobile Governance Applications
Zia Government Solutions from Paper to Mobile
OECD GOV Observatory for Public Sector Innovation
ICT, Knowledge-based Society and Innovation 2.0
OECD GOV Open government data
Google Apps for Government - GovLoop LIVE CHAT
Transcending e-Government: a Case of Mobile Government in Beijing
m-government & android application development
M-Government
Open Data Strategies & Mobile Government (GCC Perspective)
Government on the move: trends in mobile technology and how government can ge...
MOBILE SOLUTIONS GUIDE FOR GOVERNMENT
E commerece,m-commerece & m-governance
Empowering citizens and local government with mobile data
Ad

Similar to Reactive Principles and Microservices (20)

PDF
Reactive - Is it really a Magic Pill?
PDF
Diving Into Reactive Microservices
PDF
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems (Soft-Sha...
PDF
Dive into reactive microservices
PDF
Building Microservices with Reactive Architecture - Himani Arora
PPTX
Azure reactive systems
ODP
Reactive Microservices
PDF
Microservices & reactive systems
PPTX
Magento Developer Talk. Microservice Architecture and Actor Model
PDF
Go Reactive: Building Responsive, Resilient, Elastic & Message-Driven Systems
PDF
Resilience Planning & How the Empire Strikes Back
PDF
Patterns of resilience
PDF
What is Reactive programming?
PPTX
20160609 nike techtalks reactive applications tools of the trade
PDF
The Reactive Principles: Design Principles For Cloud Native Applications
PPTX
Microservices Resilient Engineering - Java meetup.pptx
PDF
Patterns for Asynchronous Microservices with NATS
PDF
The Reactive Principles: Eight Tenets For Building Cloud Native Applications
PPTX
Patterns for Asynchronous Microservices with NATS
PPTX
Expect the unexpected: Anticipate and prepare for failures in microservices b...
Reactive - Is it really a Magic Pill?
Diving Into Reactive Microservices
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems (Soft-Sha...
Dive into reactive microservices
Building Microservices with Reactive Architecture - Himani Arora
Azure reactive systems
Reactive Microservices
Microservices & reactive systems
Magento Developer Talk. Microservice Architecture and Actor Model
Go Reactive: Building Responsive, Resilient, Elastic & Message-Driven Systems
Resilience Planning & How the Empire Strikes Back
Patterns of resilience
What is Reactive programming?
20160609 nike techtalks reactive applications tools of the trade
The Reactive Principles: Design Principles For Cloud Native Applications
Microservices Resilient Engineering - Java meetup.pptx
Patterns for Asynchronous Microservices with NATS
The Reactive Principles: Eight Tenets For Building Cloud Native Applications
Patterns for Asynchronous Microservices with NATS
Expect the unexpected: Anticipate and prepare for failures in microservices b...
Ad

Recently uploaded (20)

PDF
medical staffing services at VALiNTRY
PDF
System and Network Administraation Chapter 3
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Nekopoi APK 2025 free lastest update
PPTX
history of c programming in notes for students .pptx
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
medical staffing services at VALiNTRY
System and Network Administraation Chapter 3
Understanding Forklifts - TECH EHS Solution
Nekopoi APK 2025 free lastest update
history of c programming in notes for students .pptx
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Odoo Companies in India – Driving Business Transformation.pdf
Design an Analysis of Algorithms II-SECS-1021-03
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Wondershare Filmora 15 Crack With Activation Key [2025
How to Migrate SBCGlobal Email to Yahoo Easily
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Upgrade and Innovation Strategies for SAP ERP Customers
Softaken Excel to vCard Converter Software.pdf
Reimagine Home Health with the Power of Agentic AI​
How to Choose the Right IT Partner for Your Business in Malaysia
VVF-Customer-Presentation2025-Ver1.9.pptx
2025 Textile ERP Trends: SAP, Odoo & Oracle

Reactive Principles and Microservices

  • 1. Reactive MicroServices Leveraging Reactive principles in a technology agnostic way Lorenzo Nicora Senior Consultant @ OpenCredo @nicusX https://opencredo.com/author/lorenzo
  • 2. “Reactive” is… Reactive Semantically overloaded term adj. “Readily responsive to stimulus” [Merrian-Webster dictionary] From Latin “reagere”: act in return Lorenzo Nicora Reactive μServices
  • 3. Reactive as… Reactive as Reactive Manifesto Lorenzo Nicora Reactive μServices
  • 4. Reactive Manifesto Lorenzo Nicora Reactive μServices
  • 5. ü Responsive à Low latency ü Resilient à Stay responsive on failure ü Elastic à Scale as needed ü Message-Driven à Asynchronous messages as only communication between components Simplifying Lorenzo Nicora Reactive μServices
  • 6. ✗ No Blocking operation ✗ No Synchronization à No Contention ✗ No Resource hogging Reactive Manifesto promotes Decoupling and isolation in… üTime à Concurrent processing üSpace à Components location decoupling Lorenzo Nicora Reactive μServices
  • 7. Reactive as.. Akka Spring Boot a set of Architectural Patterns and Principles Not necessarily related to a specific technology a set of technologies Lorenzo Nicora Reactive μServices
  • 8. A set of architectural patterns and principles applicable to MicroServices ü Non-blocking processing ü Message-based communication ü Asynchronous delegation ü Resilience: Isolation & Replication; Backpressure ü Elasticity ü Location transparency Reactive as Architectural Patterns Lorenzo Nicora Reactive μServices
  • 9. a MicroService is.. • Communicate with others over the network • Part of a distributed system • Independently deployed • Independently scalable MicroServices Lorenzo Nicora Reactive μServices
  • 10. Macro level at μService boundaries Between Services; external resources Across the MicroService Stack Micro level within the μService Between internal components Lorenzo Nicora Reactive μServices
  • 11. Do not block threads Never block a thread doing nothing and waiting for an Input or a Response Threads are limited resources (Thread starving) (React to Input / Response) Lorenzo Nicora Reactive μServices
  • 12. Non-blocking à Faster Lorenzo Nicora Reactive μServices
  • 13. Non-blocking Communication Macro (at service boundaries) ✗ Limit Request/Response pattern üOne-way messaging (fire and forget) üPrefer messaging protocols rather than HTTP Non-blocking Lorenzo Nicora Reactive μServices
  • 14. Non-blocking Communication and IO Micro (within the Service) ✗ Limit blocking/direct method calls üFutures, Promises, Callbacks üInternal messaging (e.g. Actor model) üNon-blocking IO and drivers Non-blocking Lorenzo Nicora Reactive μServices
  • 15. Non-blocking + Blocking = Blocking ✗ Many resources only provide blocking API • Prefer technologies with non-blocking API ✗ Do not block on a Future… • To extract the result • To handle exceptions ❗ Know where your thread come from • Thread pools Non-blocking pitfalls Lorenzo Nicora Reactive μServices
  • 16. Delegation * External components Delegate a task asynchronously to other components* Macro (at Service boundaries) o Delegate tasks to other μServices o Send Request as a Message o When required, Response come back as a Message Lorenzo Nicora Reactive μServices
  • 17. Delegation * Internal component Delegate a task asynchronously to other components* Micro (within the Service) o Execute sub-tasks in separate threads • Futures/Promises, Callbacks… o Run multiple tasks in parallel Lorenzo Nicora Reactive μServices
  • 18. Parallel Delegation Lorenzo Nicora Reactive μServices
  • 19. Resilience: Stay responsive in face of failure Resilience Design expecting failure Failure happens! Fail-Safe Lorenzo Nicora Reactive μServices
  • 20. • Failure (e.g. connection failure, timeout…) • Unexpected event • Not recoverable • No meaningful response to your client • Error (e.g. user input error) • Expected condition • A specific response to the client (your protocol) Failure ≠ Error Lorenzo Nicora Reactive μServices
  • 21. Resilience: Isolation + Replication Resilience à Isolation + Replication Macro o Deployment Isolation o Bulkheads • Prevent cascading failures • Neither to peer services, nor upstream/downstream Lorenzo Nicora Reactive μServices
  • 22. Resilience à Isolation + Replication o Replication • Legacy (always valid) HA approach • Multiple peer services • Data Replication Resilience: Isolation + Replication Lorenzo Nicora Reactive μServices
  • 23. Fail silent; Fail fast then Recover, when possible o Prevent cascading failures o Isolate failing collaborators • Downstream μServices • External services • Resources (DB…) Resilience: Circuit Breakers Lorenzo Nicora Reactive μServices
  • 24. Expect Failure… Resilience: Handle failure … Handle Failure Lorenzo Nicora Reactive μServices
  • 25. Handle Errors and Failures separately Consistently report Errors to your client Error is part of your “protocol” (business logic) Gracefully degrade on Failure Avoid ”All or nothing” logic à Partial Responses Handling Failure Lorenzo Nicora Reactive μServices
  • 26. Explicitly set and handle timeouts on every asynchronous interaction Never rely on default settings and handling for timeouts Timeouts - Failures When collaboration is asynchronous (messaging) a Failure becomes a Time-out Lorenzo Nicora Reactive μServices
  • 27. Prevent fast publishers from overrunning slow consumers ✗ Drop messages (acceptable?) ✗ Cause catastrophic cascade failures Back-pressure Lorenzo Nicora Reactive μServices
  • 28. Buffers overflow! and will not save you Back-pressure à Backpressure Consumer… ü Give feedback to publisher ü Drive the pace Lorenzo Nicora Reactive μServices
  • 29. Ability to scale when required Macro ü Scale services and resources • Add/Remove VM, Container, Cluster nodes ❗ Scaling data (application state) • Only Partitioning, Sharding Elasticity Scaling: an infrastructure concern, but application must be designed for it Lorenzo Nicora Reactive μServices
  • 30. Your collaborator may be anywhere Local or Remote Architecture may evolve Local à Remote “There ain’t no such thing as a transparent synchronous remotisation” Async Messaging work the same local and remote Location Transparency Lorenzo Nicora Reactive μServices
  • 31. You need to find your collaborator o Service Discovery • Dynamic service registration • Heartbeat, Gossip, Health Check (is a service dead?) • DNS o Load Balancers Location Transparency Lorenzo Nicora Reactive μServices
  • 33. ü Reactive as a set of Architectural Patterns and Principles Ø low latency/high throughput Ø scale linearly Ø resiliency Ø … ü When not using a ”Reactive” technology apply discipline, but still enforce Reactive Principles ü Keep in mind when designing both… Macro: μService architecture Micro: internal software design Conclusions Lorenzo Nicora Reactive μServices
  • 34. Reactive Manifesto: http://www.reactivemanifesto.org/ à Glossary http://www.reactivemanifesto.org/glossary References Lorenzo Nicora Reactive μServices