Web Hosting Talk







View Full Version : mysql max connections


Lmax
03-20-2002, 04:38 PM
Is there a way to limit the number of connections a user/database can have to the mysql server?? One user is taking up a lot of connections so other sites get "too many connections" errors. I want to limit the number so not one site can overload the stuff.
Increasing the max_connections in the mysql config files doesn't help since the user will still use up all the connections and overload the server even more.

So there are two options, kick the user of the server, of limit his access to mysql.

Synergy
03-20-2002, 04:41 PM
Change his Script's config to not use persistant connections?

Lmax
03-20-2002, 04:45 PM
They aren't persistent, there are just of lot of scripts executing tasks, and one is showing up each time. I want to limit this script to access the database with only one connection at a time, and not 10 or more and then overloading the database

Synergy
03-20-2002, 04:55 PM
Then its time to TOS the USER? How high is your load right now? Why don't you add more connections if possible.

Lmax
03-20-2002, 04:59 PM
The load is normally below 2.5, not that bad for a buzy server i think. But sometimes it jumps to 10+ or even 20+. I have a script that restarts apache and mysql, this sometimes seems to solve the problem, but then there are already complaints about "too many connections"

Well, the max_connections is now still default(100) i could try to raise it to 150 or so. I tried 300 and 200 once, but this only made things worse.

Jedito
03-20-2002, 07:44 PM
Try with
set-variable = wait_timeout = XXXX (in seconds)
set-variable = max_user_connections = XXXX

in my.cnf

Where XXXX the value that you want.

Lmax
03-20-2002, 08:02 PM
Thanks, stupid of me that i didn't find these variables. I also found out that if you run intensive mysql site that the thread_cache_size value can be of much importance. I set it to 500 but this is only a test, maybe another value is better, still experimenting with this. Anyway, the server performs much beter i think. Have to wait till the peak time tomorrow to see, but untill now it is a bit better

Jedito
03-20-2002, 08:11 PM
Glad to help :D