SlideShare una empresa de Scribd logo
1 de 35
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't...
LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't...LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't...
LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't...
Daniel Bryant
 
Distributed Reactive Architecture: Extending SOA with Events
Distributed Reactive Architecture: Extending SOA with EventsDistributed Reactive Architecture: Extending SOA with Events
Distributed Reactive Architecture: Extending SOA with Events
Steve Pember
 

La actualidad más candente (20)

Decomposing the Monolith using Microservices that don't give you pain
Decomposing the Monolith using Microservices that don't give you painDecomposing the Monolith using Microservices that don't give you pain
Decomposing the Monolith using Microservices that don't give you pain
 
JSR 354: Money and Currency API - Short Overview
JSR 354: Money and Currency API - Short OverviewJSR 354: Money and Currency API - Short Overview
JSR 354: Money and Currency API - Short Overview
 
Managing Data in Microservices
Managing Data in MicroservicesManaging Data in Microservices
Managing Data in Microservices
 
LJCConf 2013 "Chuck Norris Doesn't Need DevOps"
LJCConf 2013 "Chuck Norris Doesn't Need DevOps"LJCConf 2013 "Chuck Norris Doesn't Need DevOps"
LJCConf 2013 "Chuck Norris Doesn't Need DevOps"
 
Decomposing the monolith into embeddable microservices using OWIN, WebHooks, ...
Decomposing the monolith into embeddable microservices using OWIN, WebHooks, ...Decomposing the monolith into embeddable microservices using OWIN, WebHooks, ...
Decomposing the monolith into embeddable microservices using OWIN, WebHooks, ...
 
Should i break it?
Should i break it?Should i break it?
Should i break it?
 
LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't...
LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't...LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't...
LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't...
 
Building stateful systems with akka cluster sharding
Building stateful systems with akka cluster shardingBuilding stateful systems with akka cluster sharding
Building stateful systems with akka cluster sharding
 
Microservices Practitioner Summit Jan '15 - Microservice Ecosystems At Scale ...
Microservices Practitioner Summit Jan '15 - Microservice Ecosystems At Scale ...Microservices Practitioner Summit Jan '15 - Microservice Ecosystems At Scale ...
Microservices Practitioner Summit Jan '15 - Microservice Ecosystems At Scale ...
 
Distributed Reactive Architecture: Extending SOA with Events
Distributed Reactive Architecture: Extending SOA with EventsDistributed Reactive Architecture: Extending SOA with Events
Distributed Reactive Architecture: Extending SOA with Events
 
Just enough web ops for web developers
Just enough web ops for web developersJust enough web ops for web developers
Just enough web ops for web developers
 
Devoxx US 2017 "The Seven (More) Deadly Sins of Microservices"
Devoxx US 2017 "The Seven (More) Deadly Sins of Microservices"Devoxx US 2017 "The Seven (More) Deadly Sins of Microservices"
Devoxx US 2017 "The Seven (More) Deadly Sins of Microservices"
 
Stream Collections - Scala Days
Stream Collections - Scala DaysStream Collections - Scala Days
Stream Collections - Scala Days
 
JSR 375 - Have you seen Java EE Security API lately? - codemotion Tel Aviv 2015
JSR 375 - Have you seen Java EE Security API lately? - codemotion Tel Aviv 2015JSR 375 - Have you seen Java EE Security API lately? - codemotion Tel Aviv 2015
JSR 375 - Have you seen Java EE Security API lately? - codemotion Tel Aviv 2015
 
OpenStack: Toward a More Resilient Cloud
OpenStack: Toward a More Resilient CloudOpenStack: Toward a More Resilient Cloud
OpenStack: Toward a More Resilient Cloud
 
DefCore: The Interoperability Standard for OpenStack
DefCore: The Interoperability Standard for OpenStackDefCore: The Interoperability Standard for OpenStack
DefCore: The Interoperability Standard for OpenStack
 
LJC: "Chuck Norris Doesn't Do DevOps...but Java developers might benefit"
LJC: "Chuck Norris Doesn't Do DevOps...but Java developers might benefit"LJC: "Chuck Norris Doesn't Do DevOps...but Java developers might benefit"
LJC: "Chuck Norris Doesn't Do DevOps...but Java developers might benefit"
 
DockerCon EU 2018 "Continuous Delivery with Docker and Java"
DockerCon EU 2018 "Continuous Delivery with Docker and Java"DockerCon EU 2018 "Continuous Delivery with Docker and Java"
DockerCon EU 2018 "Continuous Delivery with Docker and Java"
 
JavaOne 2014: Cloud Developer's DHARMA: Redefining 'done' for Cloud applications
JavaOne 2014: Cloud Developer's DHARMA: Redefining 'done' for Cloud applicationsJavaOne 2014: Cloud Developer's DHARMA: Redefining 'done' for Cloud applications
JavaOne 2014: Cloud Developer's DHARMA: Redefining 'done' for Cloud applications
 
LJC 05/14 "Cloud Developer's DHARMA"
LJC 05/14 "Cloud Developer's DHARMA"LJC 05/14 "Cloud Developer's DHARMA"
LJC 05/14 "Cloud Developer's DHARMA"
 

Destacado

Haufe #msaday - Seven More Deadly Sins of Microservices by Daniel Bryant
Haufe #msaday - Seven More Deadly Sins of Microservices by Daniel Bryant Haufe #msaday - Seven More Deadly Sins of Microservices by Daniel Bryant
Haufe #msaday - Seven More Deadly Sins of Microservices by Daniel Bryant
OpenCredo
 

Destacado (20)

Voxxed Bristol 2017 - From C to Q, one event at a time: Event Sourcing illust...
Voxxed Bristol 2017 - From C to Q, one event at a time: Event Sourcing illust...Voxxed Bristol 2017 - From C to Q, one event at a time: Event Sourcing illust...
Voxxed Bristol 2017 - From C to Q, one event at a time: Event Sourcing illust...
 
Haufe #msaday - Building a Microservice Ecosystem by Daniel Bryant
Haufe #msaday - Building a Microservice Ecosystem by Daniel Bryant Haufe #msaday - Building a Microservice Ecosystem by Daniel Bryant
Haufe #msaday - Building a Microservice Ecosystem by Daniel Bryant
 
O'Reilly 2016: "Continuous Delivery with Containers: The Trials and Tribulati...
O'Reilly 2016: "Continuous Delivery with Containers: The Trials and Tribulati...O'Reilly 2016: "Continuous Delivery with Containers: The Trials and Tribulati...
O'Reilly 2016: "Continuous Delivery with Containers: The Trials and Tribulati...
 
A Visual Introduction to Event Sourcing and CQRS by Lorenzo Nicora
A Visual Introduction to Event Sourcing and CQRS by Lorenzo NicoraA Visual Introduction to Event Sourcing and CQRS by Lorenzo Nicora
A Visual Introduction to Event Sourcing and CQRS by Lorenzo Nicora
 
Haufe #msaday - Seven More Deadly Sins of Microservices by Daniel Bryant
Haufe #msaday - Seven More Deadly Sins of Microservices by Daniel Bryant Haufe #msaday - Seven More Deadly Sins of Microservices by Daniel Bryant
Haufe #msaday - Seven More Deadly Sins of Microservices by Daniel Bryant
 
Evolving Project Management: from the sin to the virtue by Antonio Cobo
Evolving Project Management: from the sin to the virtue by Antonio CoboEvolving Project Management: from the sin to the virtue by Antonio Cobo
Evolving Project Management: from the sin to the virtue by Antonio Cobo
 
ServerlessConf: Serverless for the Enterprise - Rafal Gancarz
ServerlessConf: Serverless for the Enterprise - Rafal GancarzServerlessConf: Serverless for the Enterprise - Rafal Gancarz
ServerlessConf: Serverless for the Enterprise - Rafal Gancarz
 
Haufe #msaday - The Actor model: an alternative approach to concurrency By Lo...
Haufe #msaday - The Actor model: an alternative approach to concurrency By Lo...Haufe #msaday - The Actor model: an alternative approach to concurrency By Lo...
Haufe #msaday - The Actor model: an alternative approach to concurrency By Lo...
 
High Load Strategy 2016 - Project Management: from Stone Age to DevOps
High Load Strategy 2016 - Project Management: from Stone Age to DevOps High Load Strategy 2016 - Project Management: from Stone Age to DevOps
High Load Strategy 2016 - Project Management: from Stone Age to DevOps
 
muCon 2016: Authentication in Microservice Systems By David Borsos
muCon 2016: Authentication in Microservice Systems By David BorsosmuCon 2016: Authentication in Microservice Systems By David Borsos
muCon 2016: Authentication in Microservice Systems By David Borsos
 
QCON London 2017 - Monitoring Serverless Architectures by Rafal Gancarz
QCON London 2017 - Monitoring Serverless Architectures by Rafal GancarzQCON London 2017 - Monitoring Serverless Architectures by Rafal Gancarz
QCON London 2017 - Monitoring Serverless Architectures by Rafal Gancarz
 
London Hashicorp Meetup #8 - Testing Programmable Infrastructure By Matt Long
London Hashicorp Meetup #8 -  Testing Programmable Infrastructure By Matt LongLondon Hashicorp Meetup #8 -  Testing Programmable Infrastructure By Matt Long
London Hashicorp Meetup #8 - Testing Programmable Infrastructure By Matt Long
 
Microservices Manchester: Microservices and Macro-Economics - A Shorty Histor...
Microservices Manchester: Microservices and Macro-Economics - A Shorty Histor...Microservices Manchester: Microservices and Macro-Economics - A Shorty Histor...
Microservices Manchester: Microservices and Macro-Economics - A Shorty Histor...
 
Vault: Beyond secret storage - Using Vault to harden your infrastructure
Vault: Beyond secret storage - Using Vault to harden your infrastructureVault: Beyond secret storage - Using Vault to harden your infrastructure
Vault: Beyond secret storage - Using Vault to harden your infrastructure
 
Microservices Manchester: Security, Microservces and Vault by Nicki Watt
Microservices Manchester:  Security, Microservces and Vault by Nicki WattMicroservices Manchester:  Security, Microservces and Vault by Nicki Watt
Microservices Manchester: Security, Microservces and Vault by Nicki Watt
 
Microservices Manchester: Authentication in Microservice Systems by David Borsos
Microservices Manchester: Authentication in Microservice Systems by David BorsosMicroservices Manchester: Authentication in Microservice Systems by David Borsos
Microservices Manchester: Authentication in Microservice Systems by David Borsos
 
Vert.x vs akka
Vert.x vs akkaVert.x vs akka
Vert.x vs akka
 
Microservices Manchester: Concursus - Event Sourcing Evolved By Domonic Fox
Microservices Manchester: Concursus - Event Sourcing Evolved By Domonic FoxMicroservices Manchester: Concursus - Event Sourcing Evolved By Domonic Fox
Microservices Manchester: Concursus - Event Sourcing Evolved By Domonic Fox
 
Continuous Learning
Continuous LearningContinuous Learning
Continuous Learning
 
A Journey to Reactive Function Programming
A Journey to Reactive Function ProgrammingA Journey to Reactive Function Programming
A Journey to Reactive Function Programming
 

Similar a Reactive Microservices By Lorenzo Nicora

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
 
Clean Code II - Dependency Injection
Clean Code II - Dependency InjectionClean Code II - Dependency Injection
Clean Code II - Dependency Injection
Theo Jungeblut
 

Similar a Reactive Microservices By Lorenzo Nicora (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?
 
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)
 
Give your microservices a bus ride with MassTransit
Give your microservices a bus ride with MassTransitGive your microservices a bus ride with MassTransit
Give your microservices a bus ride with MassTransit
 

Más de OpenCredo

Kafka Summit 2018: A Journey Building Kafka Connectors - Pegerto Fernandez
Kafka Summit 2018: A Journey Building Kafka Connectors - Pegerto FernandezKafka Summit 2018: A Journey Building Kafka Connectors - Pegerto Fernandez
Kafka Summit 2018: A Journey Building Kafka Connectors - Pegerto Fernandez
OpenCredo
 
MuCon 2017: A not So(A) Trivial Question by Tareq Abedrabbo
MuCon 2017: A not So(A) Trivial Question by Tareq AbedrabboMuCon 2017: A not So(A) Trivial Question by Tareq Abedrabbo
MuCon 2017: A not So(A) Trivial Question by Tareq Abedrabbo
OpenCredo
 

Más de OpenCredo (12)

Webinar - Design Thinking for Platform Engineering
Webinar - Design Thinking for Platform EngineeringWebinar - Design Thinking for Platform Engineering
Webinar - Design Thinking for Platform Engineering
 
MuCon 2019: Exploring Your Microservices Architecture Through Network Science...
MuCon 2019: Exploring Your Microservices Architecture Through Network Science...MuCon 2019: Exploring Your Microservices Architecture Through Network Science...
MuCon 2019: Exploring Your Microservices Architecture Through Network Science...
 
Goto Chicago; Journeys To Cloud Native Architecture: Sun, Sea And Emergencies...
Goto Chicago; Journeys To Cloud Native Architecture: Sun, Sea And Emergencies...Goto Chicago; Journeys To Cloud Native Architecture: Sun, Sea And Emergencies...
Goto Chicago; Journeys To Cloud Native Architecture: Sun, Sea And Emergencies...
 
Mucon 2018: Heuristics for Identifying Microservice Boundaries By Erich Eichi...
Mucon 2018: Heuristics for Identifying Microservice Boundaries By Erich Eichi...Mucon 2018: Heuristics for Identifying Microservice Boundaries By Erich Eichi...
Mucon 2018: Heuristics for Identifying Microservice Boundaries By Erich Eichi...
 
Journeys To Cloud Native Architecture: Sun, Sea And Emergencies - Nicki Watt
Journeys To Cloud Native Architecture: Sun, Sea And Emergencies - Nicki WattJourneys To Cloud Native Architecture: Sun, Sea And Emergencies - Nicki Watt
Journeys To Cloud Native Architecture: Sun, Sea And Emergencies - Nicki Watt
 
Machine Learning Game Changer for IT - Maartens Lourens
Machine Learning Game Changer for IT - Maartens LourensMachine Learning Game Changer for IT - Maartens Lourens
Machine Learning Game Changer for IT - Maartens Lourens
 
Kafka Summit 2018: A Journey Building Kafka Connectors - Pegerto Fernandez
Kafka Summit 2018: A Journey Building Kafka Connectors - Pegerto FernandezKafka Summit 2018: A Journey Building Kafka Connectors - Pegerto Fernandez
Kafka Summit 2018: A Journey Building Kafka Connectors - Pegerto Fernandez
 
MuCon 2017: A not So(A) Trivial Question by Tareq Abedrabbo
MuCon 2017: A not So(A) Trivial Question by Tareq AbedrabboMuCon 2017: A not So(A) Trivial Question by Tareq Abedrabbo
MuCon 2017: A not So(A) Trivial Question by Tareq Abedrabbo
 
DevOpsCon Berlin 2017: Project Management from Stone Age to DevOps By Antoni...
DevOpsCon Berlin 2017: Project Management from Stone Age to DevOps  By Antoni...DevOpsCon Berlin 2017: Project Management from Stone Age to DevOps  By Antoni...
DevOpsCon Berlin 2017: Project Management from Stone Age to DevOps By Antoni...
 
Hashidays London 2017 - Evolving your Infrastructure with Terraform By Nicki ...
Hashidays London 2017 - Evolving your Infrastructure with Terraform By Nicki ...Hashidays London 2017 - Evolving your Infrastructure with Terraform By Nicki ...
Hashidays London 2017 - Evolving your Infrastructure with Terraform By Nicki ...
 
Succeeding with DevOps Transformation - Rafal Gancarz
Succeeding with DevOps Transformation - Rafal GancarzSucceeding with DevOps Transformation - Rafal Gancarz
Succeeding with DevOps Transformation - Rafal Gancarz
 
Progscon 2017: Serverless Architectures - Rafal Gancarz
Progscon 2017: Serverless Architectures - Rafal GancarzProgscon 2017: Serverless Architectures - Rafal Gancarz
Progscon 2017: Serverless Architectures - Rafal Gancarz
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Reactive Microservices By Lorenzo Nicora

  • 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