Each netty worker wakes up 2 times per second. Why?
N开发者_运维知识库ioWorker.run calls SelectorUtil.select that does select with 500 ms timeout.
NioClientSocketPipelineSink.Boss.run calls select with 500 ms timeout.
NioServerSocketPipelinkSink.Boss.run also call select with 1000 ms timeout.
So each worker wakes up at least once per second even if nothing happens on the network. Is it a workaround against some problem? I though good event-driven program must not wake up if nothing happened (i. e. call "select" with infinite timeout). There is no explanation in the sources.
What if you want to shutdown the server?, If we don't use a timeout, we only wake up when a real event come from network, it maybe take much time to shutdown in a clean way(maybe never). These timeout are acceptable in most cases, we don't have to wait too long after issue shutdown command, and the checking event loop not take much CPU resource.
精彩评论