dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

dubbo之长连接

Open ghost opened this issue 8 years ago • 23 comments

我看见网上说dubbo客户端和服务端基于长连接,那是当我客户端和服务端都开着的时候,服务端数据改变的时候,客户端并没有自动变化啊,那这个长连接到底是怎么回事,还需要配置什么文件吗

ghost avatar Nov 05 '18 03:11 ghost

服务端数据改变是什么意思?provider宕机?注册中心用的什么?长连接就是会建立一个tcp连接。假如用的是zk的话,得等一会儿才会感知到provider的宕机

AnyOSR avatar Nov 05 '18 03:11 AnyOSR

@BellaJiangxia 你好,之前你提交过一个issue,包括这个issue在内,其实跟dubbo都毫无关系。长连接指的就是tcp链接,你如果想要知道长连接定义,那建议你先去看一下tcp连接的相关知识,如果你想知道dubbo的长连接机制,那么建议你先去看一下Netty的相关知识点。

carryxyh avatar Nov 05 '18 03:11 carryxyh

yw 7kqt30 yq ad58tf 8v4,就比如我服务端提供了这个方法,服务端启动,客户端启动调用那个方法,得到这个数据, r n gesb8yai ijc 42 然后服务端方法改变成 l4cg6 jjb m d jq 2u6 f 客户端会自动变化吗

ghost avatar Nov 05 '18 03:11 ghost

重启服务端后会,不重启不会。 请自己尝试一下。

carryxyh avatar Nov 05 '18 03:11 carryxyh

嗯,重启后是可以,但是这样还是长连接吗

ghost avatar Nov 05 '18 03:11 ghost

请先去了解一下tcp协议和netty。

carryxyh avatar Nov 05 '18 03:11 carryxyh

当你服务端export的时候,class文件已经被加载,你服务端的被代理的bean已经生成了,你这时候再改变服务端的代码也没用啊。只是看起来改变了而已。和长连接没有什么关系

AnyOSR avatar Nov 05 '18 03:11 AnyOSR

那到底应该怎么做才能实现长连接呢

ghost avatar Nov 05 '18 03:11 ghost

@BellaJiangxia 你怎么这么可爱 长连接是协议层的东西,建议请先学习下tcp/ip 协议

web1992 avatar Nov 05 '18 03:11 web1992

你说的是动态加载?不像是要问长链接的意思。

On Mon, Nov 5, 2018 at 11:48 AM web [email protected] wrote:

@BellaJiangxia https://github.com/BellaJiangxia 你怎么这么可爱 长连接是协议层的东西,建议请先学习下tcp/ip 协议

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/apache/incubator-dubbo/issues/2733#issuecomment-435747422, or mute the thread https://github.com/notifications/unsubscribe-auth/AD30UeRiB79C83AQ9P8NAqB_-T3JMrlYks5ur7UcgaJpZM4YNtQk .

superleo-cn avatar Nov 05 '18 05:11 superleo-cn

是要用心跳包来维持长连接吗

ghost avatar Nov 05 '18 10:11 ghost

需要写socket来维持心跳吗

ghost avatar Nov 05 '18 10:11 ghost

那就是动态加载吧

ghost avatar Nov 06 '18 09:11 ghost

那这个动态加载有办法实现吗

ghost avatar Nov 06 '18 09:11 ghost

我觉得 @AnyOSR 已经回答的非常到位了,你现在是概念没有分清,服务端改动代码了势必要重新加载类,这个跟长连接半毛钱关系没有,等你真的需要动态加载了,你可以自己去修改dubbo源码动态绑定bean,这个是高阶玩法。

hulog avatar Nov 07 '18 02:11 hulog

May be you want to get the change from the server but not Keep Alive.

I will give you two ways :

  1. Long-Pulling (长轮询), you can get more detail from net. 2.Maybe you can consider to use JMS to send the change from server to client.

I donot know what i said satify you.

Norman [email protected] 于2018年11月7日周三 上午10:31写道:

我觉得 @AnyOSR https://github.com/AnyOSR 已经回答的非常到位了,你现在是概念没有分清,服务端改动代码了势必要重新加载类,这个跟长连接半毛钱关系没有,等你真的需要动态加载了,你可以自己去修改dubbo源码动态绑定bean,这个是高阶玩法。

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/apache/incubator-dubbo/issues/2733#issuecomment-436482520, or mute the thread https://github.com/notifications/unsubscribe-auth/AD5mbPpe_O6-ncALyOWoD3xW3XGiTOlHks5uskYVgaJpZM4YNtQk .

--

Best Regard! cvitory

cvictory avatar Nov 07 '18 02:11 cvictory

我们有大约40个基于Dubbo的微服务,一启动就建立了超过4万条TCP连接,给系统带来严重的问题,谁的更好的办法可以直接降低TCP连接数?(各种参数已设置过accepts/connections等等)另外,Dubbo这种长连接设计是否值得讨论,异步TCP连接如果高效使用,一条TCP连接都可以跑满带宽,这么多长连接必要性何在?

snailwei avatar Feb 18 '19 07:02 snailwei

@weisunding Excuse me, How do you get the conclusion "40 thousands tcp long connections" ?

tswstarplanet avatar Feb 18 '19 07:02 tswstarplanet

@tswstarplanet We have about 40 microservices based on Dubbo (providers and consumes), when bring them up, we monitored about 40,000 TCP connections established by using Linux netstat/ss command. We tried to reduced the accepts/connections parameters, but ended up with dubbo connection failure/timeout etc.

snailwei avatar Feb 18 '19 10:02 snailwei

@sweihub 请问,找到问题原因了吗? 我这边也遇到这个问题了,三十个服务左右,全部启动后占用Linux 线程 三万多

Johnson-Jia avatar Dec 23 '20 10:12 Johnson-Jia