SlideShare a Scribd company logo
Patrick Di Loreto
Jose Luis Escanciano
J on the Beach
Malaga – 24/05/2018
https://github.com/patricknoir/reactive-platform
A Functional approach to reactive microservice architecture
Patrick Di Loreto
CTO
Jose Luis Escanciano
Chief Architect
Response in a
timely manner
Responsive under
failure scenariosResponsive
under load
Enabler for
responsiveness
Monolithic Microservices
Divide
Conquer
§ When implementing a system, we translate the reality into software that resemble the original business processes as
much as possible.
§ Domain is an area of interest for the business.
§ Model is a set of abstractions and behaviors that reflect the real world.
§ Domain-Model is a blueprint of the entities and their relationships in a given domain, together with the following
important details:
§ Entities that belong to the domain.
§ Interactions between the entities.
§ Ubiquitous language / Vocabulary of the domain.
§ Assumptions and constraints relevant to the domain.
Bookings:
Hotel
Room
Guest
Registrations: Booking
Amenity
Employee
Finance:
§ Value Object: Immutable item defined uniquely by the values of its attributes. If an
attribute changes, we’d be speaking of a different value object.
§ Entity: Item representing a subject in the reality which state is managed across his
lifetime by its identity. Despite a change on its attributes, the entity is always
identified by the same id.
§ Aggregate: Unit of consistency in your model, which inherently has a root
aggregate – entity used to refer to the aggregate itself.
§ Service: Describes the behavior and constraints within the domain – define the
use cases in the business logic.
§ Bounded Context refers to a specific domain model, which is part of the whole
domain.
§ Bounded contexts are intended to be self-contained (standalone module).
§ Which doesn’t mean they’re isolated, actually, bounded contexts quite often
interact between each other in the whole domain, but it’s key to:
§ Keep them as loosely coupled as possible.
§ Reduce the interactions between them to the minimum.
§ Ensure communication between them are decoupled in space and time.
Bounded
Context
Commands
Requests
Events
Events
Responses
MessageBus
Bounded
Context
Commands
Requests
Events
Events
Responses
Gateway
Gateway
Protocols
Protocols
Dispatch Messages
Dispatch Messages
A Functional approach to reactive microservice architecture
A Functional approach to reactive microservice architecture
§ Has a name
§ Is a function from In to Out
§ Service[-In, +Out](name: String, f: In => Out)
§ Sometime services have to handle a state, so in order to elaborate a
computation: they need to know the current state and they will also
produce an output state.
type StatefulService[S, Input, Output] = Service[(S, Input), (S, Output)]
class Service[In, Out](name: String, f: In => Out)
type In = (S, Input) type Out = (S, Output)
type In = (S, I)
type Out = (S, O)
class Service[In, Out](name: String, f: In => Out)
f: (S, I) => (S, O)
f: I => S => (S, O) // Currying: I => (S => (S,O))
f: I => State[S, O] // S => (S,O) = State[S,O]
class StatefulService[S, I, O](name: String, f: I => State[S, O])
class Service[In, Out](name: String, f: In => Out)
type ReactiveService[I, O] = Service[I, Future[O]]
val f: I => Future[O]
type ReactiveStatefulService[S, I, E] = StatefulService[I, Future[State[S, E]]]
val f: I => Future[State[S, E]]
O = State[S, E]
type Cmd[S] = StatefulService[S, Command, Event]
val f: Command => State[S, Event] // f: (S,Command) => (S,Event)
type Evt[S] = StatefulService[S, Event, Event]
val f: Event => State[S, Event] // f: (S,Event) => (S,Event)
type Ask[S] = StatefulService[S, Request, Response]
val f: Request => State[S, Response] // f: (S,Request) => (_,Response)
§ A microservice is a component developed to serve a specific functionaly in an
effectively manner. Is a set of services (as we defined) that will deal on a specific
problem.
§ CQRS:
§ Command
§ Query
§ Responsibility
§ Segregation
§ Encourage Separation of concerns between write and read models.
§ This separation can be extended into the microservices level where we will have:
§ Processors – which will manage the write model (deal with Commands)
§ Views – which will manage the read model (deal with Queries)
val modifiers: Set[StatefulService[S, Command, Event]]
val reactors: Set[StatefulService[S, Event, Event]]
trait Processor[S] {
type RootAggregate = S
}
val queries: Set[StatefulService[S, Request, Response]]
val reactors: Set[StatefulService[S, Event, Event]]
trait View[S] {
type RootAggregate = S
}
case class BoundedContext (
name: String,
version:Version,
processors: Set[Processor[_]],
views: Set[View[_]]
…
)
A Functional approach to reactive microservice architecture
A Functional approach to reactive microservice architecture
WE’RE HIRING!

More Related Content

PPTX
Serverless stateful
PDF
Patterns of Distributed Application Design
PDF
The art of the event streaming application: streams, stream processors and sc...
PDF
Kafka summit SF 2019 - the art of the event-streaming app
PPTX
Patterns of Distributed Application Design
PDF
Lagom : Reactive microservice framework
PDF
Async Microservices with Twitter's Finagle
PDF
Full Stack Reactive In Practice
Serverless stateful
Patterns of Distributed Application Design
The art of the event streaming application: streams, stream processors and sc...
Kafka summit SF 2019 - the art of the event-streaming app
Patterns of Distributed Application Design
Lagom : Reactive microservice framework
Async Microservices with Twitter's Finagle
Full Stack Reactive In Practice

Similar to A Functional approach to reactive microservice architecture (20)

PDF
Building event-driven (Micro)Services with Apache Kafka
PDF
Reactive Microservices with Spring 5: WebFlux
PDF
Reactor, Reactive streams and MicroServices
PDF
Innovation Without Asking Permission
PDF
Cloudstate—Towards Stateful Serverless
PDF
Event Driven-Architecture from a Scalability perspective
KEY
Event Driven Architecture
PDF
Builiding Modular monoliths that can scale to microservices. JBCNConf 2021
PDF
Devoxx London 2017 - Rethinking Services With Stateful Streams
PPTX
Serverless Stateful Architecture
PPTX
Message passing & NoSQL (in English)
PPT
Reactive programming with examples
PDF
Becoming reactive without overreacting (@pavlobaron)
PPTX
Introduction to Microservices Patterns
PPTX
Introduction to Microservices Patterns
PPTX
The Big Data Stack
PDF
A Message-Passing Model For Service Oriented Computing
PDF
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
PPTX
Software architecture for data applications
PPTX
Siddhi: A Second Look at Complex Event Processing Implementations
Building event-driven (Micro)Services with Apache Kafka
Reactive Microservices with Spring 5: WebFlux
Reactor, Reactive streams and MicroServices
Innovation Without Asking Permission
Cloudstate—Towards Stateful Serverless
Event Driven-Architecture from a Scalability perspective
Event Driven Architecture
Builiding Modular monoliths that can scale to microservices. JBCNConf 2021
Devoxx London 2017 - Rethinking Services With Stateful Streams
Serverless Stateful Architecture
Message passing & NoSQL (in English)
Reactive programming with examples
Becoming reactive without overreacting (@pavlobaron)
Introduction to Microservices Patterns
Introduction to Microservices Patterns
The Big Data Stack
A Message-Passing Model For Service Oriented Computing
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Software architecture for data applications
Siddhi: A Second Look at Complex Event Processing Implementations
Ad

More from J On The Beach (20)

PDF
Massively scalable ETL in real world applications: the hard way
PPTX
Big Data On Data You Don’t Have
PPTX
Acoustic Time Series in Industry 4.0: Improved Reliability and Cyber-Security...
PDF
Pushing it to the edge in IoT
PDF
Drinking from the firehose, with virtual streams and virtual actors
PDF
How do we deploy? From Punched cards to Immutable server pattern
PDF
Java, Turbocharged
PDF
When Cloud Native meets the Financial Sector
PDF
The big data Universe. Literally.
PDF
Streaming to a New Jakarta EE
PDF
The TIPPSS Imperative for IoT - Ensuring Trust, Identity, Privacy, Protection...
PDF
Pushing AI to the Client with WebAssembly and Blazor
PDF
Axon Server went RAFTing
PDF
The Six Pitfalls of building a Microservices Architecture (and how to avoid t...
PDF
Madaari : Ordering For The Monkeys
PDF
Servers are doomed to fail
PDF
Interaction Protocols: It's all about good manners
PDF
A race of two compilers: GraalVM JIT versus HotSpot JIT C2. Which one offers ...
PDF
Leadership at every level
PDF
Machine Learning: The Bare Math Behind Libraries
Massively scalable ETL in real world applications: the hard way
Big Data On Data You Don’t Have
Acoustic Time Series in Industry 4.0: Improved Reliability and Cyber-Security...
Pushing it to the edge in IoT
Drinking from the firehose, with virtual streams and virtual actors
How do we deploy? From Punched cards to Immutable server pattern
Java, Turbocharged
When Cloud Native meets the Financial Sector
The big data Universe. Literally.
Streaming to a New Jakarta EE
The TIPPSS Imperative for IoT - Ensuring Trust, Identity, Privacy, Protection...
Pushing AI to the Client with WebAssembly and Blazor
Axon Server went RAFTing
The Six Pitfalls of building a Microservices Architecture (and how to avoid t...
Madaari : Ordering For The Monkeys
Servers are doomed to fail
Interaction Protocols: It's all about good manners
A race of two compilers: GraalVM JIT versus HotSpot JIT C2. Which one offers ...
Leadership at every level
Machine Learning: The Bare Math Behind Libraries
Ad

Recently uploaded (20)

PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
A Presentation on Artificial Intelligence
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Encapsulation theory and applications.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Empathic Computing: Creating Shared Understanding
Assigned Numbers - 2025 - Bluetooth® Document
A Presentation on Artificial Intelligence
Advanced methodologies resolving dimensionality complications for autism neur...
Reach Out and Touch Someone: Haptics and Empathic Computing
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
MYSQL Presentation for SQL database connectivity
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Machine learning based COVID-19 study performance prediction
Dropbox Q2 2025 Financial Results & Investor Presentation
Unlocking AI with Model Context Protocol (MCP)
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
20250228 LYD VKU AI Blended-Learning.pptx
MIND Revenue Release Quarter 2 2025 Press Release
The AUB Centre for AI in Media Proposal.docx
Encapsulation theory and applications.pdf

A Functional approach to reactive microservice architecture

  • 1. Patrick Di Loreto Jose Luis Escanciano J on the Beach Malaga – 24/05/2018 https://github.com/patricknoir/reactive-platform
  • 3. Patrick Di Loreto CTO Jose Luis Escanciano Chief Architect
  • 4. Response in a timely manner Responsive under failure scenariosResponsive under load Enabler for responsiveness
  • 7. § When implementing a system, we translate the reality into software that resemble the original business processes as much as possible. § Domain is an area of interest for the business. § Model is a set of abstractions and behaviors that reflect the real world. § Domain-Model is a blueprint of the entities and their relationships in a given domain, together with the following important details: § Entities that belong to the domain. § Interactions between the entities. § Ubiquitous language / Vocabulary of the domain. § Assumptions and constraints relevant to the domain.
  • 9. § Value Object: Immutable item defined uniquely by the values of its attributes. If an attribute changes, we’d be speaking of a different value object. § Entity: Item representing a subject in the reality which state is managed across his lifetime by its identity. Despite a change on its attributes, the entity is always identified by the same id. § Aggregate: Unit of consistency in your model, which inherently has a root aggregate – entity used to refer to the aggregate itself. § Service: Describes the behavior and constraints within the domain – define the use cases in the business logic.
  • 10. § Bounded Context refers to a specific domain model, which is part of the whole domain. § Bounded contexts are intended to be self-contained (standalone module). § Which doesn’t mean they’re isolated, actually, bounded contexts quite often interact between each other in the whole domain, but it’s key to: § Keep them as loosely coupled as possible. § Reduce the interactions between them to the minimum. § Ensure communication between them are decoupled in space and time.
  • 14. § Has a name § Is a function from In to Out § Service[-In, +Out](name: String, f: In => Out)
  • 15. § Sometime services have to handle a state, so in order to elaborate a computation: they need to know the current state and they will also produce an output state. type StatefulService[S, Input, Output] = Service[(S, Input), (S, Output)] class Service[In, Out](name: String, f: In => Out) type In = (S, Input) type Out = (S, Output)
  • 16. type In = (S, I) type Out = (S, O) class Service[In, Out](name: String, f: In => Out) f: (S, I) => (S, O) f: I => S => (S, O) // Currying: I => (S => (S,O)) f: I => State[S, O] // S => (S,O) = State[S,O] class StatefulService[S, I, O](name: String, f: I => State[S, O])
  • 17. class Service[In, Out](name: String, f: In => Out) type ReactiveService[I, O] = Service[I, Future[O]] val f: I => Future[O] type ReactiveStatefulService[S, I, E] = StatefulService[I, Future[State[S, E]]] val f: I => Future[State[S, E]] O = State[S, E]
  • 18. type Cmd[S] = StatefulService[S, Command, Event] val f: Command => State[S, Event] // f: (S,Command) => (S,Event) type Evt[S] = StatefulService[S, Event, Event] val f: Event => State[S, Event] // f: (S,Event) => (S,Event) type Ask[S] = StatefulService[S, Request, Response] val f: Request => State[S, Response] // f: (S,Request) => (_,Response)
  • 19. § A microservice is a component developed to serve a specific functionaly in an effectively manner. Is a set of services (as we defined) that will deal on a specific problem. § CQRS: § Command § Query § Responsibility § Segregation § Encourage Separation of concerns between write and read models. § This separation can be extended into the microservices level where we will have: § Processors – which will manage the write model (deal with Commands) § Views – which will manage the read model (deal with Queries)
  • 20. val modifiers: Set[StatefulService[S, Command, Event]] val reactors: Set[StatefulService[S, Event, Event]] trait Processor[S] { type RootAggregate = S }
  • 21. val queries: Set[StatefulService[S, Request, Response]] val reactors: Set[StatefulService[S, Event, Event]] trait View[S] { type RootAggregate = S }
  • 22. case class BoundedContext ( name: String, version:Version, processors: Set[Processor[_]], views: Set[View[_]] … )