PHP provides both msql_connect and mysql_pconnect. The former does
indeed create a new connection to process each request and closes it
auto-magically upon completion. The latter creates a rather
half-assed connection pool; once a connection is allocated by PHP, it
is held open and reused for subsequent requests. New connections are
created if no persistent connection is available. Unfortunately,
connections allocated though mysql_pconnect are never closed. If the
rate of requests should spike, PHP will potentially allocate every
connection and never release them, even after traffic returns to
normal, which counter-indicates using the method for any pratiacl web
application. Most developers/admins prefer to take the hit and use
mysql_connect, opening and closing a connection for each request
rather than risk having all connections consumed.
- michael dykman
On Fri, Sep 19, 2008 at 12:07 PM, Olexandr Melnyk <omelnyk@stripped> wrote:
> In case you're using PHP, in theory all database connections should be
> closed when script stops execution. I'm not sure if it's always like that in
> Persistent connections can be a quick fix to your problem, but as was
> mentioned in the previous mail, it's better to find out why there's so
> many of them.
> On 9/19/08, Gary W. Smith <gary@stripped> wrote:
>> I know the list has already recommended allowing more connections but the
>> bigger question is what is sucking them all up. Even with 1000 connections
>> things like apache can only use the number of connections that there are
>> processes (* the number of connections used within each process).
>> As a fast workaround, increase the connections but for a long term solution
>> you really need to find out what the problem is, now how to work around it.
>> From: Kinney, Gail [mailto:Gail.Kinney@stripped]
>> Sent: Fri 9/19/2008 8:33 AM
>> To: 'mysql@stripped'
>> Subject: too many connections
>> Hello, We have MySQL 4.0.14 and have just gotten an error: too many
>> connections. we can't connect to our site using MySQL admin. Please help.
>> Gail Kinney
>> Webmaster UC Denver
> Sincerely yours,
> Olexandr Melnyk
- michael dykman
- All models are wrong. Some models are useful.