BIO, NIO, Aio difference--netty series (i)

Source: Internet
Author: User

Netty is an asynchronous event-driven network application framework for rapid development of high-performance, highly reliable network servers and client programs. In other words, Netty is a NIO framework that can be used to quickly and easily develop network applications, such as client and server-side protocols. This is a description of the official document, as a Java beginner, this is a noun nio is completely without concept, for this purpose, the special reference to the relevant information, NIO has a clearer understanding.

The description of NIO is usually compared to that of bio and AIO. The concepts of the three are described separately below.

BIO: synchronization and blocking, the server implementation mode is a connection to a thread, that is, when the client has a connection request, the server will need to start a thread to process (a client-side threads). The biggest problem with this model is the lack of elasticity and scalability, when the client concurrent traffic increases, the number of threads on the server and the number of concurrent accesses by the client is 1:1, the system performance will drop dramatically, and as the concurrent traffic continues to increase, the system will have a thread stack overflow, the creation of a new thread failure, etc. And eventually lead to downtime or zombie.

NIO: asynchronous Non-blocking, server implementation mode for a request of a thread, the client sent the connection request will be registered to the multiplexer, multiplexer polling to connect with I/O requests before starting a thread to process.

For NIO, there are two points to emphasize:

(1) There are two understandings about the concept, new I/O (as opposed to the previous I/O library is new) and Non-block I/O (non-blocking). Because the goal of NIO is to have Java support non-blocking I/O, all more people prefer to use non-block I/O.

(2) Many people like to refer to NiO as asynchronous non-blocking I/O, but if differentiated according to the strict NUIX network programming model and the implementation of the JDK, it is actually a non-blocking I/O and cannot be called asynchronous non-blocking I/O. However, because the NIO library supports non-blocking read and write, it is asynchronous compared to the previous synchronization blocking read and write, so many people are accustomed to calling NiO an asynchronous non-blocking I/O.

AIO: JDK1.7 upgraded the NIO library, and the upgraded NiO library, known as NIO2.0, formally introduced the concept of an asynchronous channel. The NIO2.0 asynchronous socket channel is truly asynchronous non-blocking I/O, which is AIO. Its server implementation mode is a valid request for a thread, the client's I/O request is completed by the OS first and then notify the server application to start the thread processing.

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.