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

mysql_pconnect Too many connections ERROR

P: n/a
I get this error mysql_pconnect Too many connections ... every now and
then.
Does anyone knows where it comes from ?
There are a lot of sites running on the server and all of them use the
Database frequently.
Is there any configuration that I will have to do to my server in order to
handle the load ?

Thank you...
I would appreciate answers from someone that already experienced that
problem.
Aug 1 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
*** Angelos wrote/escribió (Mon, 1 Aug 2005 12:01:20 +0000 (UTC)):
I get this error mysql_pconnect Too many connections ... every now and
then.
Does anyone knows where it comes from ?


It comes from persistent connections: they remain open even when scripts
ends so your server can display this message even with low load.

If scripts are out of your control, I'd suggest disabling persistent
connections in php.ini: scripts that use mysql_pconnect() won't stop
working, they'll just use regular connections.

[MySQL]
; Allow or prevent persistent links.
;mysql.allow_persistent = On
mysql.allow_persistent=Off

--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Aug 1 '05 #2

P: n/a

"Alvaro G Vicario" <al******************@telecomputeronline.com> wrote in
message news:15******************************@40tude.net.. .
*** Angelos wrote/escribió (Mon, 1 Aug 2005 12:01:20 +0000 (UTC)):
I get this error mysql_pconnect Too many connections ... every now and
then.
Does anyone knows where it comes from ?


It comes from persistent connections: they remain open even when scripts
ends so your server can display this message even with low load.

If scripts are out of your control, I'd suggest disabling persistent
connections in php.ini: scripts that use mysql_pconnect() won't stop
working, they'll just use regular connections.

[MySQL]
; Allow or prevent persistent links.
;mysql.allow_persistent = On
mysql.allow_persistent=Off

Cheers For that ... at the moment I have just used mysql_connect instead of
mysql_pconnect

But i Don't really understand when to use the pconnect...
Aug 1 '05 #3

P: n/a
On Mon, 01 Aug 2005 17:21:10 GMT, "Angelos" <ad**********@redcatmedia.net>
wrote:
But i Don't really understand when to use the pconnect...


http://uk.php.net/manual/en/features...onnections.php

For non-persistent connections, the number of open connections is the number
of concurrent requests, so at maximum:

= Number of child processes/threads your webserver uses

The number of connections open to a database when using persistent connections
is related to:

Number of child processes/threads your webserver uses
*multiplied by*
Number of usernames used in scripts accessing the database server

If the number of usernames used is large, i.e. there's lots of different
scripts which each access different MySQL databases, then the number of
connections opened to the server and held open by the persistent connections
can get very high. This is usually the case in shared hosting; persistent
connections are often not a good idea on shared hosting.

Whereas if there's only a small number of databases accessed on the same
server, the number of connections may stay manageable, and so you can take
advantage of not having to open a new connection each time.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Aug 1 '05 #4

P: n/a
Angelos wrote:
I get this error mysql_pconnect Too many connections ... every now and
then.
Does anyone knows where it comes from ?
There are a lot of sites running on the server and all of them use the
Database frequently.
Is there any configuration that I will have to do to my server in order to
handle the load ?


One possible suggestion, rewriting mysql_pconnect to mysql_connect has
already been mentioned, but it your load on the mysql server is not to
high, why don't you just allow more connections? You just need to set
the max_connection variable in the [mysqld] section of your my.cnf.

The problem was apparent in some default linux installations, where the
number of allowed connections to the Apache was higher than the number
of allowed connections to the mysqld (ie 150 apache connections and
only 100 allowed mysqld connections).

But that said, you need to weight between this two choices. Either
rewrite php to use mysql_connect and have little slower pages, or
update the mysqld to accept more connections. It's a simple speed vs.
load, but if your server is mostly sitting idle, I'd go for the
max_connection solution in my.cnf...

-- Evanescent Lurker --

P.S. ooh, a URI:
http://dev.mysql.com/doc/mysql/en/to...nnections.html

Aug 1 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.