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

circuit breaker with half open state #2634

Merged
merged 6 commits into from
Jun 3, 2024
Merged

Conversation

jiangyt-git
Copy link
Contributor

What problem does this PR solve?

    解决server在夯住的情况下,比如可以响应ping请求、但没法响应业务逻辑请求时,单次ping请求成功就可以从熔断恢复,然后需要重新采样才能继续熔断的问题。

Issue Number:

Problem Summary:

What is changed and the side effects?

Changed:

Side effects:

  • Performance effects(性能影响):

  • Breaking backward compatibility(向后兼容性):


Check List:

  • Please make sure your changes are compilable(请确保你的更改可以通过编译).
  • When providing us with a new feature, it is best to add related tests(如果你向我们增加一个新的功能, 请添加相关测试).
  • Please follow Contributor Covenant Code of Conduct.(请遵循贡献者准则).

@@ -45,6 +46,10 @@ DEFINE_int32(circuit_breaker_max_isolation_duration_ms, 30000,
"Maximum isolation duration in milliseconds");
DEFINE_double(circuit_breaker_epsilon_value, 0.02,
"ema_alpha = 1 - std::pow(epsilon, 1.0 / window_size)");
DEFINE_int32(circuit_breaker_half_open_window_size, 10,
Copy link
Contributor

Choose a reason for hiding this comment

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

这个功能应该是可选的吧,比如half_open_window_size为0表示关闭该功能。默认为关闭,和之前的行为保持兼容。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

改了

@@ -45,6 +46,10 @@ DEFINE_int32(circuit_breaker_max_isolation_duration_ms, 30000,
"Maximum isolation duration in milliseconds");
DEFINE_double(circuit_breaker_epsilon_value, 0.02,
"ema_alpha = 1 - std::pow(epsilon, 1.0 / window_size)");
DEFINE_int32(circuit_breaker_half_open_window_size, 0,
"Half open window sample size.");
Copy link
Member

Choose a reason for hiding this comment

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

Can this be more descriptive?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@j05070415
Copy link

j05070415 commented May 26, 2024 via email

@wwbmmm
Copy link
Contributor

wwbmmm commented May 28, 2024

LGTM

+ 1 == FLAGS_circuit_breaker_half_open_window_size) {
_half_open.store(false, butil::memory_order_relaxed);
_half_open_success_count.store(0, butil::memory_order_relaxed);
return true;
Copy link
Member

Choose a reason for hiding this comment

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

Should we remove the return here and let this latency passed to _long_window/_short_window.OnCallEnd below instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@wwbmmm wwbmmm merged commit 976c588 into apache:master Jun 3, 2024
20 checks passed
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

4 participants