I like to use simple language to explain knowledge points

Long-term sharing of original Java articles, advanced architect learning notes and learning materials

Like you can like attention, learn together, progress together



What is Netty?

0) Key words :Netty, NIO, asynchronous, communication,

1) Essence: A Jar package, a NIO framework, is an excellent wrapper for socket network programming

2) Function: Since Netty is an excellent wrapper for socket network programming. Before Netty, the JDK forced you to use sockets to write servers, which was cumbersome and lacked a high-level API. And then Netty came along, and he said, I’ll write JDK sockets, and I’ll give you a new, cleaner API, and you can write a web server like a fool

3) Benefits: Provides asynchronous, event-driven web application frameworks and tools that you can write a web server (as opposed to the lower level of socket network programming, of course), in layman’s terms: a decent framework for handling sockets

4) Similar: Similar functions are Mina(earlier than Netty, same author. I won’t extend it here.)

5) Supported protocols include HTTP, WebSockets, SSL, etc. With Netty, you can easily leverage Java NIO to improve server-side performance.

6) Scenario: The RPC framework of Dubbo, the distributed service framework of Alibaba, uses The Dubbo protocol for inter-node communication. By default, The Dubbo protocol uses Netty as the basic communication component to realize the internal communication between process nodes. (What is dubbo?) , Ali’s Message Queue (RocketMQ), Ali’s HSF, etc

7) Learn the knowledge required by Netty: Netty itself provides a convenient network programming (especially NIO) framework (JAR package), if you are familiar with TCP/IP, network programming and NIO, then Netty is not difficult for you, about a week to use. If you are not familiar with the above, it is recommended to familiarize yourself with the above technologies first. When learning Netty, the core must master its threading model

Netty is a Network Server, which is a Network framework at the lower level of the Web Server. That is, you can use Netty to emulate Tomcat as a Web container that provides HTTP services.

9) Communication: the system needs to realize multi-process communication, and there are only two ways: memory sharing and message passing; Distributed inter-system communication only message passing, Netty can be used as the basic component of inter-application message passing, Netty is located in the OSI protocol stack session layer, presentation layer, application layer are involved, so you can easily extend the implementation, deal with the protocol and business above the session layer; Netty encapsulates the Java NIO API, making it a very user-friendly framework; It provides a thread pool for processing IO. The most important thing is that a socket can be processed in a single thread. A thread can process multiple sockets simultaneously.

10) The above is the understanding of Netty ~ specific how to play ~ behind write an article for everyone’s reference