2015-09-14 12:56:17 +05:30
---
title: Reactor
2021-09-12 13:27:23 +03:00
category: Concurrency
2021-05-19 10:49:05 -06:00
language: en
2017-03-25 22:07:10 +01:00
tags:
2019-12-13 21:09:28 +02:00
- Performance
- Reactive
2015-09-14 12:56:17 +05:30
---
2016-01-03 21:14:30 +01:00
## Intent
The Reactor design pattern handles service requests that are delivered concurrently to an application by one or more clients. The application can register specific handlers for processing which are called by reactor on specific events. Dispatching of event handlers is performed by an initiation dispatcher, which manages the registered event handlers. Demultiplexing of service requests is performed by a synchronous event demultiplexer.
2015-09-14 12:56:17 +05:30
2019-12-07 20:01:13 +02:00
## Class diagram
2015-09-14 12:56:17 +05:30

2016-01-03 21:14:30 +01:00
## Applicability
Use Reactor pattern when
2015-09-14 12:56:17 +05:30
2019-12-13 21:09:28 +02:00
* A server application needs to handle concurrent service requests from multiple clients.
* A server application needs to be available for receiving requests from new clients even when handling older client requests.
* A server must maximize throughput, minimize latency and use CPU efficiently without blocking.
2015-09-14 12:56:17 +05:30
2016-01-03 21:14:30 +01:00
## Real world examples
2015-09-14 12:56:17 +05:30
* [Spring Reactor ](http://projectreactor.io/ )
2016-01-03 21:14:30 +01:00
## Credits
2015-09-14 12:56:17 +05:30
* [Douglas C. Schmidt - Reactor ](https://www.dre.vanderbilt.edu/~schmidt/PDF/Reactor.pdf )
2020-07-06 13:31:07 +03:00
* [Pattern Oriented Software Architecture Volume 2: Patterns for Concurrent and Networked Objects ](https://www.amazon.com/gp/product/0471606952/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0471606952&linkCode=as2&tag=javadesignpat-20&linkId=889e4af72dca8261129bf14935e0f8dc )
2015-09-14 12:56:17 +05:30
* [Doug Lea - Scalable IO in Java ](http://gee.cs.oswego.edu/dl/cpjslides/nio.pdf )
* [Netty ](http://netty.io/ )