NIO is suitable for architectures with a large number of connections and relatively short connections (light operations), such as chat servers, and is limited to applications.
AIO mode is used in architectures with a large number of connections and relatively long connections (re-operations), such as photo album servers, to fully invoke OS to participate in concurrent operations
How do you understand these two paragraphs?
NIO is synchronous and needs tomcat to poll. When there are many and short connections, the polling efficiency is higher. However, if most connections take a long time, the polling overhead will be increased and a lot of Central Processor and Period will be wasted.
AIO is asynchronous and does not require polling, but requires the participation of the operating system. Therefore, if there are many and short connections, it will switch frequently between kernel and user states, and the performance is not as good as polling.
Let’s make a metaphor. You need to take all kinds of materials and equipment for your experiment. If there are a lot of things and it takes a long time to fetch them (the warehouse is downstairs or even outside the laboratory), then you must choose to have your assistant fetch them for you. This assistant is similar to the role of the operating system in AIO.
However, if there are a lot of things, but they are placed on the shelves beside them and sorted out, it is easy to get them. at this time, although you can still ask your assistant to help you get them, it is probably not as convenient as you get them yourself, especially when the name of the thing is very long and difficult to say, and it takes a lot of time to communicate with the assistant (comparing the fact that switching between user mode and system mode costs a lot)