FCM:重试后和指数补偿 [英] FCM: Retry-after and exponential backoff

查看:106
本文介绍了FCM:重试后和指数补偿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我了解,当邮件传递失败时,Retry-After标头有时会包含在响应中,有时则不会.但是,如果我第一次收到包含Retry-After的错误响应,重新发送消息并收到另一个错误响应却没有Retry-After的情况,会发生什么?我知道我应该使用指数补偿,但是当先前的等待时间来自Retry-After标头时,该如何工作?

As I understand, when a message fails to be delivered, the Retry-After header is sometimes included in the response and sometimes not. But what happens if I first receives an error response with Retry-After included, resends the message and receives another error response but without Retry-After? I know I should use exponential backoff but how does that work when the previous waiting time was from the Retry-After header?

想象一下请求和响应的顺序:

Imagine this sequence of requests and responses:

Request 1: No waiting
Response 1: Error without Retry-After
Request 2: Wait 2 seconds
Response 2: Error with Retry-After included (let's say 120 seconds)
Request 3: Wait 120 seconds
Response 3: Error without Retry-After
Request 4: How long should I wait? 

在发送请求4前我应该等待多长时间?8秒?还是从头开始2秒?

How long should I wait before sending request 4? 8 seconds? Or start from the beginning with 2 seconds?

推荐答案

AFAIK,实际上没有标准的指数补偿方法或间隔.

AFAIK, there isn't really a standard way or interval for an exponential backoff.

但是,通常会发生的情况是,对于每个连续的不成功请求,等待间隔应该比上一个间隔长,但是如果是第一个错误响应(例如,上一个请求成功),则应恢复为默认值值(您设置的值,例如2秒).

However, what is usually followed is that for every consecutive unsuccessful request, the waiting interval should be longer than the previous one, but if it is the first error response (e.g. previous request was successful), it should revert to the default value (a value you set, e.g. 2 seconds).

一个例子就是这样.

Request 1: No waiting
Response 1: Error without Retry-After
Request 2: Wait 2 seconds // assume 2seconds is your default
Response 2: Error with Retry-After included (let's say 120 seconds)
Request 3: Wait 120 seconds
Response 3: Error without Retry-After
Request 4: 180 // you use the previous value of 120 x 1.5 (sample value increment)
Request 5: ...
Response 5: Success!
Request 6: 1 second (assume default waiting interval per success response)
Response 6: Error without Retry-After included
Request 7: Wait 2 seconds (using the default)

在某些行为中,它并不一定要精确间隔,某些行为会随机添加一个增量值.

There are also some behaviors where it doesn't have to a precise interval, some mix in a random value for the increment.

您应该查看以下内容:

这篇关于FCM:重试后和指数补偿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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