Open ghost opened 10 years ago
@Samin-Du I've already been working on connection-pool-based concurrency level limiting of the underlying cosocket API in the pool-limiting
branch of lua-nginx-module: https://github.com/openresty/lua-nginx-module/tree/pool-limiting
The first step is to return an error immediately when exceeding the pool size limit so that you can use ngx.sleep
to poll connect() yourself. This part is already there. The second step is to wait via an internal queue in connect() itself, which won't introduce extra waiting latency as with ngx.sleep
and is easier to use.
Because it works on the (lower) cosocket level, every higher level Lua library like lua-resty-mysql
and lua-resty-redis
will enjoy this feature out of the box.
The function connect will create a new mysql connection or select a free connection from pool! If there are too many connection using, I don't want it to return immediately until another connection is released! How to do it?