Input/Output
Input/output (I/O) is one of the bottlenecks affecting the
system performance. So we spend a lot of time and effort to
improve the I/O performance.
In computing, I/O module is the exchange of information
between the brain (CPU/memory combo) of computer and
the database stored in a physical disk. I/O can be divided into
two classes according to the realization of system call
function in Java language: blocking and non-blocking. In the
light of interaction between application and kernel, I/O can
be synchronous or asynchronous. In theory, asynchronous
non-blocking I/O (AIO) should have the best performance
and scalability. However, through the experiment, we find
that the performance of AIO is not better than synchronous
non-blocking I/O (NIO) on Linux, even worse sometimes.So
we finally chose the NIO technique.
Java NIO technology actually takes the Reactor model,
or the Observer model, to monitor the I/O port. There is a
Selector class, similar to the observer. As long as we tell
Selector socket channel which is need to register, we can go
on to do other things. When an event occurred, it will
inform us and return a set of Selection Key. By reading
these keys, we can obtain registered socket channel and then