Click to See Complete Forum and Search --> : Too many connections
The Little Guy
10-31-2006, 12:46 PM
For the first time ever I got this error:
Warning: mysql_connect(): Too many connections in /home2/dtoporg/public_html/db.php on line 7
Too many connections
What does it mean? I know it means there are too many connections (obviously), what can I do, or why is it doing it?
netbuddy
10-31-2006, 12:57 PM
is the query nested in a loop?
or... has your SQL server got a "bot" attempting to access the resource?
The Little Guy
10-31-2006, 01:36 PM
It's not in a loop
could be a "bot" It has stopped, for now. It could have been a server issue right?
netbuddy
10-31-2006, 03:22 PM
Weird, I replied once to this post and it didnt show!
You could have had your site swamped with connections to your site.
ALSO you should "Close" any database connections AFTER you have qot your query result as an open connection is limiting your sites ability to serve up and you will run out of connections until the server timeouts occur.
bokeh
10-31-2006, 03:33 PM
is the query nested in a loop?The query is not where the problem is. The error message is raised by mysql_connect. Whether it is in a loop is of no relevance. mysql_connect only opens a new connection if one to the requested mysql server does not already exist.
Too many connections means your site is having a traffic spike. Look at your access log to find out why.
netbuddy
10-31-2006, 04:42 PM
The query is not where the problem is. The error message is raised by mysql_connect. Whether it is in a loop is of no relevance. mysql_connect only opens a new connection if one to the requested mysql server does not already exist.
Too many connections means your site is having a traffic spike. Look at your access log to find out why.
It does, if you have the query stuck in a loop that keeps on making a query each iteration, you will very quickly run out of open connections to the SQL server as will keeping connections open when no longer needed.
bokeh
11-01-2006, 05:59 AM
It does, if you have the query stuck in a loop that keeps on making a query each iteration, you will very quickly run out of open connections to the SQL server as will keeping connections open when no longer needed.Queries do not open connections. Even if you were to run one million queries in a loop there would still only be one connection.
netbuddy
11-01-2006, 11:36 AM
Queries do not open connections. Even if you were to run one million queries in a loop there would still only be one connection.
It entirely depends on how you set your connection up.
It depends on the server that recieves the query.
It depends on the amount of traffic at the site at that time.
It depends if the coder incorporates some house keeping after the query is finished.
It depends on allot of things that we dont know about, the server could have been down or rebooting or any number of issues even my inital suggestion of a BOT which some hosts operate that can sap a sites conectivity when its being indexed.
You like me have no idea what it could have been, were just second guessing but the issue of too many connections is often be a coding problem... I know as I have experienced it with (believe it or not) an empty database that I had just initalized.... Too many connections!
The Little Guy
11-01-2006, 01:23 PM
I think that it was somthing to do with the server, because it hasn't happend any more.
knowj
11-01-2006, 01:26 PM
i've had this problem before with my old host they restrict how many connections you can make.
if theres ever high load on the sql server you can get this message
also if theres ever some technical errors
netbuddy
11-01-2006, 02:20 PM
I think that it was somthing to do with the server, because it hasn't happend any more.
Depending on how your host operates, most hosts provide you with a log which is accessed through your user CP and your log will show what the reason was.
Some hosts use a seperate folder called logs in the same folder as the htdocs folder like in my friends site, some use a database to store your traffic logs. Most good hosting accounts will provide some access to event logs. If you dont, ask your host, if they dont provide any traffic logging, I seriously suggest that you move to a provider that does.
chazzy
11-01-2006, 06:43 PM
...
I have no idea what you're talking about.
PHP closes all database connections upon script completion.
Directly from PHP.net
Note: The link to the server will be closed as soon as the execution of the script ends, unless it's closed earlier by explicitly calling mysql_close().
It sounds like to me, you don't know what it could be, but bokeh knows what it wasn't. It had nothing to do with the number of queries being sent to the server, nothing to do with not using mysql_close() at the end of the script.
bokeh
11-02-2006, 06:19 AM
PHP closes all database connections upon script completion.That depends on what function opened the connection:the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established...