netty 是否要开启业务线程池

 1

业务线程池 加快io线程效率(不处理业务) 避免 同步处理回执时 意外阻塞 io线程,或handler处理太慢拖累io线程,从而导致堆外溢出

缺点是:业务处理完后,待写入,发现要切换线程到io线程,加大线程切换的开销,与netty3读写非同一线程有些像

如果仅仅handler处理慢,加大worker线程可缓解

即使要付出线程上下文切换的代价,也建议使用非阻塞的方式,

比较好的做法是用mq或disruptor等高性能队列,以免阻塞io线程

 

参考:

1)

https://mp.weixin.qq.com/s?__biz=MzAwNzM1NjQyNg==&mid=2649962670&idx=1&sn=fea574180ccb8a7f4a7a2f3811f5fd09&chksm=8378f1cbb40f78dd34027efb3e09ca54f965b54f3d7702acf00d9cb37b8f6574326ed9a97d14&mpshare=1&scene=1&srcid=1025ixQnnhxAWRK6KZwOhMyL&key=9ec638334fce6a48492debe7e2682c5bdc4e75c453c0a7c05215e8a02e1c1d11afd628d103e529c858c4072d9804700b946a46caa8acea26328e680e21bcc448530706ccf72d5d3fbfff6d25ddc51fa4&ascene=0&uin=MTA2NzUxMDAyNQ%3D%3D&devicetype=iMac+MacBookAir6%2C2+OSX+OSX+10.10.5+build(14F2511)&version=11020012&lang=zh_CN&pass_ticket=DJCutZN70YSX5MvhvFlrbJcCzmL%2BMr8fpo3x1wp99RJRCkJZKwgUcoYSQyV0n8CG

 

2)

https://mp.weixin.qq.com/s?__biz=MzUzMTA2NTU2Ng==&mid=2247485224&idx=2&sn=510b6f2de976b80f4f2c65988338620a&chksm=fa497899cd3ef18f7d61eafcf372c61412ca8dda121c650370cafcd707054703a59e63dc7e7b&mpshare=1&scene=1&srcid=10093E4oi3IqrrgTyjzPeQ4v&key=aabb2ccd6a655235489a98a8010871fd860370d6dc76bd25b584f375d8293bf0148b8d36c8905a912b770991dec6af2a8967d227316cd6c07c5883567bdb7ccd8f3a41eadcafbe74c569df290b1780f6&ascene=0&uin=MTA2NzUxMDAyNQ%3D%3D&devicetype=iMac+MacBookAir6%2C2+OSX+OSX+10.10.5+build(14F2511)&version=11020012&lang=zh_CN&pass_ticket=3sXqr7c2oEvhreALgBwX%2FGLK0mOv%2BqBK9kOHRAlS3NHnD19yGGWL0GX1fFKdJ7eU

 

 

 

 

https://blog.csdn.net/u010739551/article/details/82887411,该链接出于线程切换的性能损耗,建议使用io线程write

write异步与流量控制 4.0.29.Final 该链接指出了业务线程write会经历增加-减少-增加 3次,而在io线程write只会增加1次

重点:堆外溢出

 

客户端异步、服务端异步与并发事务处理数、连接数的关系【重要】 提示了,是否开启业务线程池还影响单个连接可处理的并发事务数;还用厕所理论形象的描述了使用io线程导致堆外溢出时的厕所场景

posted on 2018-10-22 17:15  silyvin  阅读(3946)  评论(0编辑  收藏  举报