Describe the bug (描述bug)
基于example中的例子验证可选熔断(根据失败率)
原始代码:https://github.com/52coder/incubator-brpc/tree/master/example/asynchronous_echo_c%2B%2B
client.cpp修改点:
https://github.com/52coder/incubator-brpc/blob/master/example/asynchronous_echo_c%2B%2B/client.cpp#L65
添加:
options.enable_circuit_breaker = true;
L30行修改为rr :
DEFINE_string(load_balancer, "rr", "The algorithm for load balancing");
server.cpp在改动前,先编译出来echo_server,然后在https://github.com/52coder/incubator-brpc/blob/master/example/asynchronous_echo_c%2B%2B/server.cpp#L63前面增加如下代码:
cntl->SetFailed(brpc::EREQUEST, "Fail to parse request");然后编译出二进制echo_server_fail,这里的想法是生成一个100%失败的server触发熔断。
To Reproduce (复现方法)
验证方法,三个终端下分别执行
./echo_server --port=8002
./echo_server --port=8003
./echo_server_fail --port=8001
client端运行:
./echo_client --server="list://192.168.49.1:8001,192.168.49.1:8002,192.168.49.1:8003"
Expected behavior (期望行为)
期望行为是由于client端开启了熔断,其中一个server一直返回失败,所以应该会触发熔断才对,实际结果是跑了一晚上,一直出错的那个server并未摘除
`
I0803 00:26:21.137101 1872894 client.cpp:45] Received response from 192.168.49.1:8002: hello world (attached=bar) latency=603us
I0803 00:26:22.137842 1872886 client.cpp:45] Received response from 192.168.49.1:8003: hello world (attached=bar) latency=734us
W0803 00:26:23.138861 1872894 client.cpp:42] Fail to send EchoRequest, [E1003][127.0.1.1:8001][E1003]Fail to parse request
I0803 00:26:24.139042 1872886 client.cpp:45] Received response from 192.168.49.1:8002: hello world (attached=bar) latency=590us
I0803 00:26:25.139412 1872894 client.cpp:45] Received response from 192.168.49.1:8003: hello world (attached=bar) latency=639us
W0803 00:26:26.140028 1872886 client.cpp:42] Fail to send EchoRequest, [E1003][127.0.1.1:8001][E1003]Fail to parse request
I0803 00:26:27.140468 1872894 client.cpp:45] Received response from 192.168.49.1:8002: hello world (attached=bar) latency=733us
I0803 00:26:28.141491 1872886 client.cpp:45] Received response from 192.168.49.1:8003: hello world (attached=bar) latency=739us
W0803 00:26:29.142124 1872894 client.cpp:42] Fail to send EchoRequest, [E1003][127.0.1.1:8001][E1003]Fail to parse request
I0803 00:26:30.142181 1872886 client.cpp:45] Received response from 192.168.49.1:8002: hello world (attached=bar) latency=484us
I0803 00:26:31.142817 1872894 client.cpp:45] Received response from 192.168.49.1:8003: hello world (attached=bar) latency=737us
W0803 00:26:32.143875 1872886 client.cpp:42] Fail to send EchoRequest, [E1003][127.0.1.1:8001][E1003]Fail to parse request
I0803 00:26:33.144834 1872894 client.cpp:45] Received response from 192.168.49.1:8002: hello world (attached=bar) latency=748us
I0803 00:26:34.145134 1872886 client.cpp:45] Received response from 192.168.49.1:8003: hello world (attached=bar) latency=676us
W0803 00:26:35.145437 1872894 client.cpp:42] Fail to send EchoRequest, [E1003][127.0.1.1:8001][E1003]Fail to parse request
I0803 00:26:36.145931 1872886 client.cpp:45] Received response from 192.168.49.1:8002: hello world (attached=bar) latency=739us
`
Versions (各种版本)
OS:centos7
Compiler:
brpc:最新版
protobuf:
熔断参数均使用默认值:https://github.com/apache/incubator-brpc/blob/master/src/brpc/circuit_breaker.cpp#L32
代码看了Controller::Call::OnComplete---->FeedbackCircuitBreaker。
Additional context/screenshots (更多上下文/截图)
另外连接超时的熔断也未构造出来,设置连接超时时间1ms,rpc超时时间5ms,看服务中打印超时1008错误,但实际未触发熔断。
Describe the bug (描述bug)
基于example中的例子验证可选熔断(根据失败率)
原始代码:https://github.com/52coder/incubator-brpc/tree/master/example/asynchronous_echo_c%2B%2B
client.cpp修改点:
https://github.com/52coder/incubator-brpc/blob/master/example/asynchronous_echo_c%2B%2B/client.cpp#L65
添加:
options.enable_circuit_breaker = true;
L30行修改为rr :
DEFINE_string(load_balancer, "rr", "The algorithm for load balancing");
server.cpp在改动前,先编译出来echo_server,然后在https://github.com/52coder/incubator-brpc/blob/master/example/asynchronous_echo_c%2B%2B/server.cpp#L63前面增加如下代码:
cntl->SetFailed(brpc::EREQUEST, "Fail to parse request");然后编译出二进制echo_server_fail,这里的想法是生成一个100%失败的server触发熔断。
To Reproduce (复现方法)
验证方法,三个终端下分别执行
./echo_server --port=8002
./echo_server --port=8003
./echo_server_fail --port=8001
client端运行:
./echo_client --server="list://192.168.49.1:8001,192.168.49.1:8002,192.168.49.1:8003"
Expected behavior (期望行为)
期望行为是由于client端开启了熔断,其中一个server一直返回失败,所以应该会触发熔断才对,实际结果是跑了一晚上,一直出错的那个server并未摘除
`
I0803 00:26:21.137101 1872894 client.cpp:45] Received response from 192.168.49.1:8002: hello world (attached=bar) latency=603us
I0803 00:26:22.137842 1872886 client.cpp:45] Received response from 192.168.49.1:8003: hello world (attached=bar) latency=734us
W0803 00:26:23.138861 1872894 client.cpp:42] Fail to send EchoRequest, [E1003][127.0.1.1:8001][E1003]Fail to parse request
I0803 00:26:24.139042 1872886 client.cpp:45] Received response from 192.168.49.1:8002: hello world (attached=bar) latency=590us
I0803 00:26:25.139412 1872894 client.cpp:45] Received response from 192.168.49.1:8003: hello world (attached=bar) latency=639us
W0803 00:26:26.140028 1872886 client.cpp:42] Fail to send EchoRequest, [E1003][127.0.1.1:8001][E1003]Fail to parse request
I0803 00:26:27.140468 1872894 client.cpp:45] Received response from 192.168.49.1:8002: hello world (attached=bar) latency=733us
I0803 00:26:28.141491 1872886 client.cpp:45] Received response from 192.168.49.1:8003: hello world (attached=bar) latency=739us
W0803 00:26:29.142124 1872894 client.cpp:42] Fail to send EchoRequest, [E1003][127.0.1.1:8001][E1003]Fail to parse request
I0803 00:26:30.142181 1872886 client.cpp:45] Received response from 192.168.49.1:8002: hello world (attached=bar) latency=484us
I0803 00:26:31.142817 1872894 client.cpp:45] Received response from 192.168.49.1:8003: hello world (attached=bar) latency=737us
W0803 00:26:32.143875 1872886 client.cpp:42] Fail to send EchoRequest, [E1003][127.0.1.1:8001][E1003]Fail to parse request
I0803 00:26:33.144834 1872894 client.cpp:45] Received response from 192.168.49.1:8002: hello world (attached=bar) latency=748us
I0803 00:26:34.145134 1872886 client.cpp:45] Received response from 192.168.49.1:8003: hello world (attached=bar) latency=676us
W0803 00:26:35.145437 1872894 client.cpp:42] Fail to send EchoRequest, [E1003][127.0.1.1:8001][E1003]Fail to parse request
I0803 00:26:36.145931 1872886 client.cpp:45] Received response from 192.168.49.1:8002: hello world (attached=bar) latency=739us
`
Versions (各种版本)
OS:centos7
Compiler:
brpc:最新版
protobuf:
熔断参数均使用默认值:https://github.com/apache/incubator-brpc/blob/master/src/brpc/circuit_breaker.cpp#L32
代码看了Controller::Call::OnComplete---->FeedbackCircuitBreaker。
Additional context/screenshots (更多上下文/截图)
另外连接超时的熔断也未构造出来,设置连接超时时间1ms,rpc超时时间5ms,看服务中打印超时1008错误,但实际未触发熔断。