开发者

Each netty worker wakes up 2 times per second. Why?

开发者 https://www.devze.com 2023-03-03 05:47 出处:网络
N开发者_运维知识库ioWorker.run calls SelectorUtil.select that does select with 500 ms timeout.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号