SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Reactive programming with Spring
Webflux
Eonics Hack Night #21
João Esperancinha
joao.esperancinha@eonics.nl
Origins 1960
Jack Dennis:
● Data Flows concepts during the 1960’s at MIT
● Data stream concept and iteractions
● Data Flow years 1974 – 1975
● Roots in:
○ Asynchronous Digital Logic
○ Control Structures for Parallel Programming
○ Abstract Models for Concurrent Systems
○ Theory of Program Schemes
○ Structured Programming
○ Functional Programming
Ref: http://csg.csail.mit.edu/Dataflow/talks/DennisTalk.pdf
Origins 2010
Eric Meijer:
● Coined the term Reactive Programming in 2010
● Microsoft included C#, Visual Basic, LINQ, Volta
● Reactive programming framework
● Reactive Extensions for .NET.
● Dataflow programming on steroids
Ref: https://channel9.msdn.com/Blogs/Charles/Erik-Meijer-Rx-in-15-Minutes
Reactive Manifesto
Principles (applies to system and applications):
● Responsive
○ It needs to respond quickly. The time of the request itself is independent of this.
● Resilient
○ It must respond well and support Back-Pressure
○ Messages in control
○ Avoid catastrophic failure
● Elastic
○ Automatic Generation of resources. More threads in our case.
● Message Driven
○ Publisher/Subscriber
Ref: https://www.reactivemanifesto.org/
Spring WebFlux Basics
Observer Pattern
Is a behavioral design pattern that lets you define a subscription mechanism to
notify multiple objects about any events that happen to the object they’re
observing.
In other words, we are going to do declarative programming instead of imperative
programming.
Ref: https://en.wikipedia.org/wiki/Observer_pattern
Spring WebFlux Publishers
● Flux
○ A publisher for a stream of objects
○ Used to create lists of objects]
○ Processes one stream end to end
○ Handles stream events
● Mono
○ A publisher for a single object
○ Handles object events
Ref:https://docs.spring.io/spring/docs/current/spring-framework-reference/web-
reactive.html
Flux.just, Flux.from, Flux.fromIterable,
Flux.fromArray, Flux.fromStream,
Flux.zip
Mono.just, Mono.from,
Mono.fromCallable, Mono.zip,
Mono.fromFuture, Mono.fromDirect,
Mono.fromRunnable
Spring WebFlux Parallelism
● Flux and ParallelFlux
○ .parallel(parallelism).runOn(Schedulers.parallel())
● Mono
○ .subscribeOn(Schedulers.parallel())
Ref:https://docs.spring.io/spring/docs/current/spring-framework-reference/web-
reactive.html
Blockhound
● Test Library
● Needs to be installed:
● Detects Blocking calls:
static {
BlockHound.install();
}
Mono.delay(Duration.ofMillis(1))
.doOnNext(it -> {
try {
catController.getCatByIdI(1L);
} catch (IOException e) {
throw new RuntimeException(e);
}
})
.block();
Concerts Project
Tests with JMeter
● Load tests
● Making the world a better place by registering thousands of Nicky Minajs 😉
{
"name": "Nicky Minaj",
"gender": "FEMALE",
"careerStart": 1000,
"birthDate": "a date",
"birthCity": "Port of Spain",
"country": "Trinidad en Tobago",
"keywords": "Rap"
}
X 1000 / s
Comparing Blocking MVC and Reactive MVC
Results of analysis of Response Times
Comparing Blocking MVC and Reactive MVC
Results of analysis of number of requests:
Label # Samples Average Min Max Std. Dev. Error % Throughput Received KB/sec Sent KB/sec Avg. Bytes
WebFlux GET artists 1818 1714 7 22403 2846.73 0.000% 39.69346 4512.75 5.31 116418.6
MVC Get Artists 1510 3320 7 16520 3516.68 0.066% 33.09589 5812.04 4.42 179826.8
WebFlux Post artists 1394 1425 4 14886 2597.78 0.000% 30.97984 10.26 12.49 339.1
MVC Post Artists 1179 2813 5 20344 3265.32 0.000% 26.18371 8.69 10.56 340.0
TOTAL 5901 2276 4 22403 3160.81 0.017% 128.35795 10282.47 32.26 82030.3
Let’s Code!
● Cat Care Center
● Bocco and Zuu have been found
● The application is blocking!
● Let’s make it reactive!
● Checkout the repo
● Checkout branch exercise
● Build will fail!
● Make the code reactive!
● Build will run!
git clone git@bitbucket.org:jesperancinha/eonics-hacknight-
webflux.git
git checkout exercise
mvn clean install
Q?
References
● https://content.pivotal.io/springone-platform-2018/full-stack-reactive-with-react-and-spring-webflux
● https://bitbucket.org/jesperancinha/eonics-hacknight-webflux
● https://github.com/reactor/BlockHound
● https://github.com/jesperancinha/sea-shell-archiver
● https://github.com/jesperancinha/concert-demos-root
● http://csg.csail.mit.edu/Dataflow/talks/DennisTalk.pdf
● https://medium.com/swlh/comparing-webflux-and-spring-mvc-with-jmeter-79dc134c3c04
● https://medium.com/swlh/reactive-programming-applied-to-legacy-services-a-webflux-example-4d1c2ad40bd4
● https://en.wikipedia.org/wiki/Jack_Dennis
● https://www.reactivemanifesto.org/
● https://refactoring.guru/design-patterns/observer
● https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.csnip.org%2Fgeneral-
faqs&psig=AOvVaw1jPWBfSEBh65Oci1MZyq9E&ust=1582141566798000&source=images&cd=vfe&ved=0CAIQjRx
qFwoTCPiZyOPu2-cCFQAAAAAdAAAAABBI
● https://www.instagram.com/pechanko_bocco/?hl=nl
João Esperancinha joao.esperancinha@eonics.nl

Weitere ähnliche Inhalte

Ähnlich wie Reactive programming with Spring Webflux.pptx

Fight with Metaspace OOM
Fight with Metaspace OOMFight with Metaspace OOM
Fight with Metaspace OOMLeon Chen
 
Programming for non tech entrepreneurs
Programming for non tech entrepreneursProgramming for non tech entrepreneurs
Programming for non tech entrepreneursRodrigo Gil
 
Eclipse IoT Talk (Montreal JUG)
Eclipse IoT Talk (Montreal JUG)Eclipse IoT Talk (Montreal JUG)
Eclipse IoT Talk (Montreal JUG)Mike Milinkovich
 
Continuous Delivery: 5 years later (Incontro DevOps 2018)
Continuous Delivery: 5 years later (Incontro DevOps 2018)Continuous Delivery: 5 years later (Incontro DevOps 2018)
Continuous Delivery: 5 years later (Incontro DevOps 2018)Giovanni Toraldo
 
Introduction to react native @ TIC NUST
Introduction to react native @ TIC NUSTIntroduction to react native @ TIC NUST
Introduction to react native @ TIC NUSTWaqqas Jabbar
 
Elasticsearch Performance Testing and Scaling @ Signal
Elasticsearch Performance Testing and Scaling @ SignalElasticsearch Performance Testing and Scaling @ Signal
Elasticsearch Performance Testing and Scaling @ SignalJoachim Draeger
 
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...Theo Jungeblut
 
Reaktive Programmierung mit den Reactive Extensions (Rx)
Reaktive Programmierung mit den Reactive Extensions (Rx)Reaktive Programmierung mit den Reactive Extensions (Rx)
Reaktive Programmierung mit den Reactive Extensions (Rx)NETUserGroupBern
 
Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016maiktoepfer
 
Monitoring Big Data Systems - "The Simple Way"
Monitoring Big Data Systems - "The Simple Way"Monitoring Big Data Systems - "The Simple Way"
Monitoring Big Data Systems - "The Simple Way"Demi Ben-Ari
 
Practicing at the Cutting Edge
Practicing at the Cutting EdgePracticing at the Cutting Edge
Practicing at the Cutting EdgeC4Media
 
[Bop] Block Oriented Programming Automating Data-only Attacks
[Bop] Block Oriented Programming Automating Data-only Attacks[Bop] Block Oriented Programming Automating Data-only Attacks
[Bop] Block Oriented Programming Automating Data-only Attacks星曼 陈
 
DevOps Italian Tech Week 26/06/2019
DevOps Italian Tech Week 26/06/2019DevOps Italian Tech Week 26/06/2019
DevOps Italian Tech Week 26/06/2019Fabio Todaro
 
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the UglyKotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the UglyHaim Yadid
 
Machine Learning with Python
Machine Learning with PythonMachine Learning with Python
Machine Learning with PythonGLC Networks
 
Clean Code - Design Patterns and Best Practices for Bay.NET SF User Group (01...
Clean Code - Design Patterns and Best Practices for Bay.NET SF User Group (01...Clean Code - Design Patterns and Best Practices for Bay.NET SF User Group (01...
Clean Code - Design Patterns and Best Practices for Bay.NET SF User Group (01...Theo Jungeblut
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React NativeWaqqas Jabbar
 
Cloud Native Applications on Kubernetes: a DevOps Approach
Cloud Native Applications on Kubernetes: a DevOps ApproachCloud Native Applications on Kubernetes: a DevOps Approach
Cloud Native Applications on Kubernetes: a DevOps ApproachNicola Ferraro
 

Ähnlich wie Reactive programming with Spring Webflux.pptx (20)

Fight with Metaspace OOM
Fight with Metaspace OOMFight with Metaspace OOM
Fight with Metaspace OOM
 
Programming for non tech entrepreneurs
Programming for non tech entrepreneursProgramming for non tech entrepreneurs
Programming for non tech entrepreneurs
 
Eclipse IoT Talk (Montreal JUG)
Eclipse IoT Talk (Montreal JUG)Eclipse IoT Talk (Montreal JUG)
Eclipse IoT Talk (Montreal JUG)
 
Node.js concurrency
Node.js concurrencyNode.js concurrency
Node.js concurrency
 
Continuous Delivery: 5 years later (Incontro DevOps 2018)
Continuous Delivery: 5 years later (Incontro DevOps 2018)Continuous Delivery: 5 years later (Incontro DevOps 2018)
Continuous Delivery: 5 years later (Incontro DevOps 2018)
 
Introduction to react native @ TIC NUST
Introduction to react native @ TIC NUSTIntroduction to react native @ TIC NUST
Introduction to react native @ TIC NUST
 
Elasticsearch Performance Testing and Scaling @ Signal
Elasticsearch Performance Testing and Scaling @ SignalElasticsearch Performance Testing and Scaling @ Signal
Elasticsearch Performance Testing and Scaling @ Signal
 
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
 
Reaktive Programmierung mit den Reactive Extensions (Rx)
Reaktive Programmierung mit den Reactive Extensions (Rx)Reaktive Programmierung mit den Reactive Extensions (Rx)
Reaktive Programmierung mit den Reactive Extensions (Rx)
 
Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016
 
Monitoring Big Data Systems - "The Simple Way"
Monitoring Big Data Systems - "The Simple Way"Monitoring Big Data Systems - "The Simple Way"
Monitoring Big Data Systems - "The Simple Way"
 
Practicing at the Cutting Edge
Practicing at the Cutting EdgePracticing at the Cutting Edge
Practicing at the Cutting Edge
 
Revealing ALLSTOCKER
Revealing ALLSTOCKERRevealing ALLSTOCKER
Revealing ALLSTOCKER
 
[Bop] Block Oriented Programming Automating Data-only Attacks
[Bop] Block Oriented Programming Automating Data-only Attacks[Bop] Block Oriented Programming Automating Data-only Attacks
[Bop] Block Oriented Programming Automating Data-only Attacks
 
DevOps Italian Tech Week 26/06/2019
DevOps Italian Tech Week 26/06/2019DevOps Italian Tech Week 26/06/2019
DevOps Italian Tech Week 26/06/2019
 
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the UglyKotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
 
Machine Learning with Python
Machine Learning with PythonMachine Learning with Python
Machine Learning with Python
 
Clean Code - Design Patterns and Best Practices for Bay.NET SF User Group (01...
Clean Code - Design Patterns and Best Practices for Bay.NET SF User Group (01...Clean Code - Design Patterns and Best Practices for Bay.NET SF User Group (01...
Clean Code - Design Patterns and Best Practices for Bay.NET SF User Group (01...
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
Cloud Native Applications on Kubernetes: a DevOps Approach
Cloud Native Applications on Kubernetes: a DevOps ApproachCloud Native Applications on Kubernetes: a DevOps Approach
Cloud Native Applications on Kubernetes: a DevOps Approach
 

Mehr von João Esperancinha

Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialJoão Esperancinha
 
Fields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptxFields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptxJoão Esperancinha
 
Demystifying Co, Contra, In Kotlin modifier keywords.pptx
Demystifying Co, Contra, In Kotlin modifier keywords.pptxDemystifying Co, Contra, In Kotlin modifier keywords.pptx
Demystifying Co, Contra, In Kotlin modifier keywords.pptxJoão Esperancinha
 
Unlocking the Power of Kotlin Channels.pptx
Unlocking the Power of Kotlin Channels.pptxUnlocking the Power of Kotlin Channels.pptx
Unlocking the Power of Kotlin Channels.pptxJoão Esperancinha
 
Exploring Tailrec Through Time Until Kotlin.pptx
Exploring Tailrec Through Time Until Kotlin.pptxExploring Tailrec Through Time Until Kotlin.pptx
Exploring Tailrec Through Time Until Kotlin.pptxJoão Esperancinha
 
KONNECT Kong-Presentation How to protect web applications
KONNECT Kong-Presentation How to protect web applicationsKONNECT Kong-Presentation How to protect web applications
KONNECT Kong-Presentation How to protect web applicationsJoão Esperancinha
 

Mehr von João Esperancinha (7)

Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorial
 
Fields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptxFields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptx
 
Demystifying Co, Contra, In Kotlin modifier keywords.pptx
Demystifying Co, Contra, In Kotlin modifier keywords.pptxDemystifying Co, Contra, In Kotlin modifier keywords.pptx
Demystifying Co, Contra, In Kotlin modifier keywords.pptx
 
Unlocking the Power of Kotlin Channels.pptx
Unlocking the Power of Kotlin Channels.pptxUnlocking the Power of Kotlin Channels.pptx
Unlocking the Power of Kotlin Channels.pptx
 
Exploring Tailrec Through Time Until Kotlin.pptx
Exploring Tailrec Through Time Until Kotlin.pptxExploring Tailrec Through Time Until Kotlin.pptx
Exploring Tailrec Through Time Until Kotlin.pptx
 
KONNECT Kong-Presentation How to protect web applications
KONNECT Kong-Presentation How to protect web applicationsKONNECT Kong-Presentation How to protect web applications
KONNECT Kong-Presentation How to protect web applications
 

Kürzlich hochgeladen

VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Roomishabajaj13
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGAPNIC
 
Denver Web Design brochure for public viewing
Denver Web Design brochure for public viewingDenver Web Design brochure for public viewing
Denver Web Design brochure for public viewingbigorange77
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024APNIC
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of indiaimessage0108
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Roomdivyansh0kumar0
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)Christopher H Felton
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...aditipandeya
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...APNIC
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)Damian Radcliffe
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Delhi Call girls
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一Fs
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 

Kürzlich hochgeladen (20)

Vip Call Girls Aerocity ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Aerocity ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Aerocity ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Aerocity ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOG
 
Denver Web Design brochure for public viewing
Denver Web Design brochure for public viewingDenver Web Design brochure for public viewing
Denver Web Design brochure for public viewing
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of india
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girls
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 

Reactive programming with Spring Webflux.pptx

  • 1. Reactive programming with Spring Webflux Eonics Hack Night #21 João Esperancinha joao.esperancinha@eonics.nl
  • 2. Origins 1960 Jack Dennis: ● Data Flows concepts during the 1960’s at MIT ● Data stream concept and iteractions ● Data Flow years 1974 – 1975 ● Roots in: ○ Asynchronous Digital Logic ○ Control Structures for Parallel Programming ○ Abstract Models for Concurrent Systems ○ Theory of Program Schemes ○ Structured Programming ○ Functional Programming Ref: http://csg.csail.mit.edu/Dataflow/talks/DennisTalk.pdf
  • 3. Origins 2010 Eric Meijer: ● Coined the term Reactive Programming in 2010 ● Microsoft included C#, Visual Basic, LINQ, Volta ● Reactive programming framework ● Reactive Extensions for .NET. ● Dataflow programming on steroids Ref: https://channel9.msdn.com/Blogs/Charles/Erik-Meijer-Rx-in-15-Minutes
  • 4. Reactive Manifesto Principles (applies to system and applications): ● Responsive ○ It needs to respond quickly. The time of the request itself is independent of this. ● Resilient ○ It must respond well and support Back-Pressure ○ Messages in control ○ Avoid catastrophic failure ● Elastic ○ Automatic Generation of resources. More threads in our case. ● Message Driven ○ Publisher/Subscriber Ref: https://www.reactivemanifesto.org/
  • 5. Spring WebFlux Basics Observer Pattern Is a behavioral design pattern that lets you define a subscription mechanism to notify multiple objects about any events that happen to the object they’re observing. In other words, we are going to do declarative programming instead of imperative programming. Ref: https://en.wikipedia.org/wiki/Observer_pattern
  • 6. Spring WebFlux Publishers ● Flux ○ A publisher for a stream of objects ○ Used to create lists of objects] ○ Processes one stream end to end ○ Handles stream events ● Mono ○ A publisher for a single object ○ Handles object events Ref:https://docs.spring.io/spring/docs/current/spring-framework-reference/web- reactive.html Flux.just, Flux.from, Flux.fromIterable, Flux.fromArray, Flux.fromStream, Flux.zip Mono.just, Mono.from, Mono.fromCallable, Mono.zip, Mono.fromFuture, Mono.fromDirect, Mono.fromRunnable
  • 7. Spring WebFlux Parallelism ● Flux and ParallelFlux ○ .parallel(parallelism).runOn(Schedulers.parallel()) ● Mono ○ .subscribeOn(Schedulers.parallel()) Ref:https://docs.spring.io/spring/docs/current/spring-framework-reference/web- reactive.html
  • 8. Blockhound ● Test Library ● Needs to be installed: ● Detects Blocking calls: static { BlockHound.install(); } Mono.delay(Duration.ofMillis(1)) .doOnNext(it -> { try { catController.getCatByIdI(1L); } catch (IOException e) { throw new RuntimeException(e); } }) .block();
  • 10. Tests with JMeter ● Load tests ● Making the world a better place by registering thousands of Nicky Minajs 😉 { "name": "Nicky Minaj", "gender": "FEMALE", "careerStart": 1000, "birthDate": "a date", "birthCity": "Port of Spain", "country": "Trinidad en Tobago", "keywords": "Rap" } X 1000 / s
  • 11. Comparing Blocking MVC and Reactive MVC Results of analysis of Response Times
  • 12. Comparing Blocking MVC and Reactive MVC Results of analysis of number of requests: Label # Samples Average Min Max Std. Dev. Error % Throughput Received KB/sec Sent KB/sec Avg. Bytes WebFlux GET artists 1818 1714 7 22403 2846.73 0.000% 39.69346 4512.75 5.31 116418.6 MVC Get Artists 1510 3320 7 16520 3516.68 0.066% 33.09589 5812.04 4.42 179826.8 WebFlux Post artists 1394 1425 4 14886 2597.78 0.000% 30.97984 10.26 12.49 339.1 MVC Post Artists 1179 2813 5 20344 3265.32 0.000% 26.18371 8.69 10.56 340.0 TOTAL 5901 2276 4 22403 3160.81 0.017% 128.35795 10282.47 32.26 82030.3
  • 13. Let’s Code! ● Cat Care Center ● Bocco and Zuu have been found ● The application is blocking! ● Let’s make it reactive! ● Checkout the repo ● Checkout branch exercise ● Build will fail! ● Make the code reactive! ● Build will run! git clone git@bitbucket.org:jesperancinha/eonics-hacknight- webflux.git git checkout exercise mvn clean install
  • 14. Q?
  • 15. References ● https://content.pivotal.io/springone-platform-2018/full-stack-reactive-with-react-and-spring-webflux ● https://bitbucket.org/jesperancinha/eonics-hacknight-webflux ● https://github.com/reactor/BlockHound ● https://github.com/jesperancinha/sea-shell-archiver ● https://github.com/jesperancinha/concert-demos-root ● http://csg.csail.mit.edu/Dataflow/talks/DennisTalk.pdf ● https://medium.com/swlh/comparing-webflux-and-spring-mvc-with-jmeter-79dc134c3c04 ● https://medium.com/swlh/reactive-programming-applied-to-legacy-services-a-webflux-example-4d1c2ad40bd4 ● https://en.wikipedia.org/wiki/Jack_Dennis ● https://www.reactivemanifesto.org/ ● https://refactoring.guru/design-patterns/observer ● https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.csnip.org%2Fgeneral- faqs&psig=AOvVaw1jPWBfSEBh65Oci1MZyq9E&ust=1582141566798000&source=images&cd=vfe&ved=0CAIQjRx qFwoTCPiZyOPu2-cCFQAAAAAdAAAAABBI ● https://www.instagram.com/pechanko_bocco/?hl=nl João Esperancinha joao.esperancinha@eonics.nl