美文网首页
epoll bug fix in netty

epoll bug fix in netty

作者: 水欣 | 来源:发表于2018-02-25 20:50 被阅读0次

epoll bug简述

在NIO中通过Selector的轮询当前是否有IO事件就绪,根据JDK NIO api描述,Selector的select方法会一直阻塞,直到IO事件达到或者超时,但是在Linux平台上这里有时会出现问题,在某些场景下select方法会直接返回,即使没有超时并且也没有IO事件达到,这就是著名的epoll bug,这是一个比较严重的bug,它会导致线程陷入死循环,会让CPU飙到100%,极大地影响系统的可靠性,到目前为止,JDK都没有完全解决这个问题。

在netty如何规避

epoll bug在netty中有效的规避了这个问题,经过实践证明,epoll bug已在netty框架中解决,netty的处理方式是这样的:
记录select空转的次数,定义一个阈值,这个阈值默认是512,可以在应用层通过设置系统属性io.netty.selectorAutoRebuldThreshold传入,当空转的次数超过了这个阈值,重新构建新Selector,将老Selector上注册的Channel转移到新建的Selector上,关闭老Selector,用新的Selector代替老Selector,详细实现可以查看NioEventLoop中的selector和rebuildSelector方法。

相关文章

  • epoll bug fix in netty

    epoll bug简述 在NIO中通过Selector的轮询当前是否有IO事件就绪,根据JDK NIO api描述...

  • 从一个bug来了解Gama空间

    从一个bug来了解Gama空间 bug 光照强度系数bug fix前bug fix后0.0120210525174...

  • NIO的epoll空轮询bug

    NIO的epoll空轮询bug JDK NIO的BUG,例如臭名昭著的epoll bug,它会导致Selector...

  • 提交常犯的错误

    Typo. '#' 号跟 bug 号之间加了空格. FIX 之后没有 ":" . FIX: 之后没有空格. bug...

  • [串]子串搜索:brute_force --> KMP -

    -------------Update 6.9 BUG FIX--------------------------...

  • window.open

    description today, I do a new story fix the bug for the ...

  • For IT guys

    For IT guys,love is bug. And it's hard to fix.....

  • netty

    netty 高性能,异步,事件驱动库 Unix io模型 阻塞io 非阻塞io,netty主要就是基于epoll的...

  • 提交规范

    提交规范 feat:a new feature 一个新功能 fix:a bug fix 问题修复 docs:do...

  • Git interactive rebase

    Say I created a branch '' to fix a bug, for debugging, mu...

网友评论

      本文标题:epoll bug fix in netty

      本文链接:https://www.haomeiwen.com/subject/uefdxftx.html