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

Viewers also liked

Achieving best practice in delivering government information and services online
Achieving best practice in delivering government information and services onlineAchieving best practice in delivering government information and services online
Achieving best practice in delivering government information and services online
eGovernment Resource Centre
 
Towards a Political Aesthetic of Everyday Life
Towards a Political Aesthetic of Everyday Life Towards a Political Aesthetic of Everyday Life
Towards a Political Aesthetic of Everyday Life
Zeliha Uyurca
 
Government Controlled Mobile VoIP
Government Controlled Mobile VoIPGovernment Controlled Mobile VoIP
Government Controlled Mobile VoIP
Habibur Rahman
 
MGov2010
MGov2010MGov2010
MGov2010
Ken Eastwood
 
Mobile Seva: Bringing Citizens and Government Together Through Mobiles, India
Mobile Seva: Bringing Citizens and Government Together Through Mobiles, IndiaMobile Seva: Bringing Citizens and Government Together Through Mobiles, India
Mobile Seva: Bringing Citizens and Government Together Through Mobiles, India
UNDP India
 
The importance of a mobile government
The importance of a mobile governmentThe importance of a mobile government
The importance of a mobile government
Capgemini
 
Mobile Governance Applications
Mobile Governance ApplicationsMobile Governance Applications
Mobile Governance Applications
achalkumar
 
Zia Government Solutions from Paper to Mobile
Zia Government Solutions from Paper to MobileZia Government Solutions from Paper to Mobile
Zia Government Solutions from Paper to Mobile
Zia Consulting
 
OECD GOV Observatory for Public Sector Innovation
OECD GOV Observatory for Public Sector InnovationOECD GOV Observatory for Public Sector Innovation
OECD GOV Observatory for Public Sector Innovation
adamlerouge
 
ICT, Knowledge-based Society and Innovation 2.0
ICT, Knowledge-based Society and Innovation 2.0ICT, Knowledge-based Society and Innovation 2.0
ICT, Knowledge-based Society and Innovation 2.0
songgang
 
OECD GOV Open government data
OECD GOV Open government dataOECD GOV Open government data
OECD GOV Open government data
adamlerouge
 
Google Apps for Government - GovLoop LIVE CHAT
Google Apps for Government - GovLoop LIVE CHATGoogle Apps for Government - GovLoop LIVE CHAT
Google Apps for Government - GovLoop LIVE CHAT
GovLoop
 
Transcending e-Government: a Case of Mobile Government in Beijing
Transcending e-Government: a Case of Mobile Government in BeijingTranscending e-Government: a Case of Mobile Government in Beijing
Transcending e-Government: a Case of Mobile Government in Beijing
songgang
 
m-government & android application development
m-government & android application developmentm-government & android application development
m-government & android application development
Arif Huda
 
M-Government
M-GovernmentM-Government
M-Government
SysNet Integrators
 
Open Data Strategies & Mobile Government (GCC Perspective)
Open Data Strategies & Mobile Government (GCC Perspective)Open Data Strategies & Mobile Government (GCC Perspective)
Open Data Strategies & Mobile Government (GCC Perspective)
Dr Usman Zafar
 
Government on the move: trends in mobile technology and how government can ge...
Government on the move: trends in mobile technology and how government can ge...Government on the move: trends in mobile technology and how government can ge...
Government on the move: trends in mobile technology and how government can ge...
eGovernment Resource Centre
 
MOBILE SOLUTIONS GUIDE FOR GOVERNMENT
MOBILE SOLUTIONS GUIDE FOR GOVERNMENTMOBILE SOLUTIONS GUIDE FOR GOVERNMENT
MOBILE SOLUTIONS GUIDE FOR GOVERNMENT
NGINX at F5
 
E commerece,m-commerece & m-governance
E commerece,m-commerece & m-governanceE commerece,m-commerece & m-governance
E commerece,m-commerece & m-governance
Sai Mahesh
 
Empowering citizens and local government with mobile data
Empowering citizens and local government with mobile dataEmpowering citizens and local government with mobile data
Empowering citizens and local government with mobile data
Tim Willoughby
 

Viewers also liked (20)

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

Similar to Reactive Principles and Microservices

Reactive - Is it really a Magic Pill?
Reactive - Is it really a Magic Pill?Reactive - Is it really a Magic Pill?
Reactive - Is it really a Magic Pill?
Tech Triveni
 
Spring Boot Microservices vs Akka Actor Cluster
Spring Boot Microservices vs Akka Actor Cluster Spring Boot Microservices vs Akka Actor Cluster
Spring Boot Microservices vs Akka Actor Cluster
OpenCredo
 
Azure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challengesAzure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challenges
Ivo Andreev
 
Service Mesh CTO Forum (Draft 3)
Service Mesh CTO Forum (Draft 3)Service Mesh CTO Forum (Draft 3)
Service Mesh CTO Forum (Draft 3)
Rick Hightower
 
Microservices for Mortals by Bert Ertman at Codemotion Dubai
 Microservices for Mortals by Bert Ertman at Codemotion Dubai Microservices for Mortals by Bert Ertman at Codemotion Dubai
Microservices for Mortals by Bert Ertman at Codemotion Dubai
Codemotion Dubai
 
Observables in Angular
Observables in AngularObservables in Angular
Observables in Angular
Knoldus Inc.
 
[WSO2Con EU 2017] Resilience Patterns with Ballerina
[WSO2Con EU 2017] Resilience Patterns with Ballerina[WSO2Con EU 2017] Resilience Patterns with Ballerina
[WSO2Con EU 2017] Resilience Patterns with Ballerina
WSO2
 
Rx Swift
Rx SwiftRx Swift
Rx Swift
Vincenzo Favara
 
Asynchronyin net
Asynchronyin netAsynchronyin net
Asynchronyin net
Soacat Blogspot
 
Reactive Micro Services with Java seminar
Reactive Micro Services with Java seminarReactive Micro Services with Java seminar
Reactive Micro Services with Java seminar
Gal Marder
 
Resisting to The Shocks
Resisting to The ShocksResisting to The Shocks
Resisting to The Shocks
Stefano Fago
 
Reactive programming
Reactive programmingReactive programming
Reactive programming
Mesut Can Gurle
 
Surviving microservices
Surviving microservicesSurviving microservices
Surviving microservices
Francesco Degrassi
 
Reactive Programming
Reactive ProgrammingReactive Programming
Reactive Programming
Knoldus Inc.
 
Not my problem - Delegating responsibility to infrastructure
Not my problem - Delegating responsibility to infrastructureNot my problem - Delegating responsibility to infrastructure
Not my problem - Delegating responsibility to infrastructure
Yshay Yaacobi
 
Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...
Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...
Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...
Theo Jungeblut
 
Building Cloud Ready Apps
Building Cloud Ready AppsBuilding Cloud Ready Apps
Building Cloud Ready Apps
VMware Tanzu
 
Advance Microservice Patterns - Event Souring , CQRS
Advance Microservice Patterns - Event Souring , CQRSAdvance Microservice Patterns - Event Souring , CQRS
Advance Microservice Patterns - Event Souring , CQRS
Mohit Mittal
 
Clean Code II - Dependency Injection
Clean Code II - Dependency InjectionClean Code II - Dependency Injection
Clean Code II - Dependency Injection
Theo Jungeblut
 
Tef con2016 (1)
Tef con2016 (1)Tef con2016 (1)
Tef con2016 (1)
ggarber
 

Similar to Reactive Principles and Microservices (20)

Reactive - Is it really a Magic Pill?
Reactive - Is it really a Magic Pill?Reactive - Is it really a Magic Pill?
Reactive - Is it really a Magic Pill?
 
Spring Boot Microservices vs Akka Actor Cluster
Spring Boot Microservices vs Akka Actor Cluster Spring Boot Microservices vs Akka Actor Cluster
Spring Boot Microservices vs Akka Actor Cluster
 
Azure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challengesAzure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challenges
 
Service Mesh CTO Forum (Draft 3)
Service Mesh CTO Forum (Draft 3)Service Mesh CTO Forum (Draft 3)
Service Mesh CTO Forum (Draft 3)
 
Microservices for Mortals by Bert Ertman at Codemotion Dubai
 Microservices for Mortals by Bert Ertman at Codemotion Dubai Microservices for Mortals by Bert Ertman at Codemotion Dubai
Microservices for Mortals by Bert Ertman at Codemotion Dubai
 
Observables in Angular
Observables in AngularObservables in Angular
Observables in Angular
 
[WSO2Con EU 2017] Resilience Patterns with Ballerina
[WSO2Con EU 2017] Resilience Patterns with Ballerina[WSO2Con EU 2017] Resilience Patterns with Ballerina
[WSO2Con EU 2017] Resilience Patterns with Ballerina
 
Rx Swift
Rx SwiftRx Swift
Rx Swift
 
Asynchronyin net
Asynchronyin netAsynchronyin net
Asynchronyin net
 
Reactive Micro Services with Java seminar
Reactive Micro Services with Java seminarReactive Micro Services with Java seminar
Reactive Micro Services with Java seminar
 
Resisting to The Shocks
Resisting to The ShocksResisting to The Shocks
Resisting to The Shocks
 
Reactive programming
Reactive programmingReactive programming
Reactive programming
 
Surviving microservices
Surviving microservicesSurviving microservices
Surviving microservices
 
Reactive Programming
Reactive ProgrammingReactive Programming
Reactive Programming
 
Not my problem - Delegating responsibility to infrastructure
Not my problem - Delegating responsibility to infrastructureNot my problem - Delegating responsibility to infrastructure
Not my problem - Delegating responsibility to infrastructure
 
Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...
Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...
Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...
 
Building Cloud Ready Apps
Building Cloud Ready AppsBuilding Cloud Ready Apps
Building Cloud Ready Apps
 
Advance Microservice Patterns - Event Souring , CQRS
Advance Microservice Patterns - Event Souring , CQRSAdvance Microservice Patterns - Event Souring , CQRS
Advance Microservice Patterns - Event Souring , CQRS
 
Clean Code II - Dependency Injection
Clean Code II - Dependency InjectionClean Code II - Dependency Injection
Clean Code II - Dependency Injection
 
Tef con2016 (1)
Tef con2016 (1)Tef con2016 (1)
Tef con2016 (1)
 

Recently uploaded

Cost-Effective Strategies For iOS App Development
Cost-Effective Strategies For iOS App DevelopmentCost-Effective Strategies For iOS App Development
Cost-Effective Strategies For iOS App Development
Softradix Technologies
 
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical OperationsEnsuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
OnePlan Solutions
 
Penify - Let AI do the Documentation, you write the Code.
Penify - Let AI do the Documentation, you write the Code.Penify - Let AI do the Documentation, you write the Code.
Penify - Let AI do the Documentation, you write the Code.
KrishnaveniMohan1
 
Orca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container OrchestrationOrca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container Orchestration
Pedro J. Molina
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
gapen1
 
Beginner's Guide to Observability@Devoxx PL 2024
Beginner's  Guide to Observability@Devoxx PL 2024Beginner's  Guide to Observability@Devoxx PL 2024
Beginner's Guide to Observability@Devoxx PL 2024
michniczscribd
 
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
campbellclarkson
 
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
widenerjobeyrl638
 
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
dhavalvaghelanectarb
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
safelyiotech
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
Tier1 app
 
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA ComplianceSecure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
ICS
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
The Third Creative Media
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
ervikas4
 
Going AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applicationsGoing AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applications
Alina Yurenko
 

Recently uploaded (20)

Cost-Effective Strategies For iOS App Development
Cost-Effective Strategies For iOS App DevelopmentCost-Effective Strategies For iOS App Development
Cost-Effective Strategies For iOS App Development
 
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical OperationsEnsuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
 
Penify - Let AI do the Documentation, you write the Code.
Penify - Let AI do the Documentation, you write the Code.Penify - Let AI do the Documentation, you write the Code.
Penify - Let AI do the Documentation, you write the Code.
 
Orca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container OrchestrationOrca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container Orchestration
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
 
Beginner's Guide to Observability@Devoxx PL 2024
Beginner's  Guide to Observability@Devoxx PL 2024Beginner's  Guide to Observability@Devoxx PL 2024
Beginner's Guide to Observability@Devoxx PL 2024
 
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
 
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
 
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
 
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA ComplianceSecure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
 
bgiolcb
bgiolcbbgiolcb
bgiolcb
 
Going AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applicationsGoing AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applications
 

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