By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,492 Members | 1,289 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,492 IT Pros & Developers. It's quick & easy.

DB connection handling - i get "too many connection" - what's the solution?

P: n/a
I have a php-webpage that needs the database in the beginning and in
the end of the script. In the middle there is a lot of processing that
takes several seconds - during that time I don't use the database
connection.

What is the best approach? Should I close the connection after I'm
done with it OR should I reuse the connection thru my whole script?

Where can I read more about this? Any pointers?

Today I'm using the same connection thru my script. And sometimes I
get an error from the database "too many connections". What does that
mean? My webserver provider says that I have at least 100 connections
to play with. How come I get this error????

Thank you for all your help!!!!

Leif
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Leif Wessman wrote:
I have a php-webpage that needs the database in the beginning and in
the end of the script. In the middle there is a lot of processing that
takes several seconds - during that time I don't use the database
connection.

What is the best approach? Should I close the connection after I'm
done with it OR should I reuse the connection thru my whole script?

Where can I read more about this? Any pointers?

Today I'm using the same connection thru my script. And sometimes I
get an error from the database "too many connections". What does that
mean? My webserver provider says that I have at least 100 connections
to play with. How come I get this error????

Thank you for all your help!!!!

Leif


Are you using persistant connections to your database?

--
Amir Khawaja.

----------------------------------
Rules are written for those who lack the ability to truly reason, But
for those who can, the rules become nothing more than guidelines, And
live their lives governed not by rules but by reason.
- James McGuigan
Jul 17 '05 #2

P: n/a
No, should I? I have lots of traffic to my website.

Leif

Amir Khawaja <am**@gorebels.net> wrote in message news:<fDbUb.24797$QJ3.13194@fed1read04>...
Leif Wessman wrote:
I have a php-webpage that needs the database in the beginning and in
the end of the script. In the middle there is a lot of processing that
takes several seconds - during that time I don't use the database
connection.

What is the best approach? Should I close the connection after I'm
done with it OR should I reuse the connection thru my whole script?

Where can I read more about this? Any pointers?

Today I'm using the same connection thru my script. And sometimes I
get an error from the database "too many connections". What does that
mean? My webserver provider says that I have at least 100 connections
to play with. How come I get this error????

Thank you for all your help!!!!

Leif


Are you using persistant connections to your database?

Jul 17 '05 #3

P: n/a
Leif Wessman wrote:
No, should I? I have lots of traffic to my website.


Try persistant connections and see what sort of results you end up
getting. However, I doubt that will solve your problem but it does not
hurt to try. I'm assuming here that you are using MySQL (since it is the
popular DB server for PHP). One thing to note about MySQL is that if
your script runs for a long time, you may want to explicitly close the
connection prior to executing the code that takes a long time. This way,
you are not holding up the connection for other potential users of your
system. 100 is a default value set by MySQL. It means that 100
simultaneous connections may remain open at any given time.

--
Amir Khawaja.

----------------------------------
Rules are written for those who lack the ability to truly reason, But
for those who can, the rules become nothing more than guidelines, And
live their lives governed not by rules but by reason.
- James McGuigan
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.