SlideShare a Scribd company logo
TYPE THE SUBJECT NAME HERE
SUBJECT CODE
II III
20CSPC301
OBJECT ORIENTED PROGRAMMING
(Common to CSE, IT,CSBS)
UNIT NO V
Lambda Expressions
5.7 Parallel Processing-Reactive
Programming
OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS)
20CSPC301
Parallel Processing
Definition of Parallel Processing
 Parallel processing also called parallel computing this is a type of computation
in which many execution of processes are carried out concurrently.
 In computers, parallel processing is the processing of program instructions by
dividing them among multiple processor with the objective of running a
program in less time.
 In the earliest computers, only one program ran at a time. According to research
Parallel computing is closely related to concurrent computing — they are
frequently used together, and often conflated, though the two are distinct: it is
possible to have parallelism without concurrency (such as bit-level parallelism),
and concurrency without parallelism (such as multitasking by time-sharing on a
single-core CPU).
OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS)
20CSPC301
 Parallel processing makes a program run faster because there are more engines
(CPUs) running it. In practice, it is often difficult to divide a program in such a
way that separate CPUs can execute different portions without interfering with
each other.
Serial Computing
OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS)
20CSPC301
Parallel Computing
OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS)
20CSPC301
Advantages Parallel Processing
•Parallel computing saves time, allowing the execution of applications in a
shorter wall-clock time.
•Solve Larger Problems in a short point of time.
•Compared to serial computing, parallel computing is much better suited for
modeling, simulating and understanding complex, real-world phenomena.
•Many problems are so large that it is impossible to solve them on a single
computer, especially given limited computer memory.
•You can do many things simultaneously by using multiple computing
resources.
•Can using computer resources on the Wide Area Network(WAN) or even on
the internet.
•It can help keep you organized. If you have Internet, then communication and
social networking can be made easier.
•It has massive data storage and quick data computations.
OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS)
20CSPC301
Disadvantages Parallel Processing
•Programming to target Parallel architecture is a bit difficult but with proper
understanding and practice, you are good to go.
•The use of parallel computing lets you solve computationally and data-intensive
problems using multi-core processors, but, sometimes this effect on some of our
control algorithm and does not give good results and this can also affect the
convergence of the system due to the parallel option.
•The extra cost (i.e. increased execution time) incurred are due to data transfers,
synchronization, communication, thread creation/destruction, etc. These costs can
sometimes be quite large, and may actually exceed the gains due to parallelization.
•Various code tweaking has to be performed for different target architectures for
improved performance.
•Better cooling technologies are required in case of clusters.
•Power consumption is huge by the multi-core architectures
OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS)
20CSPC301
•Multiprocessing refers to a computer system’s ability to support more than one
process(program) at the same time.
•Multiprocessing operating system enable several programs to run concurrently.
UNIX is one of the most widely used multiprocessing system, but there are many
others, including OS/2 for high-end PCs. Multiprocessing systems are much more
complicated than single-process systems because the operating system must
allocate resource to competing processes in a reasonable manner.
•May also refer to the utilization of multiple CPUs in a single computer system.
•The maximum number of processes you can run at a time is limited by the number
of processors in your computer. If you don’t know how many processors are
present in the machine, the cpu_count() function in multiprocessing will show it.
import multiprocessing as mp
print("Number of processors: ", mp.cpu_count())
OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS)
20CSPC301
Difference Between Synchronous and Asynchronous execution
•In parallel processing, there are two types of execution: Synchronous and
Asynchronous.
•A synchronous execution is one the processes are completed in the same order in
which it was started. This is achieved by locking the main program until the
respective processes are finished.
•Asynchronous, doesn’t involve locking. As a result, the order of results can get
mixed up but usually gets done quicker.
OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS)
20CSPC301
There are 2 main objects in multiprocessing to implement parallel execution of a
function: The Pool Class and the Process Class.
1. Pool Class
2. Synchronous execution
Pool.map() and Pool.starmap()
Pool.apply()
1. Asynchronous execution
Pool.map_async() and Pool.starmap_async()
Pool.apply_async())
2. Process Class
OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS)
20CSPC301
What is Reactive Programming?
•Reactive Programming is a programming language with asynchronous data
stream. Once an event will raise it will react with responsive and non-blocking
manner that’s why it named it as reactive programming.
•In a Reactive Programming context, “Everything is a Stream and acts in a non-
blocking manner when there is data in the stream.”
•This Reactive programming in java is introduced by Netflix organization with
API (Rx-Java)
Why we need Reactive Programming?
•When we have traditional way to develop application why we should go for
reactive programming,
There is four pillar to move towards Reactive Programming
Responsive
Resilient
Elastic
Message Driven
OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS)
20CSPC301
Responsive:Responsive means if we are raising any events on stream it will return
response in fraction of time as message processing in highly concurrent
environments
Resilient:Resilient means Application should be responsive at the time of failure.
Normally we are integrating multiple modules and each are depend to each other
assume one module is failing so it should not be impact all, it should be propagate.
Elastic:Elastic means our system should be handle N number of request, it should
be well capability to load balance at any condition
Message Driven:Message Driven means asynchronous flow of execution, where
we no need to wait for response after send request to server , once we send request
it move to next business it shouldn’t depends on first one response , the first
request response should be handle by callback mechanism.
OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS)
20CSPC301
Ideal Use Cases for Implementation of Reactive Programming
•A large number of transaction-processing services, as in the banking sector.
•Notification services of large online shopping applications, like Amazon.
•A share trading business where share prices change simultaneously.
Advantages of Reactive Programming
Improves user experience: The asynchronous nature of RP means that whatever
you program with it will offer a smoother, more responsive product for your users
to interact with.
Improves user experience: The asynchronous nature of RP means that whatever
you program with it will offer a smoother, more responsive product for your users
to interact with.
Simple to compose streams of data: Reactive programming provide the potential
for developers to create, filter, and combine streams of data which can emit a
value, error, and a completed signal, to achieve powerful objectives.
OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS)
20CSPC301
A lot simpler to do async/threaded work: The method that PR allows you to work
on the data streams causes it becomes less hassle than regular threading.
Avoid “callback hell” or "pyramid of doom": Callback Hell is an anti-pattern
seen in code of asynchronous programming. It is a slang term used to describe and
unwieldy number of nested “if” statements or functions. It usually happens when
there are a lot of callback functions in the code. Developers can avoid the callback
hell with reactive programming because it depends on asynchronous data streams.
High performance in cooperation with Java: RP allows Java apps to have higher
performance with lower memory requirements. This is made possible by avoiding
blocking calls that lead to a process as well as context switches in the OS.
OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS)
20CSPC301
Disadvantages of Reactive Programming
Hard to learn: RP have a reputation of being difficult since it is entirely different
compared with previous ways of working. This leads to a steep learning curve
when you start using it which may be a shock to some developers.
More memory intensive: Applications will tend to be more memory intensive due
to reactive programming relies on streams over time. This can lead to memory
leakage which could end up seriously slowing things down for users.

More Related Content

PPTX
Message Passing, Remote Procedure Calls and Distributed Shared Memory as Com...
PPTX
Concurrency and Parallelism, Asynchronous Programming, Network Programming
PPT
Network and distributed systems
PPT
Parallel Processing Concepts
PDF
Programming Models for High-performance Computing
PPTX
TASK AND DATA PARALLELISM in Computer Science pptx
PPTX
Parallel programming model
PPTX
Unit 1 introduction to c++.pptx
Message Passing, Remote Procedure Calls and Distributed Shared Memory as Com...
Concurrency and Parallelism, Asynchronous Programming, Network Programming
Network and distributed systems
Parallel Processing Concepts
Programming Models for High-performance Computing
TASK AND DATA PARALLELISM in Computer Science pptx
Parallel programming model
Unit 1 introduction to c++.pptx

Similar to 5.7 Parallel Processing - Reactive Programming.pdf.pptx (20)

PDF
The real time publisher subscriber inter-process communication model for dist...
PPT
CS4961-L1.ppt
PPTX
Synchronous vs Asynchronous Programming
PDF
PDF
An Introduction to Parallel Programming 2. Edition Pacheco
PDF
Advanced computer architecture unit 5
PPTX
CSE202.pptx
PDF
Our Concurrent Past; Our Distributed Future
PDF
Matloff programming on-parallel_machines-2013
PDF
Lec+3-Introduction-to-Distributed-Systems.pdf
PDF
Consolidate Your Technical Debt With Spark Data Sources -Tools and Techniques...
PDF
Parallel programming model, language and compiler in ACA.
PPTX
Distributed, Network System and RPC.pptx
PDF
Inter-Process Communication in distributed systems
PPTX
Concurrency Programming in Java - 01 - Introduction to Concurrency Programming
PPT
parallel computing.ppt
PDF
Client server computing
PPT
Chapter_1.ppt Peter S Pacheco, Matthew Malensek – An Introduction to Parallel...
PPT
Chapter_1_16_10_2024.pptPeter S Pacheco, Matthew Malensek – An Introduction t...
PPTX
Object Oriented Design and Programming Unit-01
The real time publisher subscriber inter-process communication model for dist...
CS4961-L1.ppt
Synchronous vs Asynchronous Programming
An Introduction to Parallel Programming 2. Edition Pacheco
Advanced computer architecture unit 5
CSE202.pptx
Our Concurrent Past; Our Distributed Future
Matloff programming on-parallel_machines-2013
Lec+3-Introduction-to-Distributed-Systems.pdf
Consolidate Your Technical Debt With Spark Data Sources -Tools and Techniques...
Parallel programming model, language and compiler in ACA.
Distributed, Network System and RPC.pptx
Inter-Process Communication in distributed systems
Concurrency Programming in Java - 01 - Introduction to Concurrency Programming
parallel computing.ppt
Client server computing
Chapter_1.ppt Peter S Pacheco, Matthew Malensek – An Introduction to Parallel...
Chapter_1_16_10_2024.pptPeter S Pacheco, Matthew Malensek – An Introduction t...
Object Oriented Design and Programming Unit-01
Ad

Recently uploaded (20)

PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Welding lecture in detail for understanding
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
additive manufacturing of ss316l using mig welding
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Internet of Things (IOT) - A guide to understanding
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
UNIT-1 - COAL BASED THERMAL POWER PLANTS
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
CH1 Production IntroductoryConcepts.pptx
Welding lecture in detail for understanding
OOP with Java - Java Introduction (Basics)
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
additive manufacturing of ss316l using mig welding
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
bas. eng. economics group 4 presentation 1.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Ad

5.7 Parallel Processing - Reactive Programming.pdf.pptx

  • 1. TYPE THE SUBJECT NAME HERE SUBJECT CODE II III 20CSPC301 OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS) UNIT NO V Lambda Expressions 5.7 Parallel Processing-Reactive Programming
  • 2. OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS) 20CSPC301 Parallel Processing Definition of Parallel Processing  Parallel processing also called parallel computing this is a type of computation in which many execution of processes are carried out concurrently.  In computers, parallel processing is the processing of program instructions by dividing them among multiple processor with the objective of running a program in less time.  In the earliest computers, only one program ran at a time. According to research Parallel computing is closely related to concurrent computing — they are frequently used together, and often conflated, though the two are distinct: it is possible to have parallelism without concurrency (such as bit-level parallelism), and concurrency without parallelism (such as multitasking by time-sharing on a single-core CPU).
  • 3. OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS) 20CSPC301  Parallel processing makes a program run faster because there are more engines (CPUs) running it. In practice, it is often difficult to divide a program in such a way that separate CPUs can execute different portions without interfering with each other. Serial Computing
  • 4. OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS) 20CSPC301 Parallel Computing
  • 5. OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS) 20CSPC301 Advantages Parallel Processing •Parallel computing saves time, allowing the execution of applications in a shorter wall-clock time. •Solve Larger Problems in a short point of time. •Compared to serial computing, parallel computing is much better suited for modeling, simulating and understanding complex, real-world phenomena. •Many problems are so large that it is impossible to solve them on a single computer, especially given limited computer memory. •You can do many things simultaneously by using multiple computing resources. •Can using computer resources on the Wide Area Network(WAN) or even on the internet. •It can help keep you organized. If you have Internet, then communication and social networking can be made easier. •It has massive data storage and quick data computations.
  • 6. OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS) 20CSPC301 Disadvantages Parallel Processing •Programming to target Parallel architecture is a bit difficult but with proper understanding and practice, you are good to go. •The use of parallel computing lets you solve computationally and data-intensive problems using multi-core processors, but, sometimes this effect on some of our control algorithm and does not give good results and this can also affect the convergence of the system due to the parallel option. •The extra cost (i.e. increased execution time) incurred are due to data transfers, synchronization, communication, thread creation/destruction, etc. These costs can sometimes be quite large, and may actually exceed the gains due to parallelization. •Various code tweaking has to be performed for different target architectures for improved performance. •Better cooling technologies are required in case of clusters. •Power consumption is huge by the multi-core architectures
  • 7. OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS) 20CSPC301 •Multiprocessing refers to a computer system’s ability to support more than one process(program) at the same time. •Multiprocessing operating system enable several programs to run concurrently. UNIX is one of the most widely used multiprocessing system, but there are many others, including OS/2 for high-end PCs. Multiprocessing systems are much more complicated than single-process systems because the operating system must allocate resource to competing processes in a reasonable manner. •May also refer to the utilization of multiple CPUs in a single computer system. •The maximum number of processes you can run at a time is limited by the number of processors in your computer. If you don’t know how many processors are present in the machine, the cpu_count() function in multiprocessing will show it. import multiprocessing as mp print("Number of processors: ", mp.cpu_count())
  • 8. OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS) 20CSPC301 Difference Between Synchronous and Asynchronous execution •In parallel processing, there are two types of execution: Synchronous and Asynchronous. •A synchronous execution is one the processes are completed in the same order in which it was started. This is achieved by locking the main program until the respective processes are finished. •Asynchronous, doesn’t involve locking. As a result, the order of results can get mixed up but usually gets done quicker.
  • 9. OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS) 20CSPC301 There are 2 main objects in multiprocessing to implement parallel execution of a function: The Pool Class and the Process Class. 1. Pool Class 2. Synchronous execution Pool.map() and Pool.starmap() Pool.apply() 1. Asynchronous execution Pool.map_async() and Pool.starmap_async() Pool.apply_async()) 2. Process Class
  • 10. OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS) 20CSPC301 What is Reactive Programming? •Reactive Programming is a programming language with asynchronous data stream. Once an event will raise it will react with responsive and non-blocking manner that’s why it named it as reactive programming. •In a Reactive Programming context, “Everything is a Stream and acts in a non- blocking manner when there is data in the stream.” •This Reactive programming in java is introduced by Netflix organization with API (Rx-Java) Why we need Reactive Programming? •When we have traditional way to develop application why we should go for reactive programming, There is four pillar to move towards Reactive Programming Responsive Resilient Elastic Message Driven
  • 11. OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS) 20CSPC301 Responsive:Responsive means if we are raising any events on stream it will return response in fraction of time as message processing in highly concurrent environments Resilient:Resilient means Application should be responsive at the time of failure. Normally we are integrating multiple modules and each are depend to each other assume one module is failing so it should not be impact all, it should be propagate. Elastic:Elastic means our system should be handle N number of request, it should be well capability to load balance at any condition Message Driven:Message Driven means asynchronous flow of execution, where we no need to wait for response after send request to server , once we send request it move to next business it shouldn’t depends on first one response , the first request response should be handle by callback mechanism.
  • 12. OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS) 20CSPC301 Ideal Use Cases for Implementation of Reactive Programming •A large number of transaction-processing services, as in the banking sector. •Notification services of large online shopping applications, like Amazon. •A share trading business where share prices change simultaneously. Advantages of Reactive Programming Improves user experience: The asynchronous nature of RP means that whatever you program with it will offer a smoother, more responsive product for your users to interact with. Improves user experience: The asynchronous nature of RP means that whatever you program with it will offer a smoother, more responsive product for your users to interact with. Simple to compose streams of data: Reactive programming provide the potential for developers to create, filter, and combine streams of data which can emit a value, error, and a completed signal, to achieve powerful objectives.
  • 13. OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS) 20CSPC301 A lot simpler to do async/threaded work: The method that PR allows you to work on the data streams causes it becomes less hassle than regular threading. Avoid “callback hell” or "pyramid of doom": Callback Hell is an anti-pattern seen in code of asynchronous programming. It is a slang term used to describe and unwieldy number of nested “if” statements or functions. It usually happens when there are a lot of callback functions in the code. Developers can avoid the callback hell with reactive programming because it depends on asynchronous data streams. High performance in cooperation with Java: RP allows Java apps to have higher performance with lower memory requirements. This is made possible by avoiding blocking calls that lead to a process as well as context switches in the OS.
  • 14. OBJECT ORIENTED PROGRAMMING (Common to CSE, IT,CSBS) 20CSPC301 Disadvantages of Reactive Programming Hard to learn: RP have a reputation of being difficult since it is entirely different compared with previous ways of working. This leads to a steep learning curve when you start using it which may be a shock to some developers. More memory intensive: Applications will tend to be more memory intensive due to reactive programming relies on streams over time. This can lead to memory leakage which could end up seriously slowing things down for users.