Netty Network framework based on NIO

Source: Internet
Author: User
Tags ftp protocol

Netty is a high-performance, asynchronous event-driven NIO framework that provides support for TCP, UDP, and file transfers, and all IO operations of Netty are asynchronous and non-blocking, through the future-listener mechanism, The user can obtain the IO operation result conveniently or through the notification mechanism.

The advantages of Netty are:

A, rich features, built-in a variety of data codec functions, support a variety of network protocols.

B, high performance, by contrast with other mainstream NIO network framework, its comprehensive performance is the best.

C, scalability is good, can be provided by the Channelhandler components of the network communication aspects of flexible expansion.

D, ease of use, simple API usage.

E, after a lot of commercial application test, in the Internet, online games, big data, telecommunications software and many other industries have been successful commercial.

The Netty is designed with a typical three-layer network architecture, with the following logical architecture diagram:

The first layer: Reactor communication scheduling layer. The main function of this layer is to listen to the network connection and read and write operations, is responsible for the network layer of data read into the memory buffer, and then trigger a variety of network events, such as connection creation, connection activation, read events, write events, etc., to trigger these events into the pipeline, The chain of responsibilities that pipeline acts as a follow-up process.

The second layer: the responsibility chain pipeline layer. Responsible for the orderly forward (post) communication of the incident in the chain of responsibility, and responsible for the dynamic orchestration of the responsibility chain. Pipeline can choose to listen and handle events of their own interest.

The third layer: business logic processing layer, generally can be divided into two categories: a. Pure business logic processing, such as logging, order Processing. B. Application layer protocol management, such as HTTP (S) protocol, FTP protocol, etc.

We all know that the main factors that affect the performance of network Service communication are: network I/O model, thread (process) scheduling model and data serialization mode.

In the network I/O model, the Netty is based on non-blocking I/O implementations, and the underlying dependencies are the selector of the Jdknio framework.

In terms of thread scheduling model, Netty adopts reactor threading model. There are three commonly used reactor threading models, namely:

A, reactor single-threaded model: Reactor single-threaded model, which means that all I/O operations are done on the same NIO thread. For some small-capacity scenarios, you can use a single-threaded model.

B, reactor multithreading model: Rector The biggest difference between a multithreaded model and a single-threaded model is that there is a set of NIO threads that handle I/O operations. It is mainly used for high concurrency and large traffic scenarios.

C, master-slave reactor multithreading model: The main feature of the master-slave reactor threading model is that the server is no longer a separate NIO thread for receiving client connections, but rather a separate NIO thread pool. With the master-slave NIO threading model, a server-side listener thread is unable to effectively handle all client connections with insufficient performance issues. Netty threading model is not fixed, it can support three kinds of reactor threading model.

In terms of data serialization, the main factors that affect serialization performance are:

A, the serialized stream size (network bandwidth consumption).

B, the performance of serialization and deserialization operations (CPU resource consumption).

C, the performance of concurrent calls: stability, linear growth and so on.

Netty provides support for the Googleprotobuf binary serialization framework by default, but by extending the Netty codec interface, other high-performance serialization frameworks can be implemented, such as the compressed binary codec framework for Avro and thrift.

Netty Network framework based on NIO

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.