Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
3706336b
Commit
3706336b
authored
Aug 28, 2018
by
TousakaRin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the isolation caused by the excessive latency of the timeout requests
parent
4da91251
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
circuit_breaker.cpp
src/brpc/circuit_breaker.cpp
+8
-3
No files found.
src/brpc/circuit_breaker.cpp
View file @
3706336b
...
...
@@ -31,6 +31,9 @@ DEFINE_int32(circuit_breaker_long_window_error_percent, 3,
DEFINE_int32
(
circuit_breaker_min_error_cost_us
,
100
,
"The minimum error_cost, when the ema of error cost is less than this "
"value, it will be set to zero."
);
DEFINE_int32
(
circuit_breaker_max_failed_latency_mutliple
,
2
,
"The maximum multiple of the latency of the failed request relative to "
"the average latency of the success requests."
);
namespace
{
// EPSILON is used to generate the smoothing coefficient when calculating EMA.
...
...
@@ -40,9 +43,9 @@ namespace {
// eg: when window_size = 100,
// EPSILON = 0.1, smooth = 0.9772
// EPSILON = 0.3, smooth = 0.9880
// when window_size =
3
0,
// EPSILON = 0.1, smooth = 0.9
261
// EPSILON = 0.3, smooth = 0.9
606
// when window_size =
100
0,
// EPSILON = 0.1, smooth = 0.9
977
// EPSILON = 0.3, smooth = 0.9
987
const
double
EPSILON
=
0.1
;
}
// namepace
...
...
@@ -115,6 +118,8 @@ int64_t CircuitBreaker::EmaErrorRecorder::UpdateLatency(int64_t latency) {
bool
CircuitBreaker
::
EmaErrorRecorder
::
UpdateErrorCost
(
int64_t
error_cost
,
int64_t
ema_latency
)
{
const
int
max_mutilple
=
FLAGS_circuit_breaker_max_failed_latency_mutliple
;
error_cost
=
std
::
min
(
ema_latency
*
max_mutilple
,
error_cost
);
//Errorous response
if
(
error_cost
!=
0
)
{
int64_t
ema_error_cost
=
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment