Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Backoff Utilities #833

Merged
merged 5 commits into from Nov 1, 2019
Merged

Add Backoff Utilities #833

merged 5 commits into from Nov 1, 2019

Conversation

Reasno
Copy link
Member

@Reasno Reasno commented Nov 1, 2019

A simple implementation of #824

@Reasno Reasno force-pushed the retryUtil branch 5 times, most recently from 4479130 to db053c7 Compare November 1, 2019 08:15
usleep($sleep * 1000);
//update backoff using Decorrelated Jitter
//see: https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
$sleep = rand($firstMs, $sleep * 3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

每次重试都是上次重试时间的 1-3倍,是这样么?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是 是第一次重试和上一次重试3倍之间的一个随机数,具体算法是https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter 这里提出的Decorrelated Jitter

@Reasno
Copy link
Member Author

Reasno commented Nov 1, 2019

最后还是选择了OOP而不是闭包,便于依赖注入

@limingxinleo
Copy link
Member

@Reasno 还有其他要补充的么?我觉得 OK 的。

@Reasno
Copy link
Member Author

Reasno commented Nov 1, 2019

没有了 想把重启进程改成backoff的,另开PR吧。

@limingxinleo limingxinleo merged commit afcb50a into hyperf:master Nov 1, 2019
@limingxinleo
Copy link
Member

进程重启要不就不要改了吧。。因为按照现在的逻辑,假设出现问题。。

那就需要 1min 后才能重启,就算服务正常了。。

因为有一个常规重启逻辑,每当执行完多少次会重启的逻辑。。

@limingxinleo
Copy link
Member

async-queue 有一个 消费多少个消息后自动重启的功能

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants