From fd6aae8ab026fb4b6cc59bc6e5f812d34e13402e Mon Sep 17 00:00:00 2001 From: chronolaw Date: Sat, 18 Jan 2025 14:21:09 +0800 Subject: [PATCH] refactor(clustering/rpc): wait 5 seconds for non-batching rpc calls --- kong/clustering/rpc/socket.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kong/clustering/rpc/socket.lua b/kong/clustering/rpc/socket.lua index 676864e3c38..ddc35489976 100644 --- a/kong/clustering/rpc/socket.lua +++ b/kong/clustering/rpc/socket.lua @@ -347,22 +347,21 @@ function _M:start() local batch_requests = {} while not exiting() do - -- 0.5 seconds for not waiting too long - local payload, err = self.outgoing:pop(0.5) + -- 5 seconds for non-batching rpc calls + local payload, err = self.outgoing:pop(5) if err then return nil, err end -- timeout if not payload then - local n = #batch_requests - if n > 0 then + if not isempty(batch_requests) then local bytes, err = self.wb:send_binary(compress_payload(batch_requests)) if not bytes then return nil, err end - ngx_log(ngx_DEBUG, "[rpc] sent batch RPC call: ", n) + ngx_log(ngx_DEBUG, "[rpc] sent batch RPC call: ", #batch_requests) tb_clear(batch_requests) end