场景:使用Netty UDP协议将PHP程序的运行日志推送到Elasticsearch 中 。
采用:NioDatagramChannel 通道来实现UDP数据传输
突然想到 Netty 的Reactor 线程模型 ,准备使用主从多线程Reacrtor 线程模型 。之前的代码如下

红色部分:表示在UDP协议时 使用BootStrap 而不是:ServerBootStrap
StackOverFlow 上针对 UDP 有如下的Answer
there is no need for NioServerDatagramChannel, because UDP servers open one channel for all clients.
- ServerBootstrap allows many client to connect via its channel. Therefore TCP has a dedicated ServerSocketChannel.
- Bootstrap is used to create channels for single connections. Because UDP has one channel for all clients it makes sense that only the Bootstrap is requried. All

本文介绍了使用Netty的UDP协议实现PHP日志推送至Elasticsearch的场景。讨论了Netty的Reactor线程模型,指出在UDP中,由于所有客户端共享同一通道,因此只需要Bootstrap,而不需要ServerBootstrap。同时,文章提出了使用单通道传输大量日志可能影响吞吐量的问题,并预告将在后续内容中探讨解决方案。
最低0.47元/天 解锁文章
10万+

被折叠的 条评论
为什么被折叠?



