SlideShare a Scribd company logo
https://github.com/patricknoir/reactive-platform
Patrick Di Loreto
CTO Addison Global (MoPlay)
https://github.com/patricknoir
http://patricknoir.blogspot.com
@patricknoir
Serverless stateful
Serverless stateful
Serverless stateful
 This architecture was designed for
system pre smart phone generation
 Need for customer acquisition
=> need for SCALABILITY
 Availability became more important
than Consistency (CAP theorem)
Response in a
timely manner
Responsive under
failure scenariosResponsive
under load
Enabler for
responsiveness
Monolithic Microservices
 Average system utilization across organization is 15% to 20%
 The ideal should be around 80%
20% of IT budgets go to operations
“We have created:
Large
Underutilized
Complex
Environments which are costly to maintain”
In => Out
In
Stateful
Out
Database
In => Out
In
Stateless
FaaS
Out
 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])
Serverless stateful
Instruction Time
Execute typical instruction 1/1,000,000,000 = 1 nanosec
Fetch from L1 cache memory 0.5 nanosec
Branch misprediction 5 nanosec
Fetch from L2 cache memory 7 nanosec
Mutex lock/unlock 25 nanosec
Fetch from main memory 100 nanosec
Send 2K bytes over 1Gbps network 20,000 nanosec (20µs)
Read 1MB sequentially from memory 250,000 nanosec (250µs)
Fetch from new disk location (seek) 8,000,000 (8ms)
Read 1MB sequentially from disk 20,000,000 nanosec (20ms)
Send packet US to Europe and back 150,000,000 nanosec (150ms)
Instruction Time
Execute typical instruction 1 s
Fetch from L1 cache memory 0.5 s
Branch misprediction 5 s
Fetch from L2 cache memory 7 s
Mutex lock/unlock ½ s
Fetch from main memory 1½ min
Send 2K bytes over 1Gbps network 5½ hours
Read 1MB sequentially from memory 3 days
Fetch from new disk location (seek) 13 weeks
Read 1MB sequentially from disk 6½ months
Send packet US to Europe and back 5 years
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]
f: (S, Command) => (S, Event)
val f: Command => State[S, Event]
type Cmd[S] = StatefulService[S, Command, Event]
f: (S, Event) => (S, Event)
val f: Event => State[S, Event]
type Evt[S] = StatefulService[S, Event, Event]
f: (S, Request) => (_, Response)
val f: Request => State[S, Response]
type Ask[S] = StatefulService[S, Request, Response]
(Wallet(id=123, balance=5), DepositCmd(walletId=123, amount=10)) => (Wallet(id=123, balance=15), DepositEvt(walletId=123, amount=10))
(Wallet(id=123, balance=15), SettleWinEvt(walletId=123, amount=10)) => (Wallet(id=123, balance=25), WinSettledEvt(walletId=123, amount=1
(Wallet(id=123, balance=15), GetBalanceReq(walletId=123)) => (_, GetBalanceResp(walletId=123, amount=25))
val reactors: Set[(S, Event) => (S, Event)]val reactors: Set[StatefulService[S, Event, Event]]
val modifiers: Set[StatefulService[S, Command, Event]]val modifiers: Set[(S, Command) => (S, Event)]
trait Processor[S] {
type RootAggregate = S
}
trait View[S] {
type RootAggregate = S
}
val queries: Set[(S, Request) => Response]val queries: Set[StatefulService[S, Request, Response]]
val reactors: Set[(S, Event) => (S, Event)]val reactors: Set[StatefulService[S, Event, Event]]
Processor Actor
Cmd[Debit(10)]
Evt[Credit(50)]
Evt[Debit(20)]
Evt[Credit(15)]
Evt[Debit(10)]
publish
process
View Actor
request
respond
Client App
notify
Actor
[View1]Actor
[View1]Actor
[View1]
PROCESSORS
(WRITE)
VIEWS
(READ)
(Wallet, Cmd) => (Wallet Evt)
(List[Wallet], Req) => Res
(List[Wallet], Evt) => List[Wallet]
Serverless stateful
Node 1 Node 2 Node 3
 Deployment CI/CD
 Monitoring
 Logging
 Tracing
 Security Auth/Autz
MessageFabric
APIGateway
Pub
Int
Ext
Computation Farm
RDS KV GRAPH HDFS/S3
Repository
Kubernetes
Serverless stateful
Node
/logs
POD PODPOD
Infra Kubernetes
Serverless stateful
Federated Prometheus
 Mobile growth changed customer behavior, new needs:
 SCALABILITY is a must to run your business
 Shift on priorities: AVAILABILITY over CONSISTENCY (CAP)
 Infrastructure complexity and operational costs increase with MicroService
Architecture vs Monolith
 Serverless is the way to go but are not yet good enough to manage State
 https://cloudstate.io/
 https://github.com/patricknoir/reactive-platform

More Related Content

PPTX
Serverless Stateful Architecture
PDF
MongoDB Oplog入門
PDF
Debugging: Rules And Tools - PHPTek 11 Version
PDF
Teaching Your Machine To Find Fraudsters
PDF
ng-conf 2017: Angular Mischief Maker Slides
PDF
MongoUK - PHP Development
PDF
JavaSE7 Launch Event: Java7xGroovy
PPTX
What is row level isolation on cassandra
Serverless Stateful Architecture
MongoDB Oplog入門
Debugging: Rules And Tools - PHPTek 11 Version
Teaching Your Machine To Find Fraudsters
ng-conf 2017: Angular Mischief Maker Slides
MongoUK - PHP Development
JavaSE7 Launch Event: Java7xGroovy
What is row level isolation on cassandra

What's hot (20)

PDF
Stop Guessing and Start Measuring - Benchmarking Practice (Poly Version)
PDF
How fast is it really? Benchmarking in Practice (Ruby Version)
PDF
The Ring programming language version 1.9 book - Part 71 of 210
PPTX
20150724 jason winston js
PDF
The Ring programming language version 1.6 book - Part 48 of 189
PDF
Intro to OTP in Elixir
PDF
PDF
Seu primeiro loop com Python AsyncIO - TDC 2016
PDF
ES6 generators
PPTX
Async Redux Actions With RxJS - React Rally 2016
PPTX
Python queue solution with asyncio and kafka
PDF
[131]해커의 관점에서 바라보기
PDF
Mongo à la Resque
TXT
Flare3d jiglib.as
PPTX
Async Frontiers
PDF
はじめてのGroovy
PDF
Do you Promise?
PDF
Принципы и практики разработки ПО / Principles and practices of software deve...
PDF
Solr and Lucene at Etsy - By Gregg Donovan
PDF
Solr & Lucene at Etsy
Stop Guessing and Start Measuring - Benchmarking Practice (Poly Version)
How fast is it really? Benchmarking in Practice (Ruby Version)
The Ring programming language version 1.9 book - Part 71 of 210
20150724 jason winston js
The Ring programming language version 1.6 book - Part 48 of 189
Intro to OTP in Elixir
Seu primeiro loop com Python AsyncIO - TDC 2016
ES6 generators
Async Redux Actions With RxJS - React Rally 2016
Python queue solution with asyncio and kafka
[131]해커의 관점에서 바라보기
Mongo à la Resque
Flare3d jiglib.as
Async Frontiers
はじめてのGroovy
Do you Promise?
Принципы и практики разработки ПО / Principles and practices of software deve...
Solr and Lucene at Etsy - By Gregg Donovan
Solr & Lucene at Etsy
Ad

Similar to Serverless stateful (20)

PDF
A Functional approach to reactive microservice architecture
PDF
Aecor. Purely functional event sourcing
PDF
Async Microservices with Twitter's Finagle
PDF
Reactor, Reactive streams and MicroServices
PDF
Reactive Design Patterns by Dr.Roland Kuhn
PDF
Reactive Design Patterns — J on the Beach
PDF
Scala.io
PDF
Functional Systems @ Twitter
PDF
Large volume data analysis on the Typesafe Reactive Platform - Big Data Scala...
PDF
Facebook C++网络库Wangle调研
PDF
Akka with Scala
PDF
High Performance Systems Without Tears - Scala Days Berlin 2018
PDF
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
PDF
Reactive Design Patterns
PPTX
About time
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
PDF
Event Sourcing and Functional Programming
PDF
Functional Programming & Event Sourcing - a pair made in heaven
PDF
Cloudstate—Towards Stateful Serverless
A Functional approach to reactive microservice architecture
Aecor. Purely functional event sourcing
Async Microservices with Twitter's Finagle
Reactor, Reactive streams and MicroServices
Reactive Design Patterns by Dr.Roland Kuhn
Reactive Design Patterns — J on the Beach
Scala.io
Functional Systems @ Twitter
Large volume data analysis on the Typesafe Reactive Platform - Big Data Scala...
Facebook C++网络库Wangle调研
Akka with Scala
High Performance Systems Without Tears - Scala Days Berlin 2018
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Reactive Design Patterns
About time
The art of the event streaming application: streams, stream processors and sc...
Kafka summit SF 2019 - the art of the event-streaming app
Event Sourcing and Functional Programming
Functional Programming & Event Sourcing - a pair made in heaven
Cloudstate—Towards Stateful Serverless
Ad

Recently uploaded (20)

PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Nekopoi APK 2025 free lastest update
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
System and Network Administration Chapter 2
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Transform Your Business with a Software ERP System
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPT
Introduction Database Management System for Course Database
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Understanding Forklifts - TECH EHS Solution
PDF
medical staffing services at VALiNTRY
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Nekopoi APK 2025 free lastest update
Computer Software and OS of computer science of grade 11.pptx
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Design an Analysis of Algorithms II-SECS-1021-03
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
2025 Textile ERP Trends: SAP, Odoo & Oracle
Upgrade and Innovation Strategies for SAP ERP Customers
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
System and Network Administration Chapter 2
Softaken Excel to vCard Converter Software.pdf
Transform Your Business with a Software ERP System
How to Migrate SBCGlobal Email to Yahoo Easily
Introduction Database Management System for Course Database
Which alternative to Crystal Reports is best for small or large businesses.pdf
Understanding Forklifts - TECH EHS Solution
medical staffing services at VALiNTRY
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
VVF-Customer-Presentation2025-Ver1.9.pptx
Wondershare Filmora 15 Crack With Activation Key [2025

Serverless stateful

  • 2. Patrick Di Loreto CTO Addison Global (MoPlay) https://github.com/patricknoir http://patricknoir.blogspot.com @patricknoir
  • 6.  This architecture was designed for system pre smart phone generation  Need for customer acquisition => need for SCALABILITY  Availability became more important than Consistency (CAP theorem)
  • 7. Response in a timely manner Responsive under failure scenariosResponsive under load Enabler for responsiveness
  • 9.  Average system utilization across organization is 15% to 20%  The ideal should be around 80% 20% of IT budgets go to operations “We have created: Large Underutilized Complex Environments which are costly to maintain”
  • 10. In => Out In Stateful Out Database In => Out In Stateless FaaS Out
  • 11.  Has a name  Is a function from In to Out  Service[-In, +Out](name: String, f: In => Out)
  • 12.  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)
  • 13. 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])
  • 15. Instruction Time Execute typical instruction 1/1,000,000,000 = 1 nanosec Fetch from L1 cache memory 0.5 nanosec Branch misprediction 5 nanosec Fetch from L2 cache memory 7 nanosec Mutex lock/unlock 25 nanosec Fetch from main memory 100 nanosec Send 2K bytes over 1Gbps network 20,000 nanosec (20µs) Read 1MB sequentially from memory 250,000 nanosec (250µs) Fetch from new disk location (seek) 8,000,000 (8ms) Read 1MB sequentially from disk 20,000,000 nanosec (20ms) Send packet US to Europe and back 150,000,000 nanosec (150ms)
  • 16. Instruction Time Execute typical instruction 1 s Fetch from L1 cache memory 0.5 s Branch misprediction 5 s Fetch from L2 cache memory 7 s Mutex lock/unlock ½ s Fetch from main memory 1½ min Send 2K bytes over 1Gbps network 5½ hours Read 1MB sequentially from memory 3 days Fetch from new disk location (seek) 13 weeks Read 1MB sequentially from disk 6½ months Send packet US to Europe and back 5 years
  • 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. f: (S, Command) => (S, Event) val f: Command => State[S, Event] type Cmd[S] = StatefulService[S, Command, Event] f: (S, Event) => (S, Event) val f: Event => State[S, Event] type Evt[S] = StatefulService[S, Event, Event] f: (S, Request) => (_, Response) val f: Request => State[S, Response] type Ask[S] = StatefulService[S, Request, Response] (Wallet(id=123, balance=5), DepositCmd(walletId=123, amount=10)) => (Wallet(id=123, balance=15), DepositEvt(walletId=123, amount=10)) (Wallet(id=123, balance=15), SettleWinEvt(walletId=123, amount=10)) => (Wallet(id=123, balance=25), WinSettledEvt(walletId=123, amount=1 (Wallet(id=123, balance=15), GetBalanceReq(walletId=123)) => (_, GetBalanceResp(walletId=123, amount=25))
  • 19. val reactors: Set[(S, Event) => (S, Event)]val reactors: Set[StatefulService[S, Event, Event]] val modifiers: Set[StatefulService[S, Command, Event]]val modifiers: Set[(S, Command) => (S, Event)] trait Processor[S] { type RootAggregate = S }
  • 20. trait View[S] { type RootAggregate = S } val queries: Set[(S, Request) => Response]val queries: Set[StatefulService[S, Request, Response]] val reactors: Set[(S, Event) => (S, Event)]val reactors: Set[StatefulService[S, Event, Event]]
  • 21. Processor Actor Cmd[Debit(10)] Evt[Credit(50)] Evt[Debit(20)] Evt[Credit(15)] Evt[Debit(10)] publish process View Actor request respond Client App notify Actor [View1]Actor [View1]Actor [View1] PROCESSORS (WRITE) VIEWS (READ) (Wallet, Cmd) => (Wallet Evt) (List[Wallet], Req) => Res (List[Wallet], Evt) => List[Wallet]
  • 23. Node 1 Node 2 Node 3
  • 24.  Deployment CI/CD  Monitoring  Logging  Tracing  Security Auth/Autz
  • 30.  Mobile growth changed customer behavior, new needs:  SCALABILITY is a must to run your business  Shift on priorities: AVAILABILITY over CONSISTENCY (CAP)  Infrastructure complexity and operational costs increase with MicroService Architecture vs Monolith  Serverless is the way to go but are not yet good enough to manage State  https://cloudstate.io/