Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to control the total number of mysql connections #16

Open
ghost opened this issue Jun 22, 2014 · 1 comment
Open

How to control the total number of mysql connections #16

ghost opened this issue Jun 22, 2014 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 22, 2014

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?

@agentzh
Copy link
Member

agentzh commented Jun 22, 2014

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant