Get the App
SLTechnology News&Howtos  ›  Development  › 

What does Netty support for iBO mode?

Shulou Source: shulou.com Published: 2022-06-03 02:07:12 10月04日 Update

This article mainly explains "what I/O modes Netty supports". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "What I/O mode does Netty support"!

1 Classic I/O mode

BIO (blocking I/O)JDK1.4 before NIO (non-blocking I/O)JDK1.4 (2002, java.nio package)AIO (asynchronous I/O) JDK1.7 (2011)

1.2 contrast concept

blocking and non-blocking

Do you want to wait until the data is ready?

blocking

When there is no data coming, reads block until there is data; when the buffer is full, writes block.

non-blocking

returned directly

synchronous and asynchronous

After the data is ready, who completes the data operation?

You need to read it yourself. Is it synchronized?

The data is ready to read directly and then call back to the program is asynchronous

2 Netty support changes for three IO types

Underlined is no longer supported oh!

Why abolish blocking I/0 (BIO/OIO) ?

High number of connections: blocking-> resource consuming, inefficient.

Blocking means waiting, waiting will always occupy the thread, when the connection count is high, most threads are waiting, will exhaust the system thread resources.

Why delete AIO support already done?

Windows implementation matures, but it is rarely used as a server

Linux is commonly used as a server, but its AlO implementation is not mature enough.

AIO under Linux compared to NIO performance improvement is not obvious

Therefore, netty also selectively supports high-performance IO mode in connection with the actual situation.

Why does Netty support multiple implementations?

Common NIO implementation is also epoll under Linux, but Netty still chooses to implement it itself because it is better:

Netty offers more controllable parameters:

JDK's NIO default implementation is horizontal triggering

Netty is edge triggered (default) and horizontal triggered, and switchable

Netty achieves less garbage collection and better performance

Is NIO better than BIO?

BIO code is simple and in certain scenarios: few connections, low concurrency, BIO performance does not lose NIO. Of course, considering that the later stage of business development is a complex scenario, Netty only considers NIO.

At this point, I believe that everyone has a deeper understanding of "what I/O mode Netty supports", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Tags: Blocking support pattern data performance threading maturity content scenario reality situation more server level synchronization learning service selection complex practical Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MySQL Microsoft Docker Shulou Technology