Preface:
The content is from my knowledge of core Java PDF gathered inside, sharing a small portion of it to everyone, this knowledge a little knowledge, recently read many of my friends are preparing for spring resort, and I hope this can help PDF to you, you may say, to consolidate their understanding of knowledge, knowledge of their own will not, the end of the article there is the PDF of the receive mode Oh, this document a total of 283 included 30 core knowledge points, with a detailed analysis, today Netty is to share with RPC
1.Netty principle
Netty is a high performance, asynchronous event-driven NIO framework, API JAVA NIO based implementation provided. It provides support for TCP, UDP and file transfer as an asynchronous NIO framework, Netty all IO operations are asynchronous non-blocking by Future-Listener mechanism, users can easily take the initiative to acquire or obtain IO operation results notification mechanism .
High-performance 2.Netty
In the IO programming process, when it is necessary to handle multiple clients access request can be processed using multi-threading or IO multiplexing. IO blocked by multiplexing a plurality of IO multiplexed onto the same blocking select, so that the system can handle the case where a plurality of single-threaded client requests simultaneously. With the traditional multi-threaded / multi-process model ratio, I / O multiplexing biggest advantage is the small system overhead, the system does not need to create new and additional processes or threads, do not need to run these maintenance processes and threads, reducing the system maintenance workload, saving system resources. Socket and ServerSocket with corresponding, NIO SocketChannel and also provides two different socket channel ServerSocketChannel achieved.
2.1 multiplexing communication
Netty architecture and implemented in Reactor mode, its server communication sequence is as follows:
The client communication sequence is as follows:
Netty IO thread NioEventLoop Selector Since polymerized multiplexer, can handle hundreds of concurrent clients Channel, since the read and write operations are non-blocking, which can sufficiently enhance the operating efficiency of the IO thread, to avoid IO threads frequently blocked due to hang.
2.2 asynchronous communication NIO
Netty Since the asynchronous communication mode, a thread can be processed concurrently IO N and clients connected to read and write operations, which solves a conventional IO connector synchronous blocking a thread model, the performance of the underlying architecture, scalability, and reliability of the elastic It has been greatly improved.
Netty RPC achieve
concept
RPC, namely Remote Procedure Call (Remote Procedure Call) to call the service on the remote computer, the same as calling a local service. RPC can be a good decoupling system, such as a WebService is a kind of the Http RPC protocol. The RPC overall framework
as follows:
Key Technology
1. Service Publish and Subscribe: Zookeeper registered service address using the server, the client gets the services available from the address Zookeeper.
2. Communication: Netty used as a communication frame.
3. Spring: Spring configuration using the service, loaded Bean, scanning notes.
4. Dynamic Agent: The client uses transparent proxy mode service call.
The message Codec: Use Protostuff serialization and deserialization message.
Readers Benefits:
The content is from my knowledge of core Java PDF gathered inside, sharing a small portion of it to everyone, want to know more friends can come to me to receive this detailed knowledge of core Java
Receive way: My concern for the kind of numbers (Java Zhou people) can receive