Netty thread model

tags: Netease Cloud Classroom-Micro Professional Java

Netty is a very efficient network communication framework. Why is it efficient? The reason is a good threading model and memory management. Netty's thread model is designed and developed based on Reactor mode. Reactor mode is based on event-driven, especially suitable for handling massive I / O events.
 The above picture is a Reactor thread model. Based on select (), epoll (), the Reactor thread separates I / O call requests and I / O operations. In theory, a Reactor thread can handle N network I / O operations, but when When the amount of concurrency is large, a Reactor thread will have problems such as slow response and connection timeout.
Then a Reactor thread model cannot cope with large concurrent network requests, we can further choose the Reactor thread group.
Rector multithreading has a dedicated NIO thread for monitoring the server and accepting TCP connection requests from clients. The reading and writing of network IO is handled by a NIO thread pool. This already has a high processing capacity. However, in very special cases, the NIO thread is responsible for monitoring and processing all client connections and performance issues may occur. In order to solve the performance problem, a third type of Reactor threading model-the master-slave Reactor multithreading model was produced.
The feature of the master-slave Reactor thread model is that the server receives no client connection from a single NIO thread, but an independent NIO thread pool. After receiving the client request, Acceptor registers the newly created SocketChannel to an IO thread in the IO thread pool, which is responsible for the reading, writing, encoding and decoding of SocketChannnel.
The thread model is shown below:

Specifically, NioEventLoop is the Reactor thread of Netty, which is responsible for processing client request access, and is also responsible for registering the monitoring connection operation bit, which is used to judge the result of asynchronous connection and monitoring the network read operation bit , Responsible for writing messages to the SocketChannel and sending to the other party, to perform these tasks of ordinary task threads.

Intelligent Recommendation

013. NETTY thread model

Introduction to Netty Netty is a high-performance, high-scalable asynchronous event-driven network application framework, which greatly simplifies network programming such as TCP and UDP clients and s...

Netty thread model and basics

Why use Netty Netty is an asynchronous event-driven web application framework for rapid development of maintainable high-performance and high-profile servers and clients. Netty has the advantages of h...

Netty thread model and gameplay

Event cycle group   All I / O operations in Netty are asynchronous, and the asynchronous execution results are obtained by channelfuture. Asynchronously executes a thread pool EventLoopGroup, it ...

Netty - Thread Model Reactor

table of Contents Thread model 1, traditional IO service model 2, Reactor mode reactor Three modes: to sum up Netty model Excommissum Thread model 1, traditional IO service model Blocked IO mode Get i...

Netty thread model [next]

Hey everyone, I amJava small white 2021。 The programmer of the halfway is in the development of aircraft, and the opportunity to find a more interesting thing under the development of a surveying cour...

More Recommendation

【Netty】 thread model

content 1. Single Reactor single thread 2. Single Reactor Multi -thread 3. Reactor Main Strike Model Single -threaded model (single Reactor single thread) Multi -threaded model (single Reactor multi -...

Netty entry thread model

Single-threaded model: the boss thread is responsible for connection and data reading and writing Hybrid model: the boss thread is responsible for connection and data reading and writing, and the work...

Redis source code parsing: 09redis database implementations (key operation, key timeout function key space notification)

This chapter of the Redis database server implementations are introduced, indicating achieve Redis database-related operations, including key-value pairs in the database to add, delete, view, update a...

PAT B1041-B1045 Question

1、b1041 2、b1042 3、b1043 4、b1044 5、b1045...

Sorting Algorithm - Overview

Seven commonly used sorting algorithm: 1w integers sorted tested Explain the principles of: 1, direct insertion sort be a sorted array A, an empty array B, once the elements A B into a specific positi...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top