473,386 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

mysql_pconnect Too many connections ERROR

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
4 4146
*** 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

"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Randell D. | last post by:
Folks, I currently connect to my db with PHP code that uses non-persistent connections. I've read that persistent connections can help performance since a connection to the db will use an...
0
by: anders thoresson | last post by:
Hi, I have this function I call everytime I need to make a query from within my php-scripts: function db_connect ($user, $pwd, $db, $debug = 0) { $link = @mysql_pconnect("localhost",...
4
by: OneSolution | last post by:
Coming from a java background, I've been taught that connection pooling is the best thing due to the obvious benefits. I found out that the above pconnect() function will pool connections. So...
1
by: WhatsPHP | last post by:
Can I use mysql_pconnect on an environment like this? There is just 1 server on which both PHP and MYSQL runs. It is an intranet server. At any point atleast 2 people will be actively using the...
11
by: =?ISO-8859-1?Q?J=F8rn?= Dahl-Stamnes | last post by:
Hello, I have been using mysql_connect in a script that display a lot of thumbnails for an album. Each thumbnail is displayed using the code: <IMG SRC="thm.php?id=some_id" ALT="some title"> ...
4
hsriat
by: hsriat | last post by:
Got an issue regarding this... As said above (same as what php.net says), if we use mysql_pconnect(), it doesn't create more connections, if the connection parameters are same as the existing...
9
by: John Murtari | last post by:
Folks, We have a fairly busy web site present using PHP 5 to talk to a MySQL 5.0.45 DB on an Apache 1.3 series server. It's spread out over several physical hosts (one DB server), we use DB...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.