How to understand "Tomcat NIO method is suitable for connections with a large number of connections and short connections, and AIO mode is used for connections with a large number of connections and long connections"?

NIO is suitable for architectures with a large number of connections and short connections (light operation), such as chat servers, and concurrency is limited to applications

AIO is used in architectures with a large number of connections and long connections (re-operation), such as photo album server. Fully call OS to participate in concurrent operations

< hr >

how to understand these two paragraphs?


NIO is on Synchronize and needs to be polled by tomcat. When there are many and short connections, the polling efficiency is high, but if most connections take a long time, it will increase the polling overhead and consume a lot of cpu cycles.

AIO is asynchronous, does not need polling, but requires the participation of the operating system, so if there are many and short connections, it will frequently switch between kernel and user mode, and the performance is not as good as polling.

make an analogy. You need to take all kinds of materials and equipment to do the experiment. If there are a lot of things and it takes a long time to pick it up (the warehouse is downstairs or even outside the lab), you must choose to ask your assistant to pick it up for you. This helper is similar to the role of the operating system in AIO.

but if there are also a lot of things, but they are on the next shelf and placed in different categories, it is easy to get them. At this time, although you can still ask your assistant to pick them up for you, it is probably not as convenient as your own. Especially when the name of the thing is very long and mouthful, it takes a lot of time to communicate with the assistant (compared to the fact that it is expensive to switch between user mode and system mode)

Menu