balancer_by_lua_block 導致proxy前後流量不對等

96 views
Skip to first unread message

jeason chen

unread,
Jul 1, 2020, 5:29:49 AM7/1/20
to openresty
Hi ,
請問有人遇到用balancer_by_lua_block在upstream後, backend的流量會變成約三倍於frontend的流量大小嗎?
如:frontend 約10M/s , backend約30M/s

如換用upstream原生設定即正常 (frontend 約10M/s , backend約10M/s) 

設定如下:
upstream test {
  
    server 0.0.0.0;
    balancer_by_lua_block {
      local balancer = require "ngx.balancer"
      -- balancer.set_timeouts(2, 1, 1)
    local host = ‘後端IP’
    local port = ‘後端port’
    local ok, err = balancer.set_current_peer(host, port)

        if not ok then
            ngx.log(ngx.ERR, "failed to set the current peer: ", err)
            return ngx.exit(ngx.ERR)
        end
    }
}

請問是否能指教查找方向?

另外,如 balancer.set_current_peer(host, port) 的host 是domain的話,是否會有影響?

感謝指教

jeason chen

unread,
Jul 13, 2020, 12:08:57 AM7/13/20
to openresty
Hi ,
已找到問題, 因設定了connection header 成close, 導致upstream不會做keepalive 


jeason chen於 2020年7月1日星期三 UTC+8下午5時29分49秒寫道:
Reply all
Reply to author
Forward
0 new messages