Today, when using AB for stress testing, it is unintentional to discover:
Requests per second:xxx [#/sec] (mean)
Ab-n 5000-c http://www:8080/upload/5kb.jpg (nioserver:700 aio:400)
Ab-n 5000-c http://www:8080/upload/18kb.jpg (nioserver:560 aio:360)
Ab-n 2000-c http://www:8080/upload/134kb.jpg (nioserver:330 aio:300)
Ab-n 2000-c http://www:8080/upload/134kb.jpg (nioserver:330 aio:260)
ab-n 3000-c http://www:8080/upload/134kb.jpg (nioserver:300 aio:310)
Ab-n 5000-c http://www:8080/upload/134kb.jpg (nioserver:270 aio:280)
Most of the previous tests were using-K (open: connection:keep-alive), and the test found that Aio was a triumph for NIO.
No parameters are used today:-K, as seen from the above results:
1. NiO in high concurrency, if you are dealing with small pictures (1kb-100kb), NiO's concurrency is better than AIO.
The reason is also very simple, nio no matter how much concurrency, generally only use 2-3 threads to handle, in processing small pictures, high concurrency, CPU utilization 90%+, concurrency performance is very good.
And AIO, because it is asynchronous, the transfer file uses a thread pool, generally use 20-30 threads, in the processing of small pictures, high concurrency, because of the number of threads,CPU utilization in 50%-70%, and multiple thread switching also wasted some performance, concurrency is not as good as NIO.
2. When processing files become larger, such as 100kb+, high concurrency, AIO will reach or exceed NiO, both working CPU utilization: 90%+.
2013-03-06
One more talk about AIO (asynchronous IO) vs. NIO (non-blocking IO) in Java