-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
#2080 Add new V8 params to fine-tune Polly's circuit-breaker behavior #2081
base: develop
Are you sure you want to change the base?
#2080 Add new V8 params to fine-tune Polly's circuit-breaker behavior #2081
Conversation
Great! Which version are you planning to release it in? Please note that the PR depends on #2073, which needs to be merged before this PR. Therefore, this feature branch should be rebased after the merging of #2073, and ideally, after #2079 is merged as well. It appears that it won't be included in version 23.3, but rather in version 24.0, which is the next release following v23.3. |
Yes, @raman-m, you can add this when you want |
@RaynaldM |
@RaynaldM Conflicts! |
1de22fd
to
f69831a
Compare
Let's assign this to the Sep'24 milestone since the Annual 2023 milestone is already quite overloaded, and we need to reduce the scope of work for 2023. |
…ircuit-breaker behavior
add an isValid method on QoSOptions
add an isValid method on QoSOptions
8a6926a
to
3199588
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The absence of tests for the new properties is a significant concern for approval.
I recommend further work on the PR.
For Your Information: The feature branch has been successfully rebased onto the develop branch, as of November 1st, just today
@@ -35,13 +35,18 @@ Then add the following section to a Route configuration: | |||
"QoSOptions": { | |||
"ExceptionsAllowedBeforeBreaking": 3, | |||
"DurationOfBreak": 1000, | |||
"TimeoutValue": 5000 | |||
"TimeoutValue": 5000, | |||
"FailureRatio": .8 // .8 = 80% of failed, this is default value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No comma❗
"FailureRatio": .8 // .8 = 80% of failed, this is default value | |
"FailureRatio": .8, // .8 = 80% of failed, this is default value |
"TimeoutValue": 5000 | ||
"TimeoutValue": 5000, | ||
"FailureRatio": .8 // .8 = 80% of failed, this is default value | ||
"SamplingDuration": 10000 // The time period over which the failure-success ratio is calculated (in milliseconds), default is 10000 (10s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Better to add new properties docs below, after line 45.
- You are wrong regarding default value! According to the docs for SamplingDuration, the default value is 30 seconds! So, we override library value by our custom one (10s). I believe we must assign lib value in
QoSOptions
FailureRatio = 0.8, | ||
SamplingDuration = TimeSpan.FromSeconds(10), | ||
FailureRatio = options.FailureRatio, | ||
SamplingDuration = TimeSpan.FromMilliseconds(options.SamplingDuration), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both SamplingDuration
and BreakDuration
are TimeSpan
s, so they can be initialized from milliseconds.
Not an issue! FYI
FailureRatio = failureRatio; | ||
} | ||
|
||
public QoSOptions( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you add both constructors? I don't see any changes in the Creators' logic.
It appears these constructors were added solely for testing purposes. I would suggest switching to QoSOptionsBuilder
and removing these two constructors.
Therefore, you will need to update QoSOptionsBuilder
by adding new initialization methods.
/// </value> | ||
public int SamplingDuration { get; } = 10000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree to assign custom default value which differs from the lib one!
So, according to the docs for SamplingDuration, the default value is 30 seconds! So, we override library value by our custom one (10s). I believe we must assign lib value in QoSOptions
/// <value> | ||
/// An <see cref="double"/> ratio of exceptions/requests (0.8 means 80% failed of all sampled executions). | ||
/// </value> | ||
public double FailureRatio { get; } = .8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually FailureRatio has the default value is 0.1
So, I don't recommend to override library settings!
public bool IsValid() => | ||
ExceptionsAllowedBeforeBreaking <= 0 || | ||
ExceptionsAllowedBeforeBreaking >= 2 && DurationOfBreak > 0 && !(FailureRatio <= 0) && | ||
!(FailureRatio > 1) && SamplingDuration > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it used for JSON config validation?
@@ -38,7 +38,7 @@ public override void Dispose() | |||
public void Should_not_timeout() | |||
{ | |||
var port = PortFinder.GetRandomPort(); | |||
var route = GivenRoute(port, new QoSOptions(10, 500, 1000, null), HttpMethods.Post); | |||
var route = GivenRoute(port, new QoSOptions(10, 500, .5, 5, 1000, null), HttpMethods.Post); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test readability is low❗
We have to switch to QoSOptionsBuilder
in tests avoiding direct usage of constructors!
With QoSOptionsBuilder
test readability will be excellent. 😉
Raynald, please note that this PR is a successor of #2073, which contains numerous changes to the same logic. |
Closes #2080
FailureRatio
andSamplingDuration
parameters of Polly V8 circuit-breaker #2080This PR adds 2 new parameters in
QoSOptions
to fine-tune circuit-breaker behavior 👉FailureRatio
: The failure-success ratio that will cause the circuit to break/open.SamplingDuration
: The time period over which the failure-success ratio is calculated (in seconds).