This is an automated email from the ASF dual-hosted git repository. guangmingchen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push: new 667b96a9 Add a method option to disable check eovercrowded on server side (#2774) 667b96a9 is described below commit 667b96a99f1e95cb14c3f834024540f20b351d89 Author: Alan Muhammad <supersuper1...@outlook.com> AuthorDate: Mon Oct 14 14:06:39 2024 +0800 Add a method option to disable check eovercrowded on server side (#2774) * [feat][WIP] add a method option to disable check eovercrowded * [feat] only service level ignore_eovercrowded * [feat] impl ignore_eovercrowded in http protocol as well * [feat] enable for all protocols using is_overcrowded, rm useless code --------- Co-authored-by: lianxuechao <lianxuec...@bytedance.com> --- src/brpc/policy/baidu_rpc_protocol.cpp | 6 +++--- src/brpc/policy/http_rpc_protocol.cpp | 2 +- src/brpc/policy/hulu_pbrpc_protocol.cpp | 2 +- src/brpc/policy/nshead_protocol.cpp | 2 +- src/brpc/policy/sofa_pbrpc_protocol.cpp | 2 +- src/brpc/policy/thrift_protocol.cpp | 2 +- src/brpc/server.cpp | 3 ++- src/brpc/server.h | 5 +++++ 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/brpc/policy/baidu_rpc_protocol.cpp b/src/brpc/policy/baidu_rpc_protocol.cpp index cc2dcbd2..53866262 100644 --- a/src/brpc/policy/baidu_rpc_protocol.cpp +++ b/src/brpc/policy/baidu_rpc_protocol.cpp @@ -491,13 +491,13 @@ void ProcessRpcRequest(InputMessageBase* msg_base) { cntl->SetFailed(ELOGOFF, "Server is stopping"); break; } - - if (socket->is_overcrowded()) { + + if (socket->is_overcrowded() && !server->options().ignore_eovercrowded) { cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded", butil::endpoint2str(socket->remote_side()).c_str()); break; } - + if (!server_accessor.AddConcurrency(cntl.get())) { cntl->SetFailed( ELIMIT, "Reached server's max_concurrency=%d", diff --git a/src/brpc/policy/http_rpc_protocol.cpp b/src/brpc/policy/http_rpc_protocol.cpp index c4502c27..76f43c05 100644 --- a/src/brpc/policy/http_rpc_protocol.cpp +++ b/src/brpc/policy/http_rpc_protocol.cpp @@ -1495,7 +1495,7 @@ void ProcessHttpRequest(InputMessageBase *msg) { // NOTE: accesses to builtin services are not counted as part of // concurrency, therefore are not limited by ServerOptions.max_concurrency. if (!sp->is_builtin_service && !sp->params.is_tabbed) { - if (socket->is_overcrowded()) { + if (socket->is_overcrowded() && !server->options().ignore_eovercrowded) { cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded", butil::endpoint2str(socket->remote_side()).c_str()); return; diff --git a/src/brpc/policy/hulu_pbrpc_protocol.cpp b/src/brpc/policy/hulu_pbrpc_protocol.cpp index cb10aac3..20e9c827 100644 --- a/src/brpc/policy/hulu_pbrpc_protocol.cpp +++ b/src/brpc/policy/hulu_pbrpc_protocol.cpp @@ -422,7 +422,7 @@ void ProcessHuluRequest(InputMessageBase* msg_base) { break; } - if (socket->is_overcrowded()) { + if (socket->is_overcrowded() && !server->options().ignore_eovercrowded) { cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded", butil::endpoint2str(socket->remote_side()).c_str()); break; diff --git a/src/brpc/policy/nshead_protocol.cpp b/src/brpc/policy/nshead_protocol.cpp index e51be361..4288085d 100644 --- a/src/brpc/policy/nshead_protocol.cpp +++ b/src/brpc/policy/nshead_protocol.cpp @@ -301,7 +301,7 @@ void ProcessNsheadRequest(InputMessageBase* msg_base) { cntl->SetFailed(ELOGOFF, "Server is stopping"); break; } - if (socket->is_overcrowded()) { + if (socket->is_overcrowded() && !server->options().ignore_eovercrowded) { cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded", butil::endpoint2str(socket->remote_side()).c_str()); break; diff --git a/src/brpc/policy/sofa_pbrpc_protocol.cpp b/src/brpc/policy/sofa_pbrpc_protocol.cpp index 7584f79b..ad58022f 100644 --- a/src/brpc/policy/sofa_pbrpc_protocol.cpp +++ b/src/brpc/policy/sofa_pbrpc_protocol.cpp @@ -381,7 +381,7 @@ void ProcessSofaRequest(InputMessageBase* msg_base) { break; } - if (socket->is_overcrowded()) { + if (socket->is_overcrowded() && !server->options().ignore_eovercrowded) { cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded", butil::endpoint2str(socket->remote_side()).c_str()); break; diff --git a/src/brpc/policy/thrift_protocol.cpp b/src/brpc/policy/thrift_protocol.cpp index d53ec5e9..e3f4b2fa 100755 --- a/src/brpc/policy/thrift_protocol.cpp +++ b/src/brpc/policy/thrift_protocol.cpp @@ -530,7 +530,7 @@ void ProcessThriftRequest(InputMessageBase* msg_base) { if (!server->IsRunning()) { return cntl->SetFailed(ELOGOFF, "Server is stopping"); } - if (socket->is_overcrowded()) { + if (socket->is_overcrowded() && !server->options().ignore_eovercrowded) { return cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded", butil::endpoint2str(socket->remote_side()).c_str()); } diff --git a/src/brpc/server.cpp b/src/brpc/server.cpp index 740873f1..fa3ab7d7 100644 --- a/src/brpc/server.cpp +++ b/src/brpc/server.cpp @@ -152,7 +152,8 @@ ServerOptions::ServerOptions() , rtmp_service(NULL) , redis_service(NULL) , bthread_tag(BTHREAD_TAG_INVALID) - , rpc_pb_message_factory(new DefaultRpcPBMessageFactory()) { + , rpc_pb_message_factory(new DefaultRpcPBMessageFactory()) + , ignore_eovercrowded(false) { if (s_ncore > 0) { num_threads = s_ncore + 1; } diff --git a/src/brpc/server.h b/src/brpc/server.h index d65e13f0..ee5a500d 100644 --- a/src/brpc/server.h +++ b/src/brpc/server.h @@ -287,6 +287,11 @@ struct ServerOptions { // Owned by Server and deleted in server's destructor. RpcPBMessageFactory* rpc_pb_message_factory; + // Ignore eovercrowded error on server side, i.e. , if eovercrowded is reported when server is processing a rpc request, + // server will keep processing this request, it is expected to be used by some light-weight control-frame rpcs. + // [CUATION] You should not enabling this option if your rpc is heavy-loaded. + bool ignore_eovercrowded; + private: // SSLOptions is large and not often used, allocate it on heap to // prevent ServerOptions from being bloated in most cases. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org