哪些HTTP错误永远不会触发自动重试? [英] Which HTTP errors should never trigger an automatic retry?

查看:193
本文介绍了哪些HTTP错误永远不会触发自动重试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使一些微服务更具弹性,而重试某些类型的HTTP请求将对此有所帮助.

I'm trying to make a few microservices more resilient and retrying certain types of HTTP requests would help with that.

重试超时会给客户带来非常缓慢的体验,因此在这种情况下我不打算重试.重试400秒无济于事,因为错误的请求将在几毫秒后仍然是错误的请求.

Retrying timeouts will give clients a terribly slow experience, so I don't intend to retry in this case. Retrying 400s doesn't help because a bad request will remain a bad request a few milliseconds later.

我想还有其他原因不重试其他几种类型的错误,但是哪些错误以及为什么呢?

I imagine there are other reasons to not retry a few other types of errors, but which errors and why?

推荐答案

有些错误由于看起来是永久性的,因此不应重试:

There are some errors that should not be retried because they seem permanent:

  • 400错误的请求
  • 401未经授权
  • 402需要付款
  • 403禁止进入
  • 不允许使用405方法
  • 406不可接受
  • 需要407代理身份验证
  • 409冲突-这取决于
  • 410已消失
  • 411所需长度
  • 412前提条件失败
  • 413有效载荷过大
  • 414 URI太长
  • 415不支持的媒体类型
  • 416范围无法满足
  • 417预期失败
  • 418我是茶壶-不确定这个茶壶
  • 421错误定向的请求
  • 422无法处理的实体
  • 423锁定-这取决于资源平均锁定多长时间(?)
  • 424依赖关系失败
  • 需要426升级-客户端可以自动升级吗?
  • 428需要的前提条件-我认为前提条件可以是 第二次提交,没有从开始就退出 整个过程,但这取决于
  • 429请求太多-这取决于但不能快速重试
  • 431请求标头字段太大
  • 451由于法律原因无法使用
  • 400 Bad Request
  • 401 Unauthorized
  • 402 Payment Required
  • 403 Forbidden
  • 405 Method Not Allowed
  • 406 Not Acceptable
  • 407 Proxy Authentication Required
  • 409 Conflict - it depends
  • 410 Gone
  • 411 Length Required
  • 412 Precondition Failed
  • 413 Payload Too Large 
  • 414 URI Too Long
  • 415 Unsupported Media Type
  • 416 Range Not Satisfiable
  • 417 Expectation Failed
  • 418 I'm a teapot - not sure about this one
  • 421 Misdirected Request
  • 422 Unprocessable Entity
  • 423 Locked - it depends on how long a resource is locked in average (?)
  • 424 Failed Dependency
  • 426 Upgrade Required - can the client be upgraded automatically?
  • 428 Precondition Required - I don't thing that the precondition can be fulfiled the second time without retring from the beginning of the whole process but it depends
  • 429 Too Many Requests - it depends but it should not be retried to fast
  • 431 Request Header Fields TooLarge
  • 451 Unavailable For Legal Reasons

因此,不应重试4 **个客户端错误中的大多数.

So, most of the 4** Client errors should not be retried.

不应重试的5 **个服务器错误:

The 5** Servers errors that should not be retried:

  • 500内部服务器错误
  • 未实施501
  • 502错误的网关-我看到用于临时错误,所以这取决于
  • 不支持505 HTTP版本
  • 506个变体也可以协商
  • 507存储空间不足
  • 检测到508循环
  • 510未扩展
  • 需要511网络身份验证
  • 500 Internal Server Error
  • 501 Not Implemented
  • 502 Bad Gateway - I saw used for temporary errors so it depends
  • 505 HTTP Version Not Supported
  • 506 Variant Also Negotiates
  • 507 Insufficient Storage
  • 508 Loop Detected
  • 510 Not Extended
  • 511 Network Authentication Required

但是,为了使微服务更具弹性,您应该使用 断路器模式并在上游故障时快速失效.

However, in order to make the microservices more resilient you should use the Circuit breaker pattern and fail fast when the upstream is down.

这篇关于哪些HTTP错误永远不会触发自动重试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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