Learning high-performance service system: the network I / O model

About Network I / O model

Network transmission format information

  • XML: wide range of applications, suitable for network communication of information description format
  • JSON: a lightweight data interchange format.
  • Protocol Buffer (PB): A data exchange format
  • TLV: T: Type the domain L: Size Field V: content domain for financial, military field
  • Custom format: For example, after serialization data Apache Thrift

BIO blocking problems:

Either client or server, at the same time can only send or receive a message. In the interval of waiting for a reply, is "blocking" problem.
Even with multi-threaded server-side manner accept (), read () method will still be blocked.

NIO non-blocking synchronization - BIO is a synchronous blocking improvements

NIO, also known as multiplexed I / O model.
Scenario: Applies to "high concurrency" scene, otherwise there is no obvious advantage NIO
NIO: reading data into the buffer from the channel, the channel from the write buffer.

Here Insert Picture Description

  • Channel Channel: for applications and the operating system to channel interaction.
  • buffer Buffer: guaranteed write rate for each channel.
  • Selector Selector: Channel achieve the specified I / O event binding.

The flow channel is similar, but there are differences :
1. The data channels can be read, data can be written. However, read and write operations stream is unidirectional.
2. asynchronously read channel
3. The channel data buffer always go through

AIO asynchronous non-blocking

Asynchronous reflected:

  • Synchronous I / O stream server will not "take the initiative" to contact the client, but AIO after the data ready, will take the initiative to inform "clients"
  • Asynchronous I / O processing is handed over to OS, and they will handle asynchronous applications.

NIO and the difference AIO:
AIO NIO been carried out through the duct I / O operations, but each processor AIO channel are independent, one by one enantiomer, NIO is matched by the selector.

Guess you like

Origin blog.csdn.net/weixin_40990818/article/details/86373909