Waynn Lue wrote:
Our site has been slowing down dramatically in the last few days, so
I've been trying to figure out why. I ran some profiling scripts on
our site and saw that we're spending between 3-9 seconds on
mysql_connect. Then I connected to our db and saw that there were
over 100 connections at the time, most of them sleeping. Is this
because we don't close mysql connections until the end of script
execution?
How do people generally structure their code to minimize the time they
keep mysql connections open? Currently all db connections go through
one file, which gets included at the top of the file. One other
question, is it better to open one connection, then re-use it later,
or just continually open and close per db call?
Thanks,
Waynn
Hi Waynn,
I've done some tuning on MySQL last year after having similar problems.
They are not all gone, but they are reduced to a minimum.
I've read the following URL's to get some hints and tips:
www dot databasejournal dot com/features/mysql/print.php/10897_1402311_3
www dot t-scripts dot com/mysql/
mysqldatabaseadministration dot blogspot dot
com/2005/11/mysql-5-optimization-and-tuning-guide.html
(I'm sorry that these URL's are not allowed due to SURBL policies,
replace 'dot' with the appropiate character)
It boils down to tuning your my.cnf with some altered parameters and
checking the status in MySQL. It depends on how much memory is in use,
how many tables you want to have open and how many connection you expect
within certain periods etc. You can gain a lot with doing this. Having
sleeping processes / connections is because it doesn't have a hard
timeout and MySQL sometimes forgets to kill these processes. But this is
because of the load. When the load decreases, MySQL is better being able
to keep up with the processes.
--
Aschwin Wesselius
'What you would like to be done to you, do that to the other....'
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php