r******g 发帖数: 138 | 1 不太明白Event-driven为什么比socket+threadpool model 更能处理大量request
concurrently. 假如socket+threadpool 设置的pool size是10,而且每个thread 都是
long running job的话, 第11个request会block。对NIO来说,尽管只有一个thread
for event loop,每获得的event读和写也需要单独的thread来处理,如果也用thread
pool的话并且pool size也是10,那第11个request不也是要等前面10个request有一个
结束才被处理获得response? |
F****n 发帖数: 3271 | 2 Because I/O are usually highly uncertain operations.
What about one of your 10 long running job starts to wait for the device/
party it is communicating with? In the blocking model, the thread will just
wait and get totally wasted. In an asynchronous/event-based model, the
thread will hang this job and process other jobs.
thread
【在 r******g 的大作中提到】 : 不太明白Event-driven为什么比socket+threadpool model 更能处理大量request : concurrently. 假如socket+threadpool 设置的pool size是10,而且每个thread 都是 : long running job的话, 第11个request会block。对NIO来说,尽管只有一个thread : for event loop,每获得的event读和写也需要单独的thread来处理,如果也用thread : pool的话并且pool size也是10,那第11个request不也是要等前面10个request有一个 : 结束才被处理获得response?
|
w**z 发帖数: 8232 | 3 CPU bound 不适合 event driven
thread
【在 r******g 的大作中提到】 : 不太明白Event-driven为什么比socket+threadpool model 更能处理大量request : concurrently. 假如socket+threadpool 设置的pool size是10,而且每个thread 都是 : long running job的话, 第11个request会block。对NIO来说,尽管只有一个thread : for event loop,每获得的event读和写也需要单独的thread来处理,如果也用thread : pool的话并且pool size也是10,那第11个request不也是要等前面10个request有一个 : 结束才被处理获得response?
|
r******g 发帖数: 138 | 4 不太明白Event-driven为什么比socket+threadpool model 更能处理大量request
concurrently. 假如socket+threadpool 设置的pool size是10,而且每个thread 都是
long running job的话, 第11个request会block。对NIO来说,尽管只有一个thread
for event loop,每获得的event读和写也需要单独的thread来处理,如果也用thread
pool的话并且pool size也是10,那第11个request不也是要等前面10个request有一个
结束才被处理获得response? |
F****n 发帖数: 3271 | 5 Because I/O are usually highly uncertain operations.
What about one of your 10 long running job starts to wait for the device/
party it is communicating with? In the blocking model, the thread will just
wait and get totally wasted. In an asynchronous/event-based model, the
thread will hang this job and process other jobs.
thread
【在 r******g 的大作中提到】 : 不太明白Event-driven为什么比socket+threadpool model 更能处理大量request : concurrently. 假如socket+threadpool 设置的pool size是10,而且每个thread 都是 : long running job的话, 第11个request会block。对NIO来说,尽管只有一个thread : for event loop,每获得的event读和写也需要单独的thread来处理,如果也用thread : pool的话并且pool size也是10,那第11个request不也是要等前面10个request有一个 : 结束才被处理获得response?
|
w**z 发帖数: 8232 | 6 CPU bound 不适合 event driven
thread
【在 r******g 的大作中提到】 : 不太明白Event-driven为什么比socket+threadpool model 更能处理大量request : concurrently. 假如socket+threadpool 设置的pool size是10,而且每个thread 都是 : long running job的话, 第11个request会block。对NIO来说,尽管只有一个thread : for event loop,每获得的event读和写也需要单独的thread来处理,如果也用thread : pool的话并且pool size也是10,那第11个request不也是要等前面10个request有一个 : 结束才被处理获得response?
|
c*m 发帖数: 836 | 7 事实上NIO的性能的确也不比传统多线程读写差,你可以google一下,有很多文章。
thread
【在 r******g 的大作中提到】 : 不太明白Event-driven为什么比socket+threadpool model 更能处理大量request : concurrently. 假如socket+threadpool 设置的pool size是10,而且每个thread 都是 : long running job的话, 第11个request会block。对NIO来说,尽管只有一个thread : for event loop,每获得的event读和写也需要单独的thread来处理,如果也用thread : pool的话并且pool size也是10,那第11个request不也是要等前面10个request有一个 : 结束才被处理获得response?
|
g*********9 发帖数: 1285 | 8 memory and thread switching are overhead for blocking model.
【在 w**z 的大作中提到】 : CPU bound 不适合 event driven : : thread
|
x*a 发帖数: 7 | |
w***1 发帖数: 1951 | 10 Compare to java.io
【在 x*a 的大作中提到】 : what is NIO?
|
c*********p 发帖数: 3217 | 11 我记得,thread 的话会有个峰值,然后性能下降. |