Netty (13)-Overview of Netty

1. Problems with native NIO

1) NIO's class library and API are complicated and troublesome to use: you need to be proficient in Selector, ServerSocketChannel, SocketChannel, ByteBuffer, etc.
2), need to have other additional skills: to be familiar with Java multi-threaded programming, because NIO programming involves the Reactor mode, you must be very familiar with multi-threaded and network programming in order to write high-quality NIO programs.
3) The workload and difficulty of development are very large: for example, the client is facing disconnection and reconnection, network flash interruption, half-packet read and write, failed cache, network congestion and abnormal flow processing, etc.
4) Bugs of JDK NIO: For example, the notorious Epoll Bug, it will cause Selector empty polling, and eventually lead to 100% CPU, until the JDK1.7 version, the problem still exists and has not been fundamentally solved.

2. Basic introduction to Netty

2.1 Netty official website description

Official website: https://netty.io/

Netty is an asynchronous event-driven network application framework
for rapid development of maintainable high performance protocol servers & clients.

Netty frame diagram

1) Netty is a Java open source framework provided by JBOSS. Netty provides an asynchronous, event-driven network application framework for rapid development of high-performance, high-reliability network IO programs.
2) Netty can help you develop a network application quickly and simply, which is equivalent to simplifying and streamlining the development process of NIO.
3) Netty is currently the most popular NIO framework. Netty has been widely used in the Internet field, big data distributed computing field, game industry, communication industry, etc. Netty is used in the well-known Elasticsearch and Dubbo frameworks.

2.2 Netty advantages

Netty encapsulates the NIO API that comes with the JDK, and solves some of the NIO problems.
1) Elegant design: unified API for various transmission types; blocking and non-blocking Socket; based on a flexible and extensible event model, which can clearly separate concerns; highly customizable threading model-single thread, one or Multiple thread pools.
2) Easy to use: well-documented JavaDoc, user guide and examples; no other dependencies, JDK5 (Netty 3.x) or JDK6 (Netty 4.x) is sufficient.
3) High performance and higher throughput: lower latency; reduce resource consumption; minimize unnecessary memory copy.
4), security: complete SSL/TLS and StartTLS support.
5) Active community and continuous update: The community is active, the version iteration cycle is short, the bugs found can be fixed in time, and at the same time, more new features will be added.

2.3 Netty release notes

1), Netty version is divided into: Netty3.x, Netty4.x and Netty5.x.
2). Because of major bugs in Netty5, it has been abandoned by the official website. Currently, the stable version of Netty4.x is recommended.
3). The versions currently available for download on the official website: Netty3.x, Netty4.0.x and Netty4.1.x.
4), Netty download address: https://bintray.com/netty/downloads/netty

Guess you like

Origin blog.csdn.net/yangxshn/article/details/113839728