本文介绍了Netty 4:高写和低写水印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Netty 4.我看到Netty服务器的下列选项:WRITE_BUFFER_HIGH_WATER_MARK和WRITE_BUFFER_LOW_WATER_MARK。

I am working with Netty 4. I see folowing options of Netty server: WRITE_BUFFER_HIGH_WATER_MARK and WRITE_BUFFER_LOW_WATER_MARK.

官方网页链接到。其中一个幻灯片如下所示:

The official page Related articles has link to Netty best practices (slides w/ video) by Norman Maurer. One of slides looks like this:

ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap.childOption(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, 32 * 1024);
bootstrap.childOption(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, 8 * 1024);

并有此前言:

但是什么是WRITE_BUFFER_HIGH_WATER_MARK和WRITE_BUFFER_LOW_WATER_MARK?以及如何将它们设置为理智

But what is it WRITE_BUFFER_HIGH_WATER_MARK and WRITE_BUFFER_LOW_WATER_MARK? And how to set them to be sane?

我没有找到任何明确的信息。感谢您的帮助。

I did not find any clear information. Thanks for your help.

推荐答案

有关水印的一些信息来自文章:

Some information about watermarks from this article:

注意,为了使客户能够适应速度,您需要处理
任务(实际上是为了适应窗口大小)一个不应该在高水位和低水位之间产生很大的差距
。另一方面,小差距意味着
你经常在事件循环中添加/删除套接字。

Note, to make it possible for clients to adapt to speed you process tasks (actually to adapt window size) one shouldn't make a big gap between high and low watermarks. From the other side small gap means you'll be too often add/remove sockets from the event loop.

For Netty似乎是真的,因为 JavaDoc for ChannelConfig 说:

For Netty it seems to be true, because this JavaDoc for ChannelConfig says:

对于低水印:

关于理智,我认为,这是相对的问题,这取决于您通过频道发送的信息以及频率。对于必须为这些变量定义的值,没有严格的规则。所以,我认为,你必须在实践中找到自己的价值观。幻灯片向您展示了其中一个示例。

About sanity, I think, it is relative question, that depends on information that you are sending through the channel and how often. There is no strict rules for what values you must define for that variables. So, I think, you must found your own values in practice. Slides show you one of the examples for that.

这篇关于Netty 4:高写和低写水印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 23:20