Preface
The most into Lin Ye also have a period of time did not write a blog, in this period I also did not idle, but studied the framework of Netty, why to study Netty it. We all know that a wide range of open source frameworks, such as HADOOP,DUBBO,ROCKETMQ and even Tomcat, are meant to provide services on the server, essentially using sockets, and of course you can call this RPC mode, Through Socker communication to carry out distributed cluster processing, such as heartbeat check, data transmission and so on, and can do the framework of these netty mo genus, there is such a word, if you learn Java did not learn Netty then your Java is equal to white learning, haha of course this remark is exaggerated. Of course, I'm just doing a preliminary study on the surface of Netty, and more in-depth research is needed to continue in the future what is Netty.
Netty is a Java open source framework provided by JBoss. Netty provides asynchronous, event-driven network application frameworks and tools for rapid development of high-performance, highly reliable network servers and client programs. (source Baidu)
The above mentioned several concepts, one is the network application framework, the other is asynchronous, it is obvious that Netty is used to make network communication open source framework, then how to explain asynchronous.
We all know that the traditional socket program is to open a port in the server, and then let the socket packet, to listen to this port
As shown in figure:
Of course, this will have a problem, that is, the port is only a single thread processing, so that only one client access link, the other to access the client will block waiting for the thread to complete the access, so the efficiency is very low, and even the computer can not play the advantages of the original
Then everyone thought of a new method, the same port by multiple threads of parallel services, so as to a certain extent to avoid the situation of thread blocking
However, this will allow the server to create a large number of threads or processes, will cause the server's resource overhead is particularly large, can be in one way. Let a thread simultaneously server multiple access requests.
We have the channel of each client connected to the server so that a thread is processed so that is perfect, so the Netty mode
appears:
This is Netty's basic introduction, Follow-up I will also launch with more about Netty content, about Netty Hello World demo behind I will also be sorted out for everyone, further understanding how to use the Netty