Skip to content

circuit breaker with half open state#2634

Merged
wwbmmm merged 6 commits into
apache:masterfrom
jiangyt-git:master
Jun 3, 2024
Merged

circuit breaker with half open state#2634
wwbmmm merged 6 commits into
apache:masterfrom
jiangyt-git:master

Conversation

@jiangyt-git

Copy link
Copy Markdown
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.(请遵循贡献者准则).

Comment thread src/brpc/circuit_breaker.cpp Outdated
"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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

改了

Comment thread src/brpc/circuit_breaker.cpp Outdated
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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@j05070415

j05070415 commented May 26, 2024 via email

Copy link
Copy Markdown

@wwbmmm

wwbmmm commented May 28, 2024

Copy link
Copy Markdown
Contributor

LGTM

Comment thread src/brpc/circuit_breaker.cpp Outdated
+ 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
Copy Markdown
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
Copy Markdown
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
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.

4 participants