calculate http error_timeout based upon capacity option #145
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR proposes an intuitive way to configure
:error_threshold
for Semian HTTP configurations. The user configures a:capacity
option as a percentage and the:error_threshold
is calculated based upon a requests:read_timeout
.Reasoning
The following diagrams assumes the circuit starts open and the requested endpoint is not recovering. This means the worker will alternate between the open and half open state.
Whenever the circuit is in an open state, the worker is able to do work for other resources. But when the worker is in a half open state, the worker cannot do other work because it's stuck hanging until the request times out.
We're calling this ratio of free to busy state the worker's
:capacity
.The High School Math
For Semian HTTP requests we can calculate capacity based on this equation:
In words, capacity of a given worker is the amount of time that is not spent hanging on a single request.
Examples
:capacity
of0.5
would set the:error_timeout
state to whatever the request timeout is.:capacity
approaches infinity,:error_timeout
also approaches infinity.:capacity
of0.75
and a60
second request timeout, the:error_timeout
would be180
seconds.Isn't this capacity stuff meant to be handled by bulkheads?
Concerns
:read_timeout
being60
seconds will lead to values of:error_timeout
greater than a minute when:capacity > 0.5
?