You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@dubbo.apache.org by 徐靖峰 <25...@qq.com> on 2019/01/07 02:54:53 UTC

[Proposal] A proposal to use IdleStateHandler to replace using Timer to send HeartBeat.

Hi all

现状:

Dubbo 在应用层面发送心跳包保证连接的可用性,使用了定时器的设计,在客户端和服务端分别设置一个定时器,发送心跳,当发现连接断开时,客户端负责重连,服务端负责 close。使用定时器并不是一个好的设计,在忙通信时,心跳是不必要的。建议使用 Netty 的 IdleStateHandler,仅仅在检测到空闲连接时发送心跳。

修改建议:

使用 IdleStateHandler 代替 Timer 发送心跳
关闭 ChannelOption.SO_KEEPALIVE,网络层面的 TCP 断连需要在机器级别设置,默认是 2 小时,几乎没有必要存在,却发出了无必要的 TCP 探测包,仅仅依赖于应用层的心跳来给连接保活即可。
For now:

Dubbo sends a heartbeat packet at the application level to ensure the availability of the connection. A timer is set on the client and the server to send a heartbeat. When the connection is found to be disconnected, the client is responsible for reconnection and the server is responsible for close. Using a timer is not a good design, and the heartbeat is unnecessary when communicating busy. It is recommended to use Netty's IdleStateHandler to send a heartbeat only when an idle connection is detected.

Proposed changes:

Send heartbeats using IdleStateHandler instead of Timer
Close ChannelOption.SO_KEEPALIVE, TCP disconnection at the network level needs to be set at the machine level. The default is 2 hours. There is almost no need to exist, but an unnecessary TCP probe packet is issued. It only depends on the heartbeat of the application layer to keep the connection alive. Just fine.


Re: [Proposal] A proposal to use IdleStateHandler to replace using Timer to send HeartBeat.

Posted by Jun Alpha <al...@gmail.com>.
@  yuhang xiu
I have review your pr, and I think maybe something need to change about the
close method, also I have left a comment , could you pls review it?

Ian Luo <ia...@gmail.com> 于2019年1月22日周二 下午2:12写道:

> Yuhang,
>
> Nice catch. Could you pls. review my comments on your pull request?
>
> Thanks,
> -Ian.
>
>
> On Tue, Jan 22, 2019 at 11:36 AM yuhang xiu <ca...@gmail.com> wrote:
>
> > Hi, jingfeng,
> >
> > I saw beiwei merge your pr, nice work!
> >
> > However, I think we still need to consider two things.
> >
> > Since we are using a shared timer, this timer will not be closed when a
> > client is closed.
> > In this case, we need to control our tasks without unlimited growth. My
> > current practice is to create a mapping between client and task. When our
> > client is closed, we can find the corresponding task and cancel them. The
> > canceled task will not be re-inserted into the timer.
> >
> > The other thing, I modified the size of the shared timer. In the old
> > version, since each client uses a timer alone, the size of the timer is
> > only 16, and now it is changed to 128 to reduce the hash conflict.
> >
> > My pr is here:
> > https://github.com/apache/incubator-dubbo/pull/3299
> >
> > Would u pls have a look?
> >
> > 徐靖峰 <ki...@foxmail.com> 于2019年1月15日周二 下午2:49写道:
> >
> > > Hi folks,
> > >
> > > Here is my suggestion to improve Dubbo’s HeartBeat Design.
> > >
> > > - The design of the two-way heartbeat is unnecessary, compatible with
> the
> > > existing logic, allowing the client to send a one-way heartbeat when
> the
> > > connection is idle, and the server periodically detects the connection
> > > availability. Timed time to ensure: client timeout * 3 ≈ server timeout
> > > - Remove the timing tasks for reconnection and disconnection. Dubbo can
> > > judge whether the heartbeat request fails to respond. You can learn
> from
> > > the design of the improved scheme, maintain a mark of the number of
> > > heartbeat failures at the connection level, and successfully respond to
> > any
> > > failures. Clear the mark; continuous heartbeat failure. The client
> > > initiates a reconnection. This can reduce an unnecessary timer, and any
> > > polling method is not elegant.
> > >
> > > I've described more details in my blog, about Dubbo's existing
> heartbeat
> > > program, its shortcomings, and the advantages of replacing it with a
> new
> > > solution, as well as some forward thinking, welcome to discuss.
> > >
> > > bolg:https://www.cnkirito.moe/heartbeat-design/ <
> > > http://www.cnkirito.moe/heartbeat-design/>
> > >
> > > ---
> > >
> > > Hi 乡亲们:
> > >
> > > 我给现有 Dubbo 的心跳方案改进提了两条建议
> > >
> > > -
> 双向心跳的设计是不必要的,兼容现有的逻辑,可以让客户端在连接空闲时发送单向心跳,服务端定时检测连接可用性。定时时间尽量保证:客户端超时时间 *
> > > 3 ≈ 服务端超时时间
> > > - 去除处理重连和断连的定时任务,Dubbo
> > > 可以判断心跳请求是否响应失败,可以借鉴改进方案的设计,在连接级别维护一个心跳失败次数的标记,任意响应成功,清除标记;连续心跳失败 n
> > > 次,客户端发起重连。这样可以减少一个不必要的定时器,任何轮询的方式,都是不优雅的。
> > >
> > > 我的博客中描述了更多的细节,关于 Dubbo 现有的心跳方案,它的不足之处,以及替换成新的方案的优势,以及一些展望思考,欢迎讨论。
> > >
> > > 博客地址:https://www.cnkirito.moe/heartbeat-design/
> >
>

Re: [Proposal] A proposal to use IdleStateHandler to replace using Timer to send HeartBeat.

Posted by Ian Luo <ia...@gmail.com>.
Yuhang,

Nice catch. Could you pls. review my comments on your pull request?

Thanks,
-Ian.


On Tue, Jan 22, 2019 at 11:36 AM yuhang xiu <ca...@gmail.com> wrote:

> Hi, jingfeng,
>
> I saw beiwei merge your pr, nice work!
>
> However, I think we still need to consider two things.
>
> Since we are using a shared timer, this timer will not be closed when a
> client is closed.
> In this case, we need to control our tasks without unlimited growth. My
> current practice is to create a mapping between client and task. When our
> client is closed, we can find the corresponding task and cancel them. The
> canceled task will not be re-inserted into the timer.
>
> The other thing, I modified the size of the shared timer. In the old
> version, since each client uses a timer alone, the size of the timer is
> only 16, and now it is changed to 128 to reduce the hash conflict.
>
> My pr is here:
> https://github.com/apache/incubator-dubbo/pull/3299
>
> Would u pls have a look?
>
> 徐靖峰 <ki...@foxmail.com> 于2019年1月15日周二 下午2:49写道:
>
> > Hi folks,
> >
> > Here is my suggestion to improve Dubbo’s HeartBeat Design.
> >
> > - The design of the two-way heartbeat is unnecessary, compatible with the
> > existing logic, allowing the client to send a one-way heartbeat when the
> > connection is idle, and the server periodically detects the connection
> > availability. Timed time to ensure: client timeout * 3 ≈ server timeout
> > - Remove the timing tasks for reconnection and disconnection. Dubbo can
> > judge whether the heartbeat request fails to respond. You can learn from
> > the design of the improved scheme, maintain a mark of the number of
> > heartbeat failures at the connection level, and successfully respond to
> any
> > failures. Clear the mark; continuous heartbeat failure. The client
> > initiates a reconnection. This can reduce an unnecessary timer, and any
> > polling method is not elegant.
> >
> > I've described more details in my blog, about Dubbo's existing heartbeat
> > program, its shortcomings, and the advantages of replacing it with a new
> > solution, as well as some forward thinking, welcome to discuss.
> >
> > bolg:https://www.cnkirito.moe/heartbeat-design/ <
> > http://www.cnkirito.moe/heartbeat-design/>
> >
> > ---
> >
> > Hi 乡亲们:
> >
> > 我给现有 Dubbo 的心跳方案改进提了两条建议
> >
> > - 双向心跳的设计是不必要的,兼容现有的逻辑,可以让客户端在连接空闲时发送单向心跳,服务端定时检测连接可用性。定时时间尽量保证:客户端超时时间 *
> > 3 ≈ 服务端超时时间
> > - 去除处理重连和断连的定时任务,Dubbo
> > 可以判断心跳请求是否响应失败,可以借鉴改进方案的设计,在连接级别维护一个心跳失败次数的标记,任意响应成功,清除标记;连续心跳失败 n
> > 次,客户端发起重连。这样可以减少一个不必要的定时器,任何轮询的方式,都是不优雅的。
> >
> > 我的博客中描述了更多的细节,关于 Dubbo 现有的心跳方案,它的不足之处,以及替换成新的方案的优势,以及一些展望思考,欢迎讨论。
> >
> > 博客地址:https://www.cnkirito.moe/heartbeat-design/
>

Re: [Proposal] A proposal to use IdleStateHandler to replace using Timer to send HeartBeat.

Posted by yuhang xiu <ca...@gmail.com>.
Hi, jingfeng,

I saw beiwei merge your pr, nice work!

However, I think we still need to consider two things.

Since we are using a shared timer, this timer will not be closed when a
client is closed.
In this case, we need to control our tasks without unlimited growth. My
current practice is to create a mapping between client and task. When our
client is closed, we can find the corresponding task and cancel them. The
canceled task will not be re-inserted into the timer.

The other thing, I modified the size of the shared timer. In the old
version, since each client uses a timer alone, the size of the timer is
only 16, and now it is changed to 128 to reduce the hash conflict.

My pr is here:
https://github.com/apache/incubator-dubbo/pull/3299

Would u pls have a look?

徐靖峰 <ki...@foxmail.com> 于2019年1月15日周二 下午2:49写道:

> Hi folks,
>
> Here is my suggestion to improve Dubbo’s HeartBeat Design.
>
> - The design of the two-way heartbeat is unnecessary, compatible with the
> existing logic, allowing the client to send a one-way heartbeat when the
> connection is idle, and the server periodically detects the connection
> availability. Timed time to ensure: client timeout * 3 ≈ server timeout
> - Remove the timing tasks for reconnection and disconnection. Dubbo can
> judge whether the heartbeat request fails to respond. You can learn from
> the design of the improved scheme, maintain a mark of the number of
> heartbeat failures at the connection level, and successfully respond to any
> failures. Clear the mark; continuous heartbeat failure. The client
> initiates a reconnection. This can reduce an unnecessary timer, and any
> polling method is not elegant.
>
> I've described more details in my blog, about Dubbo's existing heartbeat
> program, its shortcomings, and the advantages of replacing it with a new
> solution, as well as some forward thinking, welcome to discuss.
>
> bolg:https://www.cnkirito.moe/heartbeat-design/ <
> http://www.cnkirito.moe/heartbeat-design/>
>
> ---
>
> Hi 乡亲们:
>
> 我给现有 Dubbo 的心跳方案改进提了两条建议
>
> - 双向心跳的设计是不必要的,兼容现有的逻辑,可以让客户端在连接空闲时发送单向心跳,服务端定时检测连接可用性。定时时间尽量保证:客户端超时时间 *
> 3 ≈ 服务端超时时间
> - 去除处理重连和断连的定时任务,Dubbo
> 可以判断心跳请求是否响应失败,可以借鉴改进方案的设计,在连接级别维护一个心跳失败次数的标记,任意响应成功,清除标记;连续心跳失败 n
> 次,客户端发起重连。这样可以减少一个不必要的定时器,任何轮询的方式,都是不优雅的。
>
> 我的博客中描述了更多的细节,关于 Dubbo 现有的心跳方案,它的不足之处,以及替换成新的方案的优势,以及一些展望思考,欢迎讨论。
>
> 博客地址:https://www.cnkirito.moe/heartbeat-design/

Re: [Proposal] A proposal to use IdleStateHandler to replace using Timer to send HeartBeat.

Posted by 徐靖峰 <ki...@foxmail.com>.
Hi folks,

Here is my suggestion to improve Dubbo’s HeartBeat Design.

- The design of the two-way heartbeat is unnecessary, compatible with the existing logic, allowing the client to send a one-way heartbeat when the connection is idle, and the server periodically detects the connection availability. Timed time to ensure: client timeout * 3 ≈ server timeout
- Remove the timing tasks for reconnection and disconnection. Dubbo can judge whether the heartbeat request fails to respond. You can learn from the design of the improved scheme, maintain a mark of the number of heartbeat failures at the connection level, and successfully respond to any failures. Clear the mark; continuous heartbeat failure. The client initiates a reconnection. This can reduce an unnecessary timer, and any polling method is not elegant.

I've described more details in my blog, about Dubbo's existing heartbeat program, its shortcomings, and the advantages of replacing it with a new solution, as well as some forward thinking, welcome to discuss.

bolg:https://www.cnkirito.moe/heartbeat-design/ <http://www.cnkirito.moe/heartbeat-design/>

---

Hi 乡亲们:

我给现有 Dubbo 的心跳方案改进提了两条建议

- 双向心跳的设计是不必要的,兼容现有的逻辑,可以让客户端在连接空闲时发送单向心跳,服务端定时检测连接可用性。定时时间尽量保证:客户端超时时间 * 3 ≈ 服务端超时时间
- 去除处理重连和断连的定时任务,Dubbo 可以判断心跳请求是否响应失败,可以借鉴改进方案的设计,在连接级别维护一个心跳失败次数的标记,任意响应成功,清除标记;连续心跳失败 n 次,客户端发起重连。这样可以减少一个不必要的定时器,任何轮询的方式,都是不优雅的。

我的博客中描述了更多的细节,关于 Dubbo 现有的心跳方案,它的不足之处,以及替换成新的方案的优势,以及一些展望思考,欢迎讨论。

博客地址:https://www.cnkirito.moe/heartbeat-design/

Re: [Proposal] A proposal to use IdleStateHandler to replace using Timer to send HeartBeat.

Posted by Ian Luo <ia...@gmail.com>.
Folks,

Should we simply close this pull request if it is
inappropriate? @carryxyh, @lexburner


Thanks,
-Ian.


On Sat, Jan 12, 2019 at 8:14 PM 徐靖峰 <ki...@foxmail.com> wrote:

> Hi
> The changes don’t follow my attentions, I will submit my design later.
> Maybe we need describe the problem more detailedly, then the problem has
> solved for a half.
>
> > 在 2019年1月12日,下午7:45,Jun Alpha <al...@gmail.com> 写道:
> >
> > Hello everyone, I have commit a pull request[1] to optimize Dubbo's
> > heartbeat mechanise,
> > witch is mentioned in this email and this issue[2],pls review it.
> >
> > [1] https://github.com/apache/incubator-dubbo/pull/3213
> > [2] https://github.com/apache/incubator-dubbo/issues/3151
> >
> > 徐靖峰 <25...@qq.com> 于2019年1月11日周五 上午7:46写道:
> >
> >> @Jun Alpha great, I am glad to review your changes and wait for your
> pull
> >> request.
> >>
> >>> 在 2019年1月10日,下午8:00,Jun Alpha <al...@gmail.com> 写道:
> >>>
> >>> I'll try it.
> >>>
> >>> Ian Luo <ia...@gmail.com> 于2019年1月10日周四 下午2:21写道:
> >>>
> >>>> It is a good suggestion any way, we should give it a try at least.
> >>>>
> >>>> -Ian.
> >>>>
> >>>> On Thu, Jan 10, 2019 at 10:21 AM yuhang xiu <ca...@gmail.com>
> wrote:
> >>>>
> >>>>> hi, @jun alpha
> >>>>>
> >>>>> I agree.
> >>>>> If netty can do more precise heartbeat control, we can integrate its
> >>>> design
> >>>>> in our heartbeat. Would you like to try it?
> >>>>>
> >>>>> Jun Alpha <al...@gmail.com> 于2019年1月9日周三 下午9:21写道:
> >>>>>
> >>>>>> Hi,I left a comment in this issue[1],I think it's worth to learn
> from
> >>>>>> netty's heartbeat mechanism.
> >>>>>>
> >>>>>> [1]  https://github.com/apache/incubator-dubbo/issues/3151
> >>>>>>
> >>>>>> Ian Luo <ia...@gmail.com> 于2019年1月7日周一 下午10:47写道:
> >>>>>>
> >>>>>>> Thanks
> >>>>>>>
> >>>>>>> On Mon, Jan 7, 2019 at 2:50 PM yuhang xiu <ca...@gmail.com>
> >>>> wrote:
> >>>>>>>
> >>>>>>>> Hi, I left some comments in this issue[1]
> >>>>>>>>
> >>>>>>>> Thanks to beiwei for reminding. I forgot that we have some
> >>>> non-netty
> >>>>>>>> servers. In this case, I personally prefer all heartbeats to use
> >>>> the
> >>>>>> same
> >>>>>>>> set of mechanisms to guarantee. But we can learn from netty's
> >>>>> heartbeat
> >>>>>>>> mechanism to ensure more accurate heartbeat control.
> >>>>>>>>
> >>>>>>>> [1] https://github.com/apache/incubator-dubbo/issues/3151
> >>>>>>>>
> >>>>>>>> Ian Luo <ia...@gmail.com> 于2019年1月7日周一 下午1:09写道:
> >>>>>>>>
> >>>>>>>>> It is an interesting topic. It is worthy to give it a try when
> >>>>> Dubbo
> >>>>>>> uses
> >>>>>>>>> Netty, but pls. keep in mind that Dubbo has the ability to use
> >>>>> other
> >>>>>>>>> servers. I am not sure whether this suggestion will introduce
> >>>>>>> unnecessary
> >>>>>>>>> complexity.
> >>>>>>>>>
> >>>>>>>>> JingFeng, would you mind to file an issue and give it a try if
> >>>> you
> >>>>>> have
> >>>>>>>>> time?
> >>>>>>>>>
> >>>>>>>>> Thanks,
> >>>>>>>>> -Ian.
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> On Mon, Jan 7, 2019 at 11:03 AM 徐靖峰 <25...@qq.com> wrote:
> >>>>>>>>>
> >>>>>>>>>> Hi all
> >>>>>>>>>>
> >>>>>>>>>> 现状:
> >>>>>>>>>>
> >>>>>>>>>> Dubbo
> >>>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>
> >>>>
> >>
> 在应用层面发送心跳包保证连接的可用性,使用了定时器的设计,在客户端和服务端分别设置一个定时器,发送心跳,当发现连接断开时,客户端负责重连,服务端负责
> >>>>>>>>>> close。使用定时器并不是一个好的设计,在忙通信时,心跳是不必要的。建议使用 Netty 的
> >>>>>>>>>> IdleStateHandler,仅仅在检测到空闲连接时发送心跳。
> >>>>>>>>>>
> >>>>>>>>>> 修改建议:
> >>>>>>>>>>
> >>>>>>>>>> 使用 IdleStateHandler 代替 Timer 发送心跳
> >>>>>>>>>> 关闭 ChannelOption.SO_KEEPALIVE,网络层面的 TCP 断连需要在机器级别设置,默认是 2
> >>>>>>>>>> 小时,几乎没有必要存在,却发出了无必要的 TCP 探测包,仅仅依赖于应用层的心跳来给连接保活即可。
> >>>>>>>>>> For now:
> >>>>>>>>>>
> >>>>>>>>>> Dubbo sends a heartbeat packet at the application level to
> >>>> ensure
> >>>>>> the
> >>>>>>>>>> availability of the connection. A timer is set on the client
> >>>> and
> >>>>>> the
> >>>>>>>>> server
> >>>>>>>>>> to send a heartbeat. When the connection is found to be
> >>>>>> disconnected,
> >>>>>>>> the
> >>>>>>>>>> client is responsible for reconnection and the server is
> >>>>>> responsible
> >>>>>>>> for
> >>>>>>>>>> close. Using a timer is not a good design, and the heartbeat is
> >>>>>>>>> unnecessary
> >>>>>>>>>> when communicating busy. It is recommended to use Netty's
> >>>>>>>>> IdleStateHandler
> >>>>>>>>>> to send a heartbeat only when an idle connection is detected.
> >>>>>>>>>>
> >>>>>>>>>> Proposed changes:
> >>>>>>>>>>
> >>>>>>>>>> Send heartbeats using IdleStateHandler instead of Timer
> >>>>>>>>>> Close ChannelOption.SO_KEEPALIVE, TCP disconnection at the
> >>>>> network
> >>>>>>>> level
> >>>>>>>>>> needs to be set at the machine level. The default is 2 hours.
> >>>>> There
> >>>>>>> is
> >>>>>>>>>> almost no need to exist, but an unnecessary TCP probe packet is
> >>>>>>> issued.
> >>>>>>>>> It
> >>>>>>>>>> only depends on the heartbeat of the application layer to keep
> >>>>> the
> >>>>>>>>>> connection alive. Just fine.
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>
> >>>>
> >>
> >>
> >>
> >>
>
>
>
>

Re: [Proposal] A proposal to use IdleStateHandler to replace using Timer to send HeartBeat.

Posted by 徐靖峰 <ki...@foxmail.com>.
Hi
The changes don’t follow my attentions, I will submit my design later. Maybe we need describe the problem more detailedly, then the problem has solved for a half.

> 在 2019年1月12日,下午7:45,Jun Alpha <al...@gmail.com> 写道:
> 
> Hello everyone, I have commit a pull request[1] to optimize Dubbo's
> heartbeat mechanise,
> witch is mentioned in this email and this issue[2],pls review it.
> 
> [1] https://github.com/apache/incubator-dubbo/pull/3213
> [2] https://github.com/apache/incubator-dubbo/issues/3151
> 
> 徐靖峰 <25...@qq.com> 于2019年1月11日周五 上午7:46写道:
> 
>> @Jun Alpha great, I am glad to review your changes and wait for your pull
>> request.
>> 
>>> 在 2019年1月10日,下午8:00,Jun Alpha <al...@gmail.com> 写道:
>>> 
>>> I'll try it.
>>> 
>>> Ian Luo <ia...@gmail.com> 于2019年1月10日周四 下午2:21写道:
>>> 
>>>> It is a good suggestion any way, we should give it a try at least.
>>>> 
>>>> -Ian.
>>>> 
>>>> On Thu, Jan 10, 2019 at 10:21 AM yuhang xiu <ca...@gmail.com> wrote:
>>>> 
>>>>> hi, @jun alpha
>>>>> 
>>>>> I agree.
>>>>> If netty can do more precise heartbeat control, we can integrate its
>>>> design
>>>>> in our heartbeat. Would you like to try it?
>>>>> 
>>>>> Jun Alpha <al...@gmail.com> 于2019年1月9日周三 下午9:21写道:
>>>>> 
>>>>>> Hi,I left a comment in this issue[1],I think it's worth to learn from
>>>>>> netty's heartbeat mechanism.
>>>>>> 
>>>>>> [1]  https://github.com/apache/incubator-dubbo/issues/3151
>>>>>> 
>>>>>> Ian Luo <ia...@gmail.com> 于2019年1月7日周一 下午10:47写道:
>>>>>> 
>>>>>>> Thanks
>>>>>>> 
>>>>>>> On Mon, Jan 7, 2019 at 2:50 PM yuhang xiu <ca...@gmail.com>
>>>> wrote:
>>>>>>> 
>>>>>>>> Hi, I left some comments in this issue[1]
>>>>>>>> 
>>>>>>>> Thanks to beiwei for reminding. I forgot that we have some
>>>> non-netty
>>>>>>>> servers. In this case, I personally prefer all heartbeats to use
>>>> the
>>>>>> same
>>>>>>>> set of mechanisms to guarantee. But we can learn from netty's
>>>>> heartbeat
>>>>>>>> mechanism to ensure more accurate heartbeat control.
>>>>>>>> 
>>>>>>>> [1] https://github.com/apache/incubator-dubbo/issues/3151
>>>>>>>> 
>>>>>>>> Ian Luo <ia...@gmail.com> 于2019年1月7日周一 下午1:09写道:
>>>>>>>> 
>>>>>>>>> It is an interesting topic. It is worthy to give it a try when
>>>>> Dubbo
>>>>>>> uses
>>>>>>>>> Netty, but pls. keep in mind that Dubbo has the ability to use
>>>>> other
>>>>>>>>> servers. I am not sure whether this suggestion will introduce
>>>>>>> unnecessary
>>>>>>>>> complexity.
>>>>>>>>> 
>>>>>>>>> JingFeng, would you mind to file an issue and give it a try if
>>>> you
>>>>>> have
>>>>>>>>> time?
>>>>>>>>> 
>>>>>>>>> Thanks,
>>>>>>>>> -Ian.
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> On Mon, Jan 7, 2019 at 11:03 AM 徐靖峰 <25...@qq.com> wrote:
>>>>>>>>> 
>>>>>>>>>> Hi all
>>>>>>>>>> 
>>>>>>>>>> 现状:
>>>>>>>>>> 
>>>>>>>>>> Dubbo
>>>>>>>>>> 
>>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>> 在应用层面发送心跳包保证连接的可用性,使用了定时器的设计,在客户端和服务端分别设置一个定时器,发送心跳,当发现连接断开时,客户端负责重连,服务端负责
>>>>>>>>>> close。使用定时器并不是一个好的设计,在忙通信时,心跳是不必要的。建议使用 Netty 的
>>>>>>>>>> IdleStateHandler,仅仅在检测到空闲连接时发送心跳。
>>>>>>>>>> 
>>>>>>>>>> 修改建议:
>>>>>>>>>> 
>>>>>>>>>> 使用 IdleStateHandler 代替 Timer 发送心跳
>>>>>>>>>> 关闭 ChannelOption.SO_KEEPALIVE,网络层面的 TCP 断连需要在机器级别设置,默认是 2
>>>>>>>>>> 小时,几乎没有必要存在,却发出了无必要的 TCP 探测包,仅仅依赖于应用层的心跳来给连接保活即可。
>>>>>>>>>> For now:
>>>>>>>>>> 
>>>>>>>>>> Dubbo sends a heartbeat packet at the application level to
>>>> ensure
>>>>>> the
>>>>>>>>>> availability of the connection. A timer is set on the client
>>>> and
>>>>>> the
>>>>>>>>> server
>>>>>>>>>> to send a heartbeat. When the connection is found to be
>>>>>> disconnected,
>>>>>>>> the
>>>>>>>>>> client is responsible for reconnection and the server is
>>>>>> responsible
>>>>>>>> for
>>>>>>>>>> close. Using a timer is not a good design, and the heartbeat is
>>>>>>>>> unnecessary
>>>>>>>>>> when communicating busy. It is recommended to use Netty's
>>>>>>>>> IdleStateHandler
>>>>>>>>>> to send a heartbeat only when an idle connection is detected.
>>>>>>>>>> 
>>>>>>>>>> Proposed changes:
>>>>>>>>>> 
>>>>>>>>>> Send heartbeats using IdleStateHandler instead of Timer
>>>>>>>>>> Close ChannelOption.SO_KEEPALIVE, TCP disconnection at the
>>>>> network
>>>>>>>> level
>>>>>>>>>> needs to be set at the machine level. The default is 2 hours.
>>>>> There
>>>>>>> is
>>>>>>>>>> almost no need to exist, but an unnecessary TCP probe packet is
>>>>>>> issued.
>>>>>>>>> It
>>>>>>>>>> only depends on the heartbeat of the application layer to keep
>>>>> the
>>>>>>>>>> connection alive. Just fine.
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>> 
>> 
>> 
>> 




Re: [Proposal] A proposal to use IdleStateHandler to replace using Timer to send HeartBeat.

Posted by Jun Alpha <al...@gmail.com>.
Hello everyone, I have commit a pull request[1] to optimize Dubbo's
heartbeat mechanise,
witch is mentioned in this email and this issue[2],pls review it.

[1] https://github.com/apache/incubator-dubbo/pull/3213
[2] https://github.com/apache/incubator-dubbo/issues/3151

徐靖峰 <25...@qq.com> 于2019年1月11日周五 上午7:46写道:

> @Jun Alpha great, I am glad to review your changes and wait for your pull
> request.
>
> > 在 2019年1月10日,下午8:00,Jun Alpha <al...@gmail.com> 写道:
> >
> > I'll try it.
> >
> > Ian Luo <ia...@gmail.com> 于2019年1月10日周四 下午2:21写道:
> >
> >> It is a good suggestion any way, we should give it a try at least.
> >>
> >> -Ian.
> >>
> >> On Thu, Jan 10, 2019 at 10:21 AM yuhang xiu <ca...@gmail.com> wrote:
> >>
> >>> hi, @jun alpha
> >>>
> >>> I agree.
> >>> If netty can do more precise heartbeat control, we can integrate its
> >> design
> >>> in our heartbeat. Would you like to try it?
> >>>
> >>> Jun Alpha <al...@gmail.com> 于2019年1月9日周三 下午9:21写道:
> >>>
> >>>> Hi,I left a comment in this issue[1],I think it's worth to learn from
> >>>> netty's heartbeat mechanism.
> >>>>
> >>>> [1]  https://github.com/apache/incubator-dubbo/issues/3151
> >>>>
> >>>> Ian Luo <ia...@gmail.com> 于2019年1月7日周一 下午10:47写道:
> >>>>
> >>>>> Thanks
> >>>>>
> >>>>> On Mon, Jan 7, 2019 at 2:50 PM yuhang xiu <ca...@gmail.com>
> >> wrote:
> >>>>>
> >>>>>> Hi, I left some comments in this issue[1]
> >>>>>>
> >>>>>> Thanks to beiwei for reminding. I forgot that we have some
> >> non-netty
> >>>>>> servers. In this case, I personally prefer all heartbeats to use
> >> the
> >>>> same
> >>>>>> set of mechanisms to guarantee. But we can learn from netty's
> >>> heartbeat
> >>>>>> mechanism to ensure more accurate heartbeat control.
> >>>>>>
> >>>>>> [1] https://github.com/apache/incubator-dubbo/issues/3151
> >>>>>>
> >>>>>> Ian Luo <ia...@gmail.com> 于2019年1月7日周一 下午1:09写道:
> >>>>>>
> >>>>>>> It is an interesting topic. It is worthy to give it a try when
> >>> Dubbo
> >>>>> uses
> >>>>>>> Netty, but pls. keep in mind that Dubbo has the ability to use
> >>> other
> >>>>>>> servers. I am not sure whether this suggestion will introduce
> >>>>> unnecessary
> >>>>>>> complexity.
> >>>>>>>
> >>>>>>> JingFeng, would you mind to file an issue and give it a try if
> >> you
> >>>> have
> >>>>>>> time?
> >>>>>>>
> >>>>>>> Thanks,
> >>>>>>> -Ian.
> >>>>>>>
> >>>>>>>
> >>>>>>> On Mon, Jan 7, 2019 at 11:03 AM 徐靖峰 <25...@qq.com> wrote:
> >>>>>>>
> >>>>>>>> Hi all
> >>>>>>>>
> >>>>>>>> 现状:
> >>>>>>>>
> >>>>>>>> Dubbo
> >>>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>
> >>>>
> >>>
> >>
> 在应用层面发送心跳包保证连接的可用性,使用了定时器的设计,在客户端和服务端分别设置一个定时器,发送心跳,当发现连接断开时,客户端负责重连,服务端负责
> >>>>>>>> close。使用定时器并不是一个好的设计,在忙通信时,心跳是不必要的。建议使用 Netty 的
> >>>>>>>> IdleStateHandler,仅仅在检测到空闲连接时发送心跳。
> >>>>>>>>
> >>>>>>>> 修改建议:
> >>>>>>>>
> >>>>>>>> 使用 IdleStateHandler 代替 Timer 发送心跳
> >>>>>>>> 关闭 ChannelOption.SO_KEEPALIVE,网络层面的 TCP 断连需要在机器级别设置,默认是 2
> >>>>>>>> 小时,几乎没有必要存在,却发出了无必要的 TCP 探测包,仅仅依赖于应用层的心跳来给连接保活即可。
> >>>>>>>> For now:
> >>>>>>>>
> >>>>>>>> Dubbo sends a heartbeat packet at the application level to
> >> ensure
> >>>> the
> >>>>>>>> availability of the connection. A timer is set on the client
> >> and
> >>>> the
> >>>>>>> server
> >>>>>>>> to send a heartbeat. When the connection is found to be
> >>>> disconnected,
> >>>>>> the
> >>>>>>>> client is responsible for reconnection and the server is
> >>>> responsible
> >>>>>> for
> >>>>>>>> close. Using a timer is not a good design, and the heartbeat is
> >>>>>>> unnecessary
> >>>>>>>> when communicating busy. It is recommended to use Netty's
> >>>>>>> IdleStateHandler
> >>>>>>>> to send a heartbeat only when an idle connection is detected.
> >>>>>>>>
> >>>>>>>> Proposed changes:
> >>>>>>>>
> >>>>>>>> Send heartbeats using IdleStateHandler instead of Timer
> >>>>>>>> Close ChannelOption.SO_KEEPALIVE, TCP disconnection at the
> >>> network
> >>>>>> level
> >>>>>>>> needs to be set at the machine level. The default is 2 hours.
> >>> There
> >>>>> is
> >>>>>>>> almost no need to exist, but an unnecessary TCP probe packet is
> >>>>> issued.
> >>>>>>> It
> >>>>>>>> only depends on the heartbeat of the application layer to keep
> >>> the
> >>>>>>>> connection alive. Just fine.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>
> >>>>
> >>>
> >>
>
>
>
>

Re: [Proposal] A proposal to use IdleStateHandler to replace using Timer to send HeartBeat.

Posted by 徐靖峰 <25...@qq.com>.
@Jun Alpha great, I am glad to review your changes and wait for your pull request. 

> 在 2019年1月10日,下午8:00,Jun Alpha <al...@gmail.com> 写道:
> 
> I'll try it.
> 
> Ian Luo <ia...@gmail.com> 于2019年1月10日周四 下午2:21写道:
> 
>> It is a good suggestion any way, we should give it a try at least.
>> 
>> -Ian.
>> 
>> On Thu, Jan 10, 2019 at 10:21 AM yuhang xiu <ca...@gmail.com> wrote:
>> 
>>> hi, @jun alpha
>>> 
>>> I agree.
>>> If netty can do more precise heartbeat control, we can integrate its
>> design
>>> in our heartbeat. Would you like to try it?
>>> 
>>> Jun Alpha <al...@gmail.com> 于2019年1月9日周三 下午9:21写道:
>>> 
>>>> Hi,I left a comment in this issue[1],I think it's worth to learn from
>>>> netty's heartbeat mechanism.
>>>> 
>>>> [1]  https://github.com/apache/incubator-dubbo/issues/3151
>>>> 
>>>> Ian Luo <ia...@gmail.com> 于2019年1月7日周一 下午10:47写道:
>>>> 
>>>>> Thanks
>>>>> 
>>>>> On Mon, Jan 7, 2019 at 2:50 PM yuhang xiu <ca...@gmail.com>
>> wrote:
>>>>> 
>>>>>> Hi, I left some comments in this issue[1]
>>>>>> 
>>>>>> Thanks to beiwei for reminding. I forgot that we have some
>> non-netty
>>>>>> servers. In this case, I personally prefer all heartbeats to use
>> the
>>>> same
>>>>>> set of mechanisms to guarantee. But we can learn from netty's
>>> heartbeat
>>>>>> mechanism to ensure more accurate heartbeat control.
>>>>>> 
>>>>>> [1] https://github.com/apache/incubator-dubbo/issues/3151
>>>>>> 
>>>>>> Ian Luo <ia...@gmail.com> 于2019年1月7日周一 下午1:09写道:
>>>>>> 
>>>>>>> It is an interesting topic. It is worthy to give it a try when
>>> Dubbo
>>>>> uses
>>>>>>> Netty, but pls. keep in mind that Dubbo has the ability to use
>>> other
>>>>>>> servers. I am not sure whether this suggestion will introduce
>>>>> unnecessary
>>>>>>> complexity.
>>>>>>> 
>>>>>>> JingFeng, would you mind to file an issue and give it a try if
>> you
>>>> have
>>>>>>> time?
>>>>>>> 
>>>>>>> Thanks,
>>>>>>> -Ian.
>>>>>>> 
>>>>>>> 
>>>>>>> On Mon, Jan 7, 2019 at 11:03 AM 徐靖峰 <25...@qq.com> wrote:
>>>>>>> 
>>>>>>>> Hi all
>>>>>>>> 
>>>>>>>> 现状:
>>>>>>>> 
>>>>>>>> Dubbo
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 在应用层面发送心跳包保证连接的可用性,使用了定时器的设计,在客户端和服务端分别设置一个定时器,发送心跳,当发现连接断开时,客户端负责重连,服务端负责
>>>>>>>> close。使用定时器并不是一个好的设计,在忙通信时,心跳是不必要的。建议使用 Netty 的
>>>>>>>> IdleStateHandler,仅仅在检测到空闲连接时发送心跳。
>>>>>>>> 
>>>>>>>> 修改建议:
>>>>>>>> 
>>>>>>>> 使用 IdleStateHandler 代替 Timer 发送心跳
>>>>>>>> 关闭 ChannelOption.SO_KEEPALIVE,网络层面的 TCP 断连需要在机器级别设置,默认是 2
>>>>>>>> 小时,几乎没有必要存在,却发出了无必要的 TCP 探测包,仅仅依赖于应用层的心跳来给连接保活即可。
>>>>>>>> For now:
>>>>>>>> 
>>>>>>>> Dubbo sends a heartbeat packet at the application level to
>> ensure
>>>> the
>>>>>>>> availability of the connection. A timer is set on the client
>> and
>>>> the
>>>>>>> server
>>>>>>>> to send a heartbeat. When the connection is found to be
>>>> disconnected,
>>>>>> the
>>>>>>>> client is responsible for reconnection and the server is
>>>> responsible
>>>>>> for
>>>>>>>> close. Using a timer is not a good design, and the heartbeat is
>>>>>>> unnecessary
>>>>>>>> when communicating busy. It is recommended to use Netty's
>>>>>>> IdleStateHandler
>>>>>>>> to send a heartbeat only when an idle connection is detected.
>>>>>>>> 
>>>>>>>> Proposed changes:
>>>>>>>> 
>>>>>>>> Send heartbeats using IdleStateHandler instead of Timer
>>>>>>>> Close ChannelOption.SO_KEEPALIVE, TCP disconnection at the
>>> network
>>>>>> level
>>>>>>>> needs to be set at the machine level. The default is 2 hours.
>>> There
>>>>> is
>>>>>>>> almost no need to exist, but an unnecessary TCP probe packet is
>>>>> issued.
>>>>>>> It
>>>>>>>> only depends on the heartbeat of the application layer to keep
>>> the
>>>>>>>> connection alive. Just fine.
>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 




Re: [Proposal] A proposal to use IdleStateHandler to replace using Timer to send HeartBeat.

Posted by Jun Alpha <al...@gmail.com>.
I'll try it.

Ian Luo <ia...@gmail.com> 于2019年1月10日周四 下午2:21写道:

> It is a good suggestion any way, we should give it a try at least.
>
> -Ian.
>
> On Thu, Jan 10, 2019 at 10:21 AM yuhang xiu <ca...@gmail.com> wrote:
>
> > hi, @jun alpha
> >
> > I agree.
> > If netty can do more precise heartbeat control, we can integrate its
> design
> > in our heartbeat. Would you like to try it?
> >
> > Jun Alpha <al...@gmail.com> 于2019年1月9日周三 下午9:21写道:
> >
> > > Hi,I left a comment in this issue[1],I think it's worth to learn from
> > > netty's heartbeat mechanism.
> > >
> > > [1]  https://github.com/apache/incubator-dubbo/issues/3151
> > >
> > > Ian Luo <ia...@gmail.com> 于2019年1月7日周一 下午10:47写道:
> > >
> > > > Thanks
> > > >
> > > > On Mon, Jan 7, 2019 at 2:50 PM yuhang xiu <ca...@gmail.com>
> wrote:
> > > >
> > > > > Hi, I left some comments in this issue[1]
> > > > >
> > > > > Thanks to beiwei for reminding. I forgot that we have some
> non-netty
> > > > > servers. In this case, I personally prefer all heartbeats to use
> the
> > > same
> > > > > set of mechanisms to guarantee. But we can learn from netty's
> > heartbeat
> > > > > mechanism to ensure more accurate heartbeat control.
> > > > >
> > > > > [1] https://github.com/apache/incubator-dubbo/issues/3151
> > > > >
> > > > > Ian Luo <ia...@gmail.com> 于2019年1月7日周一 下午1:09写道:
> > > > >
> > > > > > It is an interesting topic. It is worthy to give it a try when
> > Dubbo
> > > > uses
> > > > > > Netty, but pls. keep in mind that Dubbo has the ability to use
> > other
> > > > > > servers. I am not sure whether this suggestion will introduce
> > > > unnecessary
> > > > > > complexity.
> > > > > >
> > > > > > JingFeng, would you mind to file an issue and give it a try if
> you
> > > have
> > > > > > time?
> > > > > >
> > > > > > Thanks,
> > > > > > -Ian.
> > > > > >
> > > > > >
> > > > > > On Mon, Jan 7, 2019 at 11:03 AM 徐靖峰 <25...@qq.com> wrote:
> > > > > >
> > > > > > > Hi all
> > > > > > >
> > > > > > > 现状:
> > > > > > >
> > > > > > > Dubbo
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> 在应用层面发送心跳包保证连接的可用性,使用了定时器的设计,在客户端和服务端分别设置一个定时器,发送心跳,当发现连接断开时,客户端负责重连,服务端负责
> > > > > > > close。使用定时器并不是一个好的设计,在忙通信时,心跳是不必要的。建议使用 Netty 的
> > > > > > > IdleStateHandler,仅仅在检测到空闲连接时发送心跳。
> > > > > > >
> > > > > > > 修改建议:
> > > > > > >
> > > > > > > 使用 IdleStateHandler 代替 Timer 发送心跳
> > > > > > > 关闭 ChannelOption.SO_KEEPALIVE,网络层面的 TCP 断连需要在机器级别设置,默认是 2
> > > > > > > 小时,几乎没有必要存在,却发出了无必要的 TCP 探测包,仅仅依赖于应用层的心跳来给连接保活即可。
> > > > > > > For now:
> > > > > > >
> > > > > > > Dubbo sends a heartbeat packet at the application level to
> ensure
> > > the
> > > > > > > availability of the connection. A timer is set on the client
> and
> > > the
> > > > > > server
> > > > > > > to send a heartbeat. When the connection is found to be
> > > disconnected,
> > > > > the
> > > > > > > client is responsible for reconnection and the server is
> > > responsible
> > > > > for
> > > > > > > close. Using a timer is not a good design, and the heartbeat is
> > > > > > unnecessary
> > > > > > > when communicating busy. It is recommended to use Netty's
> > > > > > IdleStateHandler
> > > > > > > to send a heartbeat only when an idle connection is detected.
> > > > > > >
> > > > > > > Proposed changes:
> > > > > > >
> > > > > > > Send heartbeats using IdleStateHandler instead of Timer
> > > > > > > Close ChannelOption.SO_KEEPALIVE, TCP disconnection at the
> > network
> > > > > level
> > > > > > > needs to be set at the machine level. The default is 2 hours.
> > There
> > > > is
> > > > > > > almost no need to exist, but an unnecessary TCP probe packet is
> > > > issued.
> > > > > > It
> > > > > > > only depends on the heartbeat of the application layer to keep
> > the
> > > > > > > connection alive. Just fine.
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: [Proposal] A proposal to use IdleStateHandler to replace using Timer to send HeartBeat.

Posted by Ian Luo <ia...@gmail.com>.
It is a good suggestion any way, we should give it a try at least.

-Ian.

On Thu, Jan 10, 2019 at 10:21 AM yuhang xiu <ca...@gmail.com> wrote:

> hi, @jun alpha
>
> I agree.
> If netty can do more precise heartbeat control, we can integrate its design
> in our heartbeat. Would you like to try it?
>
> Jun Alpha <al...@gmail.com> 于2019年1月9日周三 下午9:21写道:
>
> > Hi,I left a comment in this issue[1],I think it's worth to learn from
> > netty's heartbeat mechanism.
> >
> > [1]  https://github.com/apache/incubator-dubbo/issues/3151
> >
> > Ian Luo <ia...@gmail.com> 于2019年1月7日周一 下午10:47写道:
> >
> > > Thanks
> > >
> > > On Mon, Jan 7, 2019 at 2:50 PM yuhang xiu <ca...@gmail.com> wrote:
> > >
> > > > Hi, I left some comments in this issue[1]
> > > >
> > > > Thanks to beiwei for reminding. I forgot that we have some non-netty
> > > > servers. In this case, I personally prefer all heartbeats to use the
> > same
> > > > set of mechanisms to guarantee. But we can learn from netty's
> heartbeat
> > > > mechanism to ensure more accurate heartbeat control.
> > > >
> > > > [1] https://github.com/apache/incubator-dubbo/issues/3151
> > > >
> > > > Ian Luo <ia...@gmail.com> 于2019年1月7日周一 下午1:09写道:
> > > >
> > > > > It is an interesting topic. It is worthy to give it a try when
> Dubbo
> > > uses
> > > > > Netty, but pls. keep in mind that Dubbo has the ability to use
> other
> > > > > servers. I am not sure whether this suggestion will introduce
> > > unnecessary
> > > > > complexity.
> > > > >
> > > > > JingFeng, would you mind to file an issue and give it a try if you
> > have
> > > > > time?
> > > > >
> > > > > Thanks,
> > > > > -Ian.
> > > > >
> > > > >
> > > > > On Mon, Jan 7, 2019 at 11:03 AM 徐靖峰 <25...@qq.com> wrote:
> > > > >
> > > > > > Hi all
> > > > > >
> > > > > > 现状:
> > > > > >
> > > > > > Dubbo
> > > > > >
> > > > >
> > > >
> > >
> >
> 在应用层面发送心跳包保证连接的可用性,使用了定时器的设计,在客户端和服务端分别设置一个定时器,发送心跳,当发现连接断开时,客户端负责重连,服务端负责
> > > > > > close。使用定时器并不是一个好的设计,在忙通信时,心跳是不必要的。建议使用 Netty 的
> > > > > > IdleStateHandler,仅仅在检测到空闲连接时发送心跳。
> > > > > >
> > > > > > 修改建议:
> > > > > >
> > > > > > 使用 IdleStateHandler 代替 Timer 发送心跳
> > > > > > 关闭 ChannelOption.SO_KEEPALIVE,网络层面的 TCP 断连需要在机器级别设置,默认是 2
> > > > > > 小时,几乎没有必要存在,却发出了无必要的 TCP 探测包,仅仅依赖于应用层的心跳来给连接保活即可。
> > > > > > For now:
> > > > > >
> > > > > > Dubbo sends a heartbeat packet at the application level to ensure
> > the
> > > > > > availability of the connection. A timer is set on the client and
> > the
> > > > > server
> > > > > > to send a heartbeat. When the connection is found to be
> > disconnected,
> > > > the
> > > > > > client is responsible for reconnection and the server is
> > responsible
> > > > for
> > > > > > close. Using a timer is not a good design, and the heartbeat is
> > > > > unnecessary
> > > > > > when communicating busy. It is recommended to use Netty's
> > > > > IdleStateHandler
> > > > > > to send a heartbeat only when an idle connection is detected.
> > > > > >
> > > > > > Proposed changes:
> > > > > >
> > > > > > Send heartbeats using IdleStateHandler instead of Timer
> > > > > > Close ChannelOption.SO_KEEPALIVE, TCP disconnection at the
> network
> > > > level
> > > > > > needs to be set at the machine level. The default is 2 hours.
> There
> > > is
> > > > > > almost no need to exist, but an unnecessary TCP probe packet is
> > > issued.
> > > > > It
> > > > > > only depends on the heartbeat of the application layer to keep
> the
> > > > > > connection alive. Just fine.
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: [Proposal] A proposal to use IdleStateHandler to replace using Timer to send HeartBeat.

Posted by yuhang xiu <ca...@gmail.com>.
hi, @jun alpha

I agree.
If netty can do more precise heartbeat control, we can integrate its design
in our heartbeat. Would you like to try it?

Jun Alpha <al...@gmail.com> 于2019年1月9日周三 下午9:21写道:

> Hi,I left a comment in this issue[1],I think it's worth to learn from
> netty's heartbeat mechanism.
>
> [1]  https://github.com/apache/incubator-dubbo/issues/3151
>
> Ian Luo <ia...@gmail.com> 于2019年1月7日周一 下午10:47写道:
>
> > Thanks
> >
> > On Mon, Jan 7, 2019 at 2:50 PM yuhang xiu <ca...@gmail.com> wrote:
> >
> > > Hi, I left some comments in this issue[1]
> > >
> > > Thanks to beiwei for reminding. I forgot that we have some non-netty
> > > servers. In this case, I personally prefer all heartbeats to use the
> same
> > > set of mechanisms to guarantee. But we can learn from netty's heartbeat
> > > mechanism to ensure more accurate heartbeat control.
> > >
> > > [1] https://github.com/apache/incubator-dubbo/issues/3151
> > >
> > > Ian Luo <ia...@gmail.com> 于2019年1月7日周一 下午1:09写道:
> > >
> > > > It is an interesting topic. It is worthy to give it a try when Dubbo
> > uses
> > > > Netty, but pls. keep in mind that Dubbo has the ability to use other
> > > > servers. I am not sure whether this suggestion will introduce
> > unnecessary
> > > > complexity.
> > > >
> > > > JingFeng, would you mind to file an issue and give it a try if you
> have
> > > > time?
> > > >
> > > > Thanks,
> > > > -Ian.
> > > >
> > > >
> > > > On Mon, Jan 7, 2019 at 11:03 AM 徐靖峰 <25...@qq.com> wrote:
> > > >
> > > > > Hi all
> > > > >
> > > > > 现状:
> > > > >
> > > > > Dubbo
> > > > >
> > > >
> > >
> >
> 在应用层面发送心跳包保证连接的可用性,使用了定时器的设计,在客户端和服务端分别设置一个定时器,发送心跳,当发现连接断开时,客户端负责重连,服务端负责
> > > > > close。使用定时器并不是一个好的设计,在忙通信时,心跳是不必要的。建议使用 Netty 的
> > > > > IdleStateHandler,仅仅在检测到空闲连接时发送心跳。
> > > > >
> > > > > 修改建议:
> > > > >
> > > > > 使用 IdleStateHandler 代替 Timer 发送心跳
> > > > > 关闭 ChannelOption.SO_KEEPALIVE,网络层面的 TCP 断连需要在机器级别设置,默认是 2
> > > > > 小时,几乎没有必要存在,却发出了无必要的 TCP 探测包,仅仅依赖于应用层的心跳来给连接保活即可。
> > > > > For now:
> > > > >
> > > > > Dubbo sends a heartbeat packet at the application level to ensure
> the
> > > > > availability of the connection. A timer is set on the client and
> the
> > > > server
> > > > > to send a heartbeat. When the connection is found to be
> disconnected,
> > > the
> > > > > client is responsible for reconnection and the server is
> responsible
> > > for
> > > > > close. Using a timer is not a good design, and the heartbeat is
> > > > unnecessary
> > > > > when communicating busy. It is recommended to use Netty's
> > > > IdleStateHandler
> > > > > to send a heartbeat only when an idle connection is detected.
> > > > >
> > > > > Proposed changes:
> > > > >
> > > > > Send heartbeats using IdleStateHandler instead of Timer
> > > > > Close ChannelOption.SO_KEEPALIVE, TCP disconnection at the network
> > > level
> > > > > needs to be set at the machine level. The default is 2 hours. There
> > is
> > > > > almost no need to exist, but an unnecessary TCP probe packet is
> > issued.
> > > > It
> > > > > only depends on the heartbeat of the application layer to keep the
> > > > > connection alive. Just fine.
> > > > >
> > > > >
> > > >
> > >
> >
>

Re: [Proposal] A proposal to use IdleStateHandler to replace using Timer to send HeartBeat.

Posted by Jun Alpha <al...@gmail.com>.
Hi,I left a comment in this issue[1],I think it's worth to learn from
netty's heartbeat mechanism.

[1]  https://github.com/apache/incubator-dubbo/issues/3151

Ian Luo <ia...@gmail.com> 于2019年1月7日周一 下午10:47写道:

> Thanks
>
> On Mon, Jan 7, 2019 at 2:50 PM yuhang xiu <ca...@gmail.com> wrote:
>
> > Hi, I left some comments in this issue[1]
> >
> > Thanks to beiwei for reminding. I forgot that we have some non-netty
> > servers. In this case, I personally prefer all heartbeats to use the same
> > set of mechanisms to guarantee. But we can learn from netty's heartbeat
> > mechanism to ensure more accurate heartbeat control.
> >
> > [1] https://github.com/apache/incubator-dubbo/issues/3151
> >
> > Ian Luo <ia...@gmail.com> 于2019年1月7日周一 下午1:09写道:
> >
> > > It is an interesting topic. It is worthy to give it a try when Dubbo
> uses
> > > Netty, but pls. keep in mind that Dubbo has the ability to use other
> > > servers. I am not sure whether this suggestion will introduce
> unnecessary
> > > complexity.
> > >
> > > JingFeng, would you mind to file an issue and give it a try if you have
> > > time?
> > >
> > > Thanks,
> > > -Ian.
> > >
> > >
> > > On Mon, Jan 7, 2019 at 11:03 AM 徐靖峰 <25...@qq.com> wrote:
> > >
> > > > Hi all
> > > >
> > > > 现状:
> > > >
> > > > Dubbo
> > > >
> > >
> >
> 在应用层面发送心跳包保证连接的可用性,使用了定时器的设计,在客户端和服务端分别设置一个定时器,发送心跳,当发现连接断开时,客户端负责重连,服务端负责
> > > > close。使用定时器并不是一个好的设计,在忙通信时,心跳是不必要的。建议使用 Netty 的
> > > > IdleStateHandler,仅仅在检测到空闲连接时发送心跳。
> > > >
> > > > 修改建议:
> > > >
> > > > 使用 IdleStateHandler 代替 Timer 发送心跳
> > > > 关闭 ChannelOption.SO_KEEPALIVE,网络层面的 TCP 断连需要在机器级别设置,默认是 2
> > > > 小时,几乎没有必要存在,却发出了无必要的 TCP 探测包,仅仅依赖于应用层的心跳来给连接保活即可。
> > > > For now:
> > > >
> > > > Dubbo sends a heartbeat packet at the application level to ensure the
> > > > availability of the connection. A timer is set on the client and the
> > > server
> > > > to send a heartbeat. When the connection is found to be disconnected,
> > the
> > > > client is responsible for reconnection and the server is responsible
> > for
> > > > close. Using a timer is not a good design, and the heartbeat is
> > > unnecessary
> > > > when communicating busy. It is recommended to use Netty's
> > > IdleStateHandler
> > > > to send a heartbeat only when an idle connection is detected.
> > > >
> > > > Proposed changes:
> > > >
> > > > Send heartbeats using IdleStateHandler instead of Timer
> > > > Close ChannelOption.SO_KEEPALIVE, TCP disconnection at the network
> > level
> > > > needs to be set at the machine level. The default is 2 hours. There
> is
> > > > almost no need to exist, but an unnecessary TCP probe packet is
> issued.
> > > It
> > > > only depends on the heartbeat of the application layer to keep the
> > > > connection alive. Just fine.
> > > >
> > > >
> > >
> >
>

Re: [Proposal] A proposal to use IdleStateHandler to replace using Timer to send HeartBeat.

Posted by Ian Luo <ia...@gmail.com>.
Thanks

On Mon, Jan 7, 2019 at 2:50 PM yuhang xiu <ca...@gmail.com> wrote:

> Hi, I left some comments in this issue[1]
>
> Thanks to beiwei for reminding. I forgot that we have some non-netty
> servers. In this case, I personally prefer all heartbeats to use the same
> set of mechanisms to guarantee. But we can learn from netty's heartbeat
> mechanism to ensure more accurate heartbeat control.
>
> [1] https://github.com/apache/incubator-dubbo/issues/3151
>
> Ian Luo <ia...@gmail.com> 于2019年1月7日周一 下午1:09写道:
>
> > It is an interesting topic. It is worthy to give it a try when Dubbo uses
> > Netty, but pls. keep in mind that Dubbo has the ability to use other
> > servers. I am not sure whether this suggestion will introduce unnecessary
> > complexity.
> >
> > JingFeng, would you mind to file an issue and give it a try if you have
> > time?
> >
> > Thanks,
> > -Ian.
> >
> >
> > On Mon, Jan 7, 2019 at 11:03 AM 徐靖峰 <25...@qq.com> wrote:
> >
> > > Hi all
> > >
> > > 现状:
> > >
> > > Dubbo
> > >
> >
> 在应用层面发送心跳包保证连接的可用性,使用了定时器的设计,在客户端和服务端分别设置一个定时器,发送心跳,当发现连接断开时,客户端负责重连,服务端负责
> > > close。使用定时器并不是一个好的设计,在忙通信时,心跳是不必要的。建议使用 Netty 的
> > > IdleStateHandler,仅仅在检测到空闲连接时发送心跳。
> > >
> > > 修改建议:
> > >
> > > 使用 IdleStateHandler 代替 Timer 发送心跳
> > > 关闭 ChannelOption.SO_KEEPALIVE,网络层面的 TCP 断连需要在机器级别设置,默认是 2
> > > 小时,几乎没有必要存在,却发出了无必要的 TCP 探测包,仅仅依赖于应用层的心跳来给连接保活即可。
> > > For now:
> > >
> > > Dubbo sends a heartbeat packet at the application level to ensure the
> > > availability of the connection. A timer is set on the client and the
> > server
> > > to send a heartbeat. When the connection is found to be disconnected,
> the
> > > client is responsible for reconnection and the server is responsible
> for
> > > close. Using a timer is not a good design, and the heartbeat is
> > unnecessary
> > > when communicating busy. It is recommended to use Netty's
> > IdleStateHandler
> > > to send a heartbeat only when an idle connection is detected.
> > >
> > > Proposed changes:
> > >
> > > Send heartbeats using IdleStateHandler instead of Timer
> > > Close ChannelOption.SO_KEEPALIVE, TCP disconnection at the network
> level
> > > needs to be set at the machine level. The default is 2 hours. There is
> > > almost no need to exist, but an unnecessary TCP probe packet is issued.
> > It
> > > only depends on the heartbeat of the application layer to keep the
> > > connection alive. Just fine.
> > >
> > >
> >
>

Re: [Proposal] A proposal to use IdleStateHandler to replace using Timer to send HeartBeat.

Posted by yuhang xiu <ca...@gmail.com>.
Hi, I left some comments in this issue[1]

Thanks to beiwei for reminding. I forgot that we have some non-netty
servers. In this case, I personally prefer all heartbeats to use the same
set of mechanisms to guarantee. But we can learn from netty's heartbeat
mechanism to ensure more accurate heartbeat control.

[1] https://github.com/apache/incubator-dubbo/issues/3151

Ian Luo <ia...@gmail.com> 于2019年1月7日周一 下午1:09写道:

> It is an interesting topic. It is worthy to give it a try when Dubbo uses
> Netty, but pls. keep in mind that Dubbo has the ability to use other
> servers. I am not sure whether this suggestion will introduce unnecessary
> complexity.
>
> JingFeng, would you mind to file an issue and give it a try if you have
> time?
>
> Thanks,
> -Ian.
>
>
> On Mon, Jan 7, 2019 at 11:03 AM 徐靖峰 <25...@qq.com> wrote:
>
> > Hi all
> >
> > 现状:
> >
> > Dubbo
> >
> 在应用层面发送心跳包保证连接的可用性,使用了定时器的设计,在客户端和服务端分别设置一个定时器,发送心跳,当发现连接断开时,客户端负责重连,服务端负责
> > close。使用定时器并不是一个好的设计,在忙通信时,心跳是不必要的。建议使用 Netty 的
> > IdleStateHandler,仅仅在检测到空闲连接时发送心跳。
> >
> > 修改建议:
> >
> > 使用 IdleStateHandler 代替 Timer 发送心跳
> > 关闭 ChannelOption.SO_KEEPALIVE,网络层面的 TCP 断连需要在机器级别设置,默认是 2
> > 小时,几乎没有必要存在,却发出了无必要的 TCP 探测包,仅仅依赖于应用层的心跳来给连接保活即可。
> > For now:
> >
> > Dubbo sends a heartbeat packet at the application level to ensure the
> > availability of the connection. A timer is set on the client and the
> server
> > to send a heartbeat. When the connection is found to be disconnected, the
> > client is responsible for reconnection and the server is responsible for
> > close. Using a timer is not a good design, and the heartbeat is
> unnecessary
> > when communicating busy. It is recommended to use Netty's
> IdleStateHandler
> > to send a heartbeat only when an idle connection is detected.
> >
> > Proposed changes:
> >
> > Send heartbeats using IdleStateHandler instead of Timer
> > Close ChannelOption.SO_KEEPALIVE, TCP disconnection at the network level
> > needs to be set at the machine level. The default is 2 hours. There is
> > almost no need to exist, but an unnecessary TCP probe packet is issued.
> It
> > only depends on the heartbeat of the application layer to keep the
> > connection alive. Just fine.
> >
> >
>

Re: [Proposal] A proposal to use IdleStateHandler to replace using Timer to send HeartBeat.

Posted by Ian Luo <ia...@gmail.com>.
It is an interesting topic. It is worthy to give it a try when Dubbo uses
Netty, but pls. keep in mind that Dubbo has the ability to use other
servers. I am not sure whether this suggestion will introduce unnecessary
complexity.

JingFeng, would you mind to file an issue and give it a try if you have
time?

Thanks,
-Ian.


On Mon, Jan 7, 2019 at 11:03 AM 徐靖峰 <25...@qq.com> wrote:

> Hi all
>
> 现状:
>
> Dubbo
> 在应用层面发送心跳包保证连接的可用性,使用了定时器的设计,在客户端和服务端分别设置一个定时器,发送心跳,当发现连接断开时,客户端负责重连,服务端负责
> close。使用定时器并不是一个好的设计,在忙通信时,心跳是不必要的。建议使用 Netty 的
> IdleStateHandler,仅仅在检测到空闲连接时发送心跳。
>
> 修改建议:
>
> 使用 IdleStateHandler 代替 Timer 发送心跳
> 关闭 ChannelOption.SO_KEEPALIVE,网络层面的 TCP 断连需要在机器级别设置,默认是 2
> 小时,几乎没有必要存在,却发出了无必要的 TCP 探测包,仅仅依赖于应用层的心跳来给连接保活即可。
> For now:
>
> Dubbo sends a heartbeat packet at the application level to ensure the
> availability of the connection. A timer is set on the client and the server
> to send a heartbeat. When the connection is found to be disconnected, the
> client is responsible for reconnection and the server is responsible for
> close. Using a timer is not a good design, and the heartbeat is unnecessary
> when communicating busy. It is recommended to use Netty's IdleStateHandler
> to send a heartbeat only when an idle connection is detected.
>
> Proposed changes:
>
> Send heartbeats using IdleStateHandler instead of Timer
> Close ChannelOption.SO_KEEPALIVE, TCP disconnection at the network level
> needs to be set at the machine level. The default is 2 hours. There is
> almost no need to exist, but an unnecessary TCP probe packet is issued. It
> only depends on the heartbeat of the application layer to keep the
> connection alive. Just fine.
>
>