dubbo超时原因以及解决方案

dubbo超时原因以及解决方案:

1、超时日志:

服务端:

Caused by: com.alibaba.dubbo.remoting.TimeoutException: Waiting server-side response timeout. start time: 2017-08-05 18:14:52.751, end time: 2017-08-05 18:14:53.764, client elapsed: 6 ms, server elapsed: 1006 ms, timeout: 1000 ms, request: Request [id=0, version=2.0.0, twoway=true, event=false, broken=false, data=RpcInvocation [methodName=getCommentsByProductId, parameterTypes=[class java.lang.Long], arguments=[1], attachments={traceId=6299543007105572864, spanId=6299543007105572864, input=259, path=com.jim.framework.dubbo.core.service.CommentService, interface=com.jim.framework.dubbo.core.service.CommentService, version=0.0.0}]], channel: /192.168.10.222:53204 -> /192.168.10.222:7777
    at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:107) ~[dubbo-2.5.3.jar:2.5.3]
    at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:84) ~[dubbo-2.5.3.jar:2.5.3]
    at com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker.doInvoke(DubboInvoker.java:96) ~[dubbo-2.5.3.jar:2.5.3]
    ... 42 common frames omitted

客户端类似:

com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method   in the service com.... Tried 3 times of the providers [172..., 172.... , 172...:03] (3/3) from the registry 172....:2181 on the consumer 172.... using the dubbo version 2.5.3. Last error is: Invoke remote method timeout. method:  , provider: dubbo://172....:03/com.?anyhost=true&application=admin-dubbo&check=false&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=com. ice&methods=getBalanceInfo,getBalance,recharge,unfreeze,statisticAccountInfo,withdraw,transfer2User,register&pid=1&release=2.7.7&revision=1.0.0.0-SNAPSHOT&side=consumer&timestamp=1648652988240, cause: Waiting server-side response timeout by scan timer. start time: 2022-03-30 23:12:22.772, end time: 2022-03-30 23:12:23.796, client elapsed: 0 ms, server elapsed: 1024 ms, timeout: 1000 ms, request: 

2、原因:

消费者:当消费者发起一次请求后,如果在规定时间内未得到服务端的响应则直接返回超时异常,但服务端的代码依然在执行。

生产者:消费端发起一次请求后,一直等待服务端的响应,服务端在方法执行到指定时间后如果未执行完,此时返回一个超时异常给到消费端。

dubbo的超时主要是针对客户端的,由于Dubbo是采用一种NIO模式,消费者发起请求后得到一个ResponseFuture,然后消费者一直轮询这个ResponseFuture直至超时或者收到生产者的返回结果。虽然超时了,但仅仅是消费者不再等待生产者的反馈并不代表此时服务端也停止了执行。

3、解决方案:

springboot配置超时时间:

dubbo:
  consumer:
    timeout: 10000
  provider:
    timeout: 30000

springMVC配置:

<dubbo:consumer timeout="10000"></dubbo:consumer>

<dubbo:provider timeout="10000"></dubbo:provider>

4、举例 生产者 4秒  ,消费者设置3秒,这个service在调用时的超时时间就是3秒

1)consumer会在超过3秒时得到一个调用超时的异常。

2)provider中代码的执行不会因为超时而中断,在执行完毕后,会得到一个dubbo的警告。

即 在dubbo的provider和consumer的配置文件中,如果都配置了timeout的超时时间,dubbo默认以consumer中配置的时间为准

  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

寅灯

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值