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_thresholdfor Semian HTTP configurations. The user configures a:capacityoption as a percentage and the:error_thresholdis 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
:capacityof0.5would set the:error_timeoutstate to whatever the request timeout is.:capacityapproaches infinity,:error_timeoutalso approaches infinity.:capacityof0.75and a60second request timeout, the:error_timeoutwould be180seconds.Isn't this capacity stuff meant to be handled by bulkheads?
Concerns
:read_timeoutbeing60seconds will lead to values of:error_timeoutgreater than a minute when:capacity > 0.5?