Reactor vs Proactor¶
Reactor and Proactor are two distinct Design Patterns used to handle concurrent I/O events, often implemented within networking frameworks like Netty^[600-developer__big-data__netty__netty-Reactor.md].
Overview¶
- Reactor Pattern: A synchronous design pattern that demultiplexes and dispatches I/O requests to corresponding handlers when the device is ready.^[600-developer__big-data__netty__netty-Reactor.md]
- Proactor Pattern: An asynchronous design pattern that allows the application to initiate operations and continue processing while the OS handles the I/O, dispatching handlers only upon completion.^[600-developer__big-data__netty__netty-Reactor.md]
Key Differences¶
The primary distinction lies in the initiation of the read/write operations and who handles the data copying:
- Reactor: The application must register an interest in an event. When the "readiness" event occurs (e.g., a socket is readable), the Reactor notifies the application, which must then explicitly initiate the read or write operation (synchronously) from the kernel.^[600-developer__big-data__netty__netty-Reactor.md]
- Proactor: The application initiates an asynchronous read/write operation to the OS. The application is then free to continue other tasks. The OS handles the data transfer and, upon completion, notifies the application via a callback or completion event.^[600-developer__big-data__netty__netty-Reactor.md]
Related Concepts¶
- [[Netty]]
- I/O Multiplexing
- Asynchronous I/O
- Synchronous I/O
Sources¶
^[600-developer__big-data__netty__netty-Reactor.md]