Netty pattern of five components in simple terms --53.Reactor Analysis

Traditional IO processing three drawbacks:

1. server a large number of threads and client communications, the number of threads since the server is limited, after all, the thread is a resource;

2. When the thread context switching is performed must have overhead, if a large number of thread context switching overhead, then it would be very great;

3. After the connection is established between the client and the server, and then if the client after sending the data is not sent, but the connection has always been there, so wasted system resources.

Because of all the disadvantages of traditional IO processing, so we come out of the Reactor pattern.

In nio processing logic when we do not provide event handlers, we need to write your own callback method.

In netty the event provides a processor and associated callback method

channelRead0 () method is associated callback method mentioned above, so that channelRead0 () is called by Initiation Dispatcher.

In this case a problem arises, because the callback method is invoked by the Initiation Dispatcher method, and if channelRead0 () method performs a long time, can block Initiation Dispatcher.

 

Guess you like

Origin blog.csdn.net/qq_37909508/article/details/91387405