Forum Moderators: buckworks
Warning: mysql_connect() [function.mysql-connect]: User mysite has already more than 'max_user_connections' active connections in /home/mysite/public_html/ZZZZZ//includes/functions/database.php on line 19
Unable to connect to database server!
We are on shared hosting. We recently had some custom coding added which may be causing some of the problem.
We got the following response back from our host
There are many reasons this could be happening. They are:
* Your website is getting busy for this server, resulting in too many simultaneous connections/processes running.
* Your script is not exiting after execution, resulting in "zombie" / stale processes.
* You have a look/runaway process.
---------------
Sun Sep 28 00:03:48 2008: mysite running 16 processes
Sun Sep 28 00:12:04 2008: mysite running 17 processes
Sun Sep 28 13:51:32 2008: mysite running 16 processes
Sun Sep 28 14:56:12 2008: mysite running 17 processes
Sun Sep 28 14:57:03 2008: mysite running 18 processes
Sun Sep 28 14:58:40 2008: mysite running 17 processes
Sun Sep 28 15:00:02 2008: mysite running 16 processes
Sun Sep 28 15:02:25 2008: mysite running 16 processes
------------------------------------------------------------
What I suggest doing is adding an "exit(0);" to the bottom of all your PHP scripts to assure the script exits and doesn't dwell around.
If this is still a problem, you'll need to look into the code and see if you can improve in areas.
I have a php.ini file in the root of the store. I believe it does get read. Here are some of the lines in it
-------------------------------------------------------------------------------------
; Allow or prevent persistent links.
odbc.allow_persistent = On
; Check that a connection is still valid before reuse.
odbc.check_persistent = On
; Maximum number of persistent links. -1 means no limit.
odbc.max_persistent = -1
; Maximum number of links (persistent + non-persistent). -1 means no limit.
odbc.max_links = -1
-------------
; Allow or prevent persistent links.
mysql.allow_persistent = On
; Maximum number of persistent links. -1 means no limit.
mysql.max_persistent = 50
; Maximum number of links (persistent + non-persistent). -1 means no limit.
mysql.max_links = 500
--------------------------------------------------------------------------------
My Questions.
1. I believe our host has set the max connections to something like 10 or 15. Is this adequate for a site where we can expect a couple of hundred page views per day. ?
2. For OS Commerce, what would be a reasonable number of max connections?
3. Am I correct in that we would need about 1 connection per logged on visitor?
4. I checked the configure.php and the pconnect setting was set to false for both the admin and the store.
5. Would the exit(0) help. I think that would be unwieldy to try to add to all the php files in oscommerce.
6. I copied part of the php.ini file that is in the root of the store. Is there anything in there that could be tweaked for connections.
I'm beginning to think we might need to move to another host or perhaps a dedicated server.
I'd really appreciate any thoughts or comments.
Thanks
chris
I would look at the new code as this didn't happen until you added the code it would be my firt look then examine the host and how many connections you have.
Find out how many sites there are on this server and take a look at the usuage your using.
I think they are saying your not closing the connections and they are staying open causing the error.