我使用mongol,设置了local ok, err = sock:setkeepalive(10000,10)用ab测试,如果并发100个请求,连接最高是10个,但是到了10个以后不能保持,而是会断掉,新建,我查阅之前的问答,发现这是结果对的,cosocket是这么设计的,但是,不复合我的预期。现在我想,不管并发是多少,最多只用这10个连接,请问该怎么做?谢谢 --
Hello! 2016-05-15 20:10 GMT-07:00 有莘: > 我使用mongol,设置了local ok, err = sock:setkeepalive(10000,10) > 用ab测试,如果并发100个请求,连接最高是10个,但是到了10个以后不能保持,而是会断掉,新建,我查阅之前的问答,发现这是结果对的,cosocket是这么设计的,但是,不复合我的预期。 > 现在我想,不管并发是多少,最多只用这10个连接,请问该怎么做?谢谢 > 值得一提的是,NGINX 核心中的后端连接池是也这样的行为。 超出连接池容量时的请求自动排队等待是 ngx_lua 的一个 TODO: "cosocket: pool-based backend concurrency level control: implement automatic connect queueing when the backend concurrency exceeds its connection pool limit." https://github.com/openresty/lua-nginx-module#todo 欢迎贡献补丁。 在此之前,其实你也可以自己在 Lua 层面实现后端连接的并发度调控,比如使用 lua-resty-limit-traffic 库中的 resty.limit.conn 模块: https://github.com/openresty/lua-resty-limit-traffic/blob/master/lib/resty/limit/conn.md#readme 就是效率稍差一些。 Regards, -agentzh
Hello! 2016-05-15 20:10 GMT-07:00 有莘: > 我使用mongol,设置了local ok, err = sock:setkeepalive(10000,10) > 用ab测试,如果并发100个请求,连接最高是10个,但是到了10个以后不能保持,而是会断掉,新建,我查阅之前的问答,发现这是结果对的,cosocket是这么设计的,但是,不复合我的预期。 > 现在我想,不管并发是多少,最多只用这10个连接,请问该怎么做?谢谢 > 值得一提的是,NGINX 核心中的后端连接池是也这样的行为。 超出连接池容量时的请求自动排队等待是 ngx_lua 的一个 TODO: "cosocket: pool-based backend concurrency level control: implement automatic connect queueing when the backend concurrency exceeds its connection pool limit." https://github.com/openresty/lua-nginx-module#todo
欢迎贡献补丁。 在此之前,其实你也可以自己在 Lua 层面实现后端连接的并发度调控,比如使用 lua-resty-limit-traffic 库中的 resty.limit.conn 模块: https://github.com/openresty/lua-resty-limit-traffic/blob/master/lib/resty/limit/conn.md#readme 就是效率稍差一些。 Regards, -agentzh