Reactive Programming
A primer for Reactor
@pranavek
Enterprise Challenges
•Blocking IO
•Latency
•Imperative code
•Resource utilization
2
3
Improve responsiveness
•Concurrent programming?
•Parallel programming?
•Asynchronous programing?
4
5
6
Backpressure
7
8
9
Reactor
•Asynchronous
•Backpressure
•High level but high value abstraction
•Readable/composable
10
[ 0 | 1 | N ]
11
Mono
12
A publisher that produces 0 to 1 value. Operations that return a single element
use this type.
Flux
13
A publisher that produces 0 to N values. It could be unbounded. Operations that return
multiple elements use this type.
Mono<Void> mono = Mono.empty();
Mono<String> mono = Mono.just(”GoTo");
Flux<String> goto = Flux.just(”G2W", ”G2M", ”G2T");
Flux<String> flux = Flux.fromArray(new String[]{"A", "B", "C"});
Flux<String> flux = Flux.fromIterable(Arrays.asList("A", "B",));
14
Web Stack
15
16
WebClient
17
https://www.reactivemanifesto.org
https://projectreactor.io/docs/core/release/reference
https://rxmarbles.com
https://www.codingame.com/playgrounds/929/reactive-programming-
with-reactor-3/Intro
https://docs.spring.io/spring/docs/current/spring-framework-
reference/web-reactive.html
18
19

More Related Content

PDF
React meets o OCalm
PPTX
Reactive Extensions for JavaScript
PDF
Reactive programming using rx java & akka actors - pdx-scala - june 2014
PDF
RxJS - The Reactive Extensions for JavaScript
PPTX
Intro to RxJS
PPTX
Sync with async
PDF
Performance Modeling of Serverless Computing Platforms - CASCON2020 Workshop ...
PPTX
Reactive Programming and RxJS
React meets o OCalm
Reactive Extensions for JavaScript
Reactive programming using rx java & akka actors - pdx-scala - june 2014
RxJS - The Reactive Extensions for JavaScript
Intro to RxJS
Sync with async
Performance Modeling of Serverless Computing Platforms - CASCON2020 Workshop ...
Reactive Programming and RxJS

What's hot (20)

PDF
Flink Forward SF 2017: Kenneth Knowles - Back to Sessions overview
PPTX
Enhancements in Java 9 Streams
PPTX
Intro to Functional Programming with RxJava
PDF
Gatling @ Scala.Io 2013
PDF
Load test REST APIs using gatling
PPTX
End to end testing a web application with Clojure
PDF
Reactive cocoa
PDF
The Future starts with a Promise
PDF
Effective java item 80 and 81
PDF
OASGraph LoopBack 4 Integration
PDF
Async/Await Best Practices
PDF
Async/Await: TPL & Message Pumps
PPTX
Parallel Programming
PDF
Flink Forward Berlin 2017: Boris Lublinsky, Stavros Kontopoulos - Introducing...
PPTX
Reactive programming for java developers
PPT
C# Async on iOS and Android - Craig Dunn, Developer Evangelist at Xamarin
PDF
Reflection in Pharo5
PDF
Pharo Status ESUG 2014
ODP
Learning Kafka Streams with Scala
PPTX
C# Async on iOS and Android - Miguel de Icaza, CTO of Xamarin
Flink Forward SF 2017: Kenneth Knowles - Back to Sessions overview
Enhancements in Java 9 Streams
Intro to Functional Programming with RxJava
Gatling @ Scala.Io 2013
Load test REST APIs using gatling
End to end testing a web application with Clojure
Reactive cocoa
The Future starts with a Promise
Effective java item 80 and 81
OASGraph LoopBack 4 Integration
Async/Await Best Practices
Async/Await: TPL & Message Pumps
Parallel Programming
Flink Forward Berlin 2017: Boris Lublinsky, Stavros Kontopoulos - Introducing...
Reactive programming for java developers
C# Async on iOS and Android - Craig Dunn, Developer Evangelist at Xamarin
Reflection in Pharo5
Pharo Status ESUG 2014
Learning Kafka Streams with Scala
C# Async on iOS and Android - Miguel de Icaza, CTO of Xamarin
Ad

Similar to Reactive (20)

PDF
Reactive Applications in Java
PPTX
Reactive programming intro
PPTX
From Web to Flux @DevoxxBE 2023.pptx
PDF
Reactive Programming in Java and Spring Framework 5
PPTX
Reactive solutions using java 9 and spring reactor
PDF
Spring Framework 5.0による Reactive Web Application #JavaDayTokyo
PDF
Reactive&amp;reactor
PPTX
Reactive programming
PDF
Introduction to Reactive Streams and Reactor 2.5
PDF
Guide to Spring Reactive Programming using WebFlux
PDF
Introduction to Spring webflux
PPTX
Андрій Рева, "How to build reactive java application"
PDF
Intro to Reactive Programming
PDF
Intro To Reactive Programming
PDF
Reactive systems
PDF
Deep-dive into Reactive programming.pdf
PPTX
From Streams to Reactive Streams
PPTX
Reactive Web Development with Spring Boot 2
PDF
Workshop: Event-sourced system through Reactive Streams
PPTX
Workshop: Event-sourced system through Reactive Streams
Reactive Applications in Java
Reactive programming intro
From Web to Flux @DevoxxBE 2023.pptx
Reactive Programming in Java and Spring Framework 5
Reactive solutions using java 9 and spring reactor
Spring Framework 5.0による Reactive Web Application #JavaDayTokyo
Reactive&amp;reactor
Reactive programming
Introduction to Reactive Streams and Reactor 2.5
Guide to Spring Reactive Programming using WebFlux
Introduction to Spring webflux
Андрій Рева, "How to build reactive java application"
Intro to Reactive Programming
Intro To Reactive Programming
Reactive systems
Deep-dive into Reactive programming.pdf
From Streams to Reactive Streams
Reactive Web Development with Spring Boot 2
Workshop: Event-sourced system through Reactive Streams
Workshop: Event-sourced system through Reactive Streams
Ad

Recently uploaded (20)

PDF
AI Guide for Business Growth - Arna Softech
DOC
UTEP毕业证学历认证,宾夕法尼亚克拉里恩大学毕业证未毕业
PPTX
R-Studio Crack Free Download 2025 Latest
PDF
MiniTool Power Data Recovery 12.6 Crack + Portable (Latest Version 2025)
PDF
Microsoft Office 365 Crack Download Free
PDF
Workplace Software and Skills - OpenStax
DOCX
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
PPTX
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
PPTX
MLforCyber_MLDataSetsandFeatures_Presentation.pptx
PPTX
Bista Solutions Advanced Accounting Package
PDF
Cloud Native Aachen Meetup - Aug 21, 2025
PPTX
Download Adobe Photoshop Crack 2025 Free
PPTX
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
PDF
Practical Indispensable Project Management Tips for Delivering Successful Exp...
PDF
PDF-XChange Editor Plus 10.7.0.398.0 Crack Free Download Latest 2025
PDF
Visual explanation of Dijkstra's Algorithm using Python
PDF
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
PPTX
Plex Media Server 1.28.2.6151 With Crac5 2022 Free .
PDF
CapCut PRO for PC Crack New Download (Fully Activated 2025)
PDF
Guide to Food Delivery App Development.pdf
AI Guide for Business Growth - Arna Softech
UTEP毕业证学历认证,宾夕法尼亚克拉里恩大学毕业证未毕业
R-Studio Crack Free Download 2025 Latest
MiniTool Power Data Recovery 12.6 Crack + Portable (Latest Version 2025)
Microsoft Office 365 Crack Download Free
Workplace Software and Skills - OpenStax
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
MLforCyber_MLDataSetsandFeatures_Presentation.pptx
Bista Solutions Advanced Accounting Package
Cloud Native Aachen Meetup - Aug 21, 2025
Download Adobe Photoshop Crack 2025 Free
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
Practical Indispensable Project Management Tips for Delivering Successful Exp...
PDF-XChange Editor Plus 10.7.0.398.0 Crack Free Download Latest 2025
Visual explanation of Dijkstra's Algorithm using Python
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
Plex Media Server 1.28.2.6151 With Crac5 2022 Free .
CapCut PRO for PC Crack New Download (Fully Activated 2025)
Guide to Food Delivery App Development.pdf

Reactive

Editor's Notes

  • #2: I will start with the question why reactive programming?
  • #3: These are some of the challenges as far as an application’s responsivness is concerned. There are lot of IO intensive operations in modern enterprise applications, like invoking a 3Rd party API, reading/writing a file, querying database Network latency experienced during the interactions of distributed systems is another issue Most of the code is written in imperative in fashion. It is only modified when a bottleneck is found. Scaling applications based on resource utilization is easy on cloud but are we effectively using the available resources?
  • #4: Java developers by default write blocking code. It's just how the API was set up. One example would be the traditional servlet approach. A servlet based container like Tomcat spawns thread per request and waits for the whole background process to finish in order to send the response back  The server thread represented in green color  is in waiting state until the worker thread represented in yellow color finishes it’s task. When we compare these two executions, clearly it is visible for us that the amount of time taken by the I/O task is effecting the total execution time of the procedure. the default thread pool size of Tomact is 200, which means it can handle 200 requests simultaneously. As number of request increase the application will start degrading.
  • #5: Ask question here – Which one do you think would help us to improve the reponsivness of the system?
  • #6: I’m going to give you analogy for these computing models. Example with cake and sing – Concurrent and parallel Say, ther e is an award night event – there are lot of singers, the committee came up with a challenge, sing Ganam style and eat a cake, whoever completes both tasks in shortest time wins. You can see Elvis Presley with a cake and mic, ready to charge. Elvis has 2 stratergies in mind; Sing first 20 lines, then eats 2 pieces of the cake, he can continue like that until he finish it off. Or he can eat half of the cake, sing half of the song, and so on. He can say that he likes to work as a team, ask someone to eat the cake and he can concentrate on the song. This is parallel programming/parallel computing. What about async? Explain async using email example.
  • #7: If we use the thread based concurrency model, we still nee to wait for the dependent task to complete, so it’s blocking. We can increase the no of threads to allow more parallel execution - this would increase the resource utilization, we need to increase the compute of the nodes where the application is running – the # of process core and memory should be increased. It is vertical scaling. We know vertical scaling has it’s own disadvantages. so we can horizontally scale it. This is what we were doing so far. So parallel computing is not a silver bullet. We are not doing anything to effectively use the compute while threads are in blocking state. IO bound tasks can be performed in an asynchronous and non-blocking fashion without blocking the current thread If the application is asynchronous, with minimum threads we can complete the tasks. We understood that asynchronous programming is good. Is that what reactive programming is all about? No, there is more to it. In Java, you can write code asynchronously using Callbacks and Futures. You can then get and join threads at some later point in time and process the result. Java 8 introduced us with a new class - CompletableFuture, which makes it much easier to coordinate these things. It works in a simple fashion - when a single process ends, another one starts. After the second one ends, the results are combined into a third process. This makes it a lot easier to coordinate your application, but it's still ultimately blocking as it creates Threads and waits upon calling a .join() method.
  • #9: When you moved to Banglore, you called up the packers and movers to move your stuffs. These two people are carrying your stuffs from the truck to the new apartment. The person at receiving end might collapse if he try to handle more than what he can take.
  • #10: The person at receiving end can say .. The Wikipedia definition of backpressure is Resistance or force opposing the desired flow of fluid through pipes. In the software terms; Resistance or force opposing the desired flow of data through software. When the load on the application is high we get to see OutOfMemoryException If the consumer can talk to the producer/ event emitter about the load it can take at a time, we can avoid cascading failures. Backpressure Strategies TODO Control the producer (slow down/speed up is decided by consumer) Buffer (accumulate incoming data spikes temporarily) Drop (sample a percentage of the incoming data)
  • #11: Reactor is a reactive library, based on the Reactive Streams "Reactive Streams" defines an API specification that contains a minimal set of interfaces that expose ways to define operations and entities for asynchronous streams of data with non-blocking backpressure. The high level of abstraction with Reactive Programming leads to an increased readability of code so developers can focus primarily on the interdependence of events that define the business logic.
  • #12: When we deal with functions which produce stream of data it can produce no value, one value or many values. There are 2 publishers which are main building block of Reactor.
  • #13: The image that you are seeing is called marble diagram. You can get marble diagram of the operators from the Java doc.
  • #14: It can produce stream of event without any restriction, a schedular which produces an event every 1 sec is an example for unbounded publisher.
  • #15: Use case  – On a shopping website, Show top five suggestion for a favorite product on the landing page. The favorites will be based on output of recommendation engine. If we didn’t get response with in 800 seconds get it from the cache.
  • #16: Tomcat and Jetty are supported on both sides, they’re used through different APIs in each stack. On the servlet stack they’re used through the Servlet API with blocking I/O. On the reactive stack they’re used through Servlet 3.1 non-blocking I/O without exposing the Servlet API
  • #17: Request mappings can be done in functional programming style. How requests to server like Netty are treated – There is a stack with events, a even loop thread picks that event and give it to handler, the event loops thread keeps on probing for events from the queue. When handler completes it’s task, puts it backs to the event queue. To get the best out the WebFlux we need to make sure there are no blocking components in the stack. Database layer is one of the blocking component, there is a reactive driver for MySQL based on R2DBC, however, it’s not widely adapted.
  • #18: RestTemplate is replaced by WebClient in the WebFlux.
  • #19: Python we have fast api Javascript we have nodejs