如何解决grpc截止日期超出错误? [英] How to solve grpc Deadline Exceeded error?

查看:467
本文介绍了如何解决grpc截止日期超出错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有由go和python客户端编写的grpc服务器,有时会发生以下错误:

I have grpc server which write by go and a python client, sometimes, the errors occurred as below:

eggs/grpcio-1.0.0-py2.7-linux-x86_64.egg/grpc/_channel.py\", line 432, in _end_unary_response_blocking\n    raise _Rendezvous(state, None, None, deadline)\nInternalServerError: Deadline Exceeded\n"}

grpc截止日期概念:

gRPC允许客户端在调用远程服务器时指定最后期限值 方法.这指定客户端要等待多长时间 RPC完成并出现错误之前来自服务器的响应 DEADLINE_EXCEEDED.在服务器端,服务器可以查询 最后期限,以查看特定方法是否超时或多少时间 剩下来完成该方法.

gRPC allows clients to specify a deadline value when calling a remote method. This specifies how long the client wants to wait for a response from the server before the RPC finishes with the error DEADLINE_EXCEEDED. On the server side, the server can query the deadline to see if a particular method has timed out, or how much time is left to complete the method.

如何指定截止日期因语言而异-对于 例如,Python中始终需要最后期限值,而不是全部 语言有默认的截止日期.

How the deadline is specified varies from language to language - for example, a deadline value is always required in Python, and not all languages have a default deadline.

是否可以解决此错误?

is there way to solve this error?

推荐答案

如上面的注释中所述,截止日期可以是客户端和服务器之间的任何事物,包括网络和服务器的实现.当您通过网络进行交谈时,应偶尔预期截止日期,例如在包裹丢失期间.一般而言,您可以在此处执行多种选择:

As mentioned in the comment above, deadlines can be just about anything between the client and server, including the network and implementation of the server. As you are talking over a network, deadlines should be expected occasionally, for example during package losses. I general, there are a couple of options on what you can do here:

  • 优化服务器实现以更快地处理您的请求.
  • 如果客户设定了较短的期限,则增加期限.
  • 通过以下方式优雅地处理截止日期错误:
    • 正在重试.只需确保使用指数补偿,这样就不会在服务器过载的情况下使问题恶化.
    • 在上游报告错误.
    • 有时也有可能退回到不使用该grpc调用的位置,从而降低体验.
    • Optimize the server implementation to handle your requests faster.
    • In case the client sets a short deadline, increase this.
    • Handle the deadline errors gracefully by:
      • Retrying. Just make sure to use an exponential back-off, so you don't make the problem worse in case of a server overload situation.
      • Report an error up-streams.
      • Sometimes it may also be possible to fall back to not use that grpc call and degrade the experience.

      这篇关于如何解决grpc截止日期超出错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆