jhthorsen / mojo-mysql

Mojolicious and Async MySQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Maximizing the number of connections

osvathzo opened this issue · comments

Hi,

do you have a suggestion how would it be possible to implement some kind of an upper limit on the number of concurrent connections to the mysql server?

I could subscribe to the connection event of Mojo::mysql, but I don't see a way to know when a connections is closed.

Thanks,
Zoltán

Why do you need this? I don’t see how having a lot of connections open being an issue.

I don't mind having a lots of open connections, rather I would like to avoid my REST API service using so many connections that there are no more slots left for other users of the MySQL server.

But this is more a theoretical question than my other issue, I haven't reached such high concurrent connection numbers so far.
I am just curious if there is an elegant way to do this?

I think I would solve this in MySQL instead:

grant usage on *.* to my_app_db_user@'%' with max_user_connections 10;