SlideShare a Scribd company logo
What are the benefits
of reactive
programming in Java?
Dmytro Melnychuk
Bio
Software Engineer
● 7 years experience in JVM languages
twitter.com/meldmy
github.com/meldmy
Agenda
● Synchronous vs asynchronous programming
● The key reactive programming concepts
● Current state of Java-based reactive frameworks and toolkits
Have you ever stayed in such long queue?
The first McDonald's in Moscow
opened in 1990
When can it happen?
When can it happen?
When too many clients need to
wait for finalization of their
orders!
What is the problem with simple order system?
We need to stay in queue
until all previous orders
complete
* https://www.vintag.es/2016/03/old-mcdonalds-historical-photos-of.html
How they resolved a problem with a long queue?
* https://www.calvertjournal.com/images/uploads/thumbnails/McDonalds/LON29289.jpg
* https://external-preview.redd.it/x0cIVo6wWlM8ryudtVHhMmPwvnUkZxOg1_izN5fgwZ8.jpg?auto=webp&s=209c2937112562108309eb5b4b59165bc46c0fb9
The same problem with synchronous blocking I/O
Blocking is waiting!
Let’s remember!
Waiting is doing nothing!
Let’s avoid doing nothing!
Freezing UI and our backend use blocking I/O
Let’s increase the number of server threads?
Let’s increase the number of server threads?
What's wrong with increasing threads and blocking I/O?
➢ Thread-per-connection approach
➢ Thread Context Switching
Thread-per-connection approach
* http://www.coralblocks.com/index.php/thread-concurrency-vs-network-asynchronicity/
1. Thread creating
2. Thread per connection
3. Waiting thread per
Keep-Alive connection
4. Context Switching
Context Switching - cores switch between processes
* http://www.coralblocks.com/index.php/thread-concurrency-vs-network-asynchronicity/
What about reactive programming?
What is reactive programming?
Reactive programming - is a declarative programming
paradigm concerned with data streams, the propagation of
change [1]
Reactive programming - is about non-blocking, event-driven
applications that scale with a small number of threads [2]
1. https://en.wikipedia.org/wiki/Reactive_programming
2. https://spring.io/blog/2016/07/28/reactive-programming-with-spring-5-0-m1
How we can double every int in the array in Java?
Imperative approach
How we can double every int in the array in Java?
How we can double every int in the array in Java?
Imperative approach Declarative approach
Imperative vs declarative programming
Imperative programming Declarative programming
How you want to do What you want to do
Reactive programming is
programming with
data streams
Reactive programming concerned with data streams
Data streams
Non-blocking I/OBlocking I/O
Synchronous Asynchronous
java.util.stream.* java.util.concurrent.Flow (JDK 9)
Understand the term of propagation of change
var A = 1, B = 2;
var C = A + B;
A = 3;
print(C); //=> 5
What should we know about C behavior?
● C is automatically updated when values of A or B change
● C is a observer that subscribes to an observable A and B
Observable needs a small
number of threads to scale
What are the benefits of reactive programming in java
The reactor pattern (single-threaded event loop)
Is reactor pattern faster than
one-thread-per-connection model?
Why do you think this happens?
*https://dzone.com/articles/spring-boot-20-webflux-reactive-performance-test
Spring MVC Spring WebFlux
Embedded Tomcat
(maxThreads 10000)
Netty framework
Reactor pattern makes better use of threads/cores!
*https://dzone.com/articles/spring-boot-20-webflux-reactive-performance-test
Spring MVC Spring WebFlux
Embedded Tomcat
(maxThreads 10000)
Netty framework
Thread-Based
Architecture
Event-driven
architecture
Reactive Java
libraries
Reactive Java frameworks and toolkits
Project
Reactor
What are the benefits of reactive programming in java
What are the benefits of reactive programming in java
Thank you
twitter.com/meldmy
github.com/meldmy

More Related Content

What's hot (20)

PDF
Agile Quality and Risk Management
Elisabeth Hendrickson
 
PPT
Apache TomEE - Tomcat with a kick
Vishwanath Krishnamurthi
 
PPTX
Introduction To Microservices
Lalit Kale
 
PDF
Quarkus Denmark 2019
Max Andersen
 
PDF
Understanding Reactive Programming
Andres Almiray
 
PDF
A pattern language for microservices (#gluecon #gluecon2016)
Chris Richardson
 
PDF
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
Edureka!
 
PPTX
Azure API Management
Daniel Toomey
 
PPTX
Node.Js: Basics Concepts and Introduction
Kanika Gera
 
PDF
Grokking Techtalk #39: How to build an event driven architecture with Kafka ...
Grokking VN
 
PPTX
Microservice vs. Monolithic Architecture
Paul Mooney
 
PPT
Agile QA presentation
Carl Bruiners
 
PPTX
Tips for Writing Better Charters for Exploratory Testing Sessions by Michael...
TEST Huddle
 
PPTX
Introduction to Node js
Akshay Mathur
 
PPTX
Discover Quarkus and GraalVM
Romain Schlick
 
PPTX
itlchn 20 - Kien truc he thong chung khoan - Phan 2
IT Expert Club
 
PDF
Microservices, Kubernetes and Istio - A Great Fit!
Animesh Singh
 
PDF
Design patterns for microservice architecture
The Software House
 
PPTX
Introduction Node.js
Erik van Appeldoorn
 
Agile Quality and Risk Management
Elisabeth Hendrickson
 
Apache TomEE - Tomcat with a kick
Vishwanath Krishnamurthi
 
Introduction To Microservices
Lalit Kale
 
Quarkus Denmark 2019
Max Andersen
 
Understanding Reactive Programming
Andres Almiray
 
A pattern language for microservices (#gluecon #gluecon2016)
Chris Richardson
 
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
Edureka!
 
Azure API Management
Daniel Toomey
 
Node.Js: Basics Concepts and Introduction
Kanika Gera
 
Grokking Techtalk #39: How to build an event driven architecture with Kafka ...
Grokking VN
 
Microservice vs. Monolithic Architecture
Paul Mooney
 
Agile QA presentation
Carl Bruiners
 
Tips for Writing Better Charters for Exploratory Testing Sessions by Michael...
TEST Huddle
 
Introduction to Node js
Akshay Mathur
 
Discover Quarkus and GraalVM
Romain Schlick
 
itlchn 20 - Kien truc he thong chung khoan - Phan 2
IT Expert Club
 
Microservices, Kubernetes and Istio - A Great Fit!
Animesh Singh
 
Design patterns for microservice architecture
The Software House
 
Introduction Node.js
Erik van Appeldoorn
 

Similar to What are the benefits of reactive programming in java (20)

PPTX
Reactive programming intro
Ahmed Ehab AbdulAziz
 
PDF
reactive_programming_for_java_developers.pdf
Akshitkumar437417
 
PDF
Reactive systems
Naresh Chintalcheru
 
PPT
Reactive programming with examples
Peter Lawrey
 
PPTX
Introduction to Spring Reactor
DrSimoneDiCola
 
PDF
Reactive Applications in Java
Alexander Mrynskyi
 
PDF
Not Only Streams for Akademia JLabs
Konrad Malawski
 
PDF
The Reactive Rollercoaster
Bol.com Techlab
 
PPTX
Mario Fusco - Reactive programming in Java - Codemotion Milan 2017
Codemotion
 
PDF
Spring Framework 5.0による Reactive Web Application #JavaDayTokyo
Toshiaki Maki
 
PPTX
Reactive programming
SUDIP GHOSH
 
PDF
Moving towards Reactive Programming
Deepak Shevani
 
PPTX
Going Reactive in Java with Typesafe Reactive Platform
Legacy Typesafe (now Lightbend)
 
PDF
Reactive programming with Rxjava
Christophe Marchal
 
PDF
An introduction to Reactive applications, Reactive Streams, and options for t...
Steve Pember
 
PPTX
Building Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
Todd Fritz
 
PPT
Reactive java programming for the impatient
Grant Steinfeld
 
PDF
Spring Framework 5: History and Reactive features
Aliaksei Zhynhiarouski
 
PPTX
Reactive Web Development with Spring Boot 2
Mike Melusky
 
PPTX
Reactive for the Impatient - Mary Grygleski
PolyglotMeetups
 
Reactive programming intro
Ahmed Ehab AbdulAziz
 
reactive_programming_for_java_developers.pdf
Akshitkumar437417
 
Reactive systems
Naresh Chintalcheru
 
Reactive programming with examples
Peter Lawrey
 
Introduction to Spring Reactor
DrSimoneDiCola
 
Reactive Applications in Java
Alexander Mrynskyi
 
Not Only Streams for Akademia JLabs
Konrad Malawski
 
The Reactive Rollercoaster
Bol.com Techlab
 
Mario Fusco - Reactive programming in Java - Codemotion Milan 2017
Codemotion
 
Spring Framework 5.0による Reactive Web Application #JavaDayTokyo
Toshiaki Maki
 
Reactive programming
SUDIP GHOSH
 
Moving towards Reactive Programming
Deepak Shevani
 
Going Reactive in Java with Typesafe Reactive Platform
Legacy Typesafe (now Lightbend)
 
Reactive programming with Rxjava
Christophe Marchal
 
An introduction to Reactive applications, Reactive Streams, and options for t...
Steve Pember
 
Building Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
Todd Fritz
 
Reactive java programming for the impatient
Grant Steinfeld
 
Spring Framework 5: History and Reactive features
Aliaksei Zhynhiarouski
 
Reactive Web Development with Spring Boot 2
Mike Melusky
 
Reactive for the Impatient - Mary Grygleski
PolyglotMeetups
 
Ad

Recently uploaded (20)

PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Ad

What are the benefits of reactive programming in java

  • 1. What are the benefits of reactive programming in Java? Dmytro Melnychuk
  • 2. Bio Software Engineer ● 7 years experience in JVM languages twitter.com/meldmy github.com/meldmy
  • 3. Agenda ● Synchronous vs asynchronous programming ● The key reactive programming concepts ● Current state of Java-based reactive frameworks and toolkits
  • 4. Have you ever stayed in such long queue? The first McDonald's in Moscow opened in 1990
  • 5. When can it happen?
  • 6. When can it happen? When too many clients need to wait for finalization of their orders!
  • 7. What is the problem with simple order system? We need to stay in queue until all previous orders complete * https://www.vintag.es/2016/03/old-mcdonalds-historical-photos-of.html
  • 8. How they resolved a problem with a long queue? * https://www.calvertjournal.com/images/uploads/thumbnails/McDonalds/LON29289.jpg * https://external-preview.redd.it/x0cIVo6wWlM8ryudtVHhMmPwvnUkZxOg1_izN5fgwZ8.jpg?auto=webp&s=209c2937112562108309eb5b4b59165bc46c0fb9
  • 9. The same problem with synchronous blocking I/O Blocking is waiting! Let’s remember! Waiting is doing nothing!
  • 11. Freezing UI and our backend use blocking I/O
  • 12. Let’s increase the number of server threads?
  • 13. Let’s increase the number of server threads?
  • 14. What's wrong with increasing threads and blocking I/O? ➢ Thread-per-connection approach ➢ Thread Context Switching
  • 16. Context Switching - cores switch between processes * http://www.coralblocks.com/index.php/thread-concurrency-vs-network-asynchronicity/
  • 17. What about reactive programming?
  • 18. What is reactive programming? Reactive programming - is a declarative programming paradigm concerned with data streams, the propagation of change [1] Reactive programming - is about non-blocking, event-driven applications that scale with a small number of threads [2] 1. https://en.wikipedia.org/wiki/Reactive_programming 2. https://spring.io/blog/2016/07/28/reactive-programming-with-spring-5-0-m1
  • 19. How we can double every int in the array in Java? Imperative approach
  • 20. How we can double every int in the array in Java?
  • 21. How we can double every int in the array in Java? Imperative approach Declarative approach
  • 22. Imperative vs declarative programming Imperative programming Declarative programming How you want to do What you want to do
  • 24. Reactive programming concerned with data streams Data streams Non-blocking I/OBlocking I/O Synchronous Asynchronous java.util.stream.* java.util.concurrent.Flow (JDK 9)
  • 25. Understand the term of propagation of change var A = 1, B = 2; var C = A + B; A = 3; print(C); //=> 5 What should we know about C behavior? ● C is automatically updated when values of A or B change ● C is a observer that subscribes to an observable A and B
  • 26. Observable needs a small number of threads to scale
  • 28. The reactor pattern (single-threaded event loop)
  • 29. Is reactor pattern faster than one-thread-per-connection model?
  • 30. Why do you think this happens? *https://dzone.com/articles/spring-boot-20-webflux-reactive-performance-test Spring MVC Spring WebFlux Embedded Tomcat (maxThreads 10000) Netty framework
  • 31. Reactor pattern makes better use of threads/cores! *https://dzone.com/articles/spring-boot-20-webflux-reactive-performance-test Spring MVC Spring WebFlux Embedded Tomcat (maxThreads 10000) Netty framework Thread-Based Architecture Event-driven architecture
  • 33. Reactive Java frameworks and toolkits Project Reactor