473,506 Members | 16,954 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regarding mysql_pconnect()

hsriat
1,654 Recognized Expert Top Contributor
For your database connection issue, what you can do is instead of connect() use pconnect()

p = persistent.

This way php/mysql do no create more connections, if the connection parameters are the same, it looks for a current one and uses it.
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 pconnection's.

But if the already set pconnection is too busy serving others, would the next request of pconnect create another connection then or would still wait for the first query to complete before serving it?

This will actually end up utilizing only one connection.
May 25 '08 #1
4 2063
dlite922
1,584 Recognized Expert Top Contributor
From what I understand your problem is, some solutions are provided here:

http://www.mysqlperformanceblog.com/2006/11/12/are-php-persistent-connections-evil/

I still don't know how you have so many connections.

With pconnect() it is done once per user session (per request), Do you have thousands of users pinging the DB at the same time?

If so, you might need to go enterprise level, increase harware and setup i guess. Increase number of ports/default connections between PHP and MySQL (Google it as i've never done this)

Hope that helps buddy,


Dan
May 25 '08 #2
hsriat
1,654 Recognized Expert Top Contributor
From what I understand your problem is, some solutions are provided here:

http://www.mysqlperformanceblog.com/2006/11/12/are-php-persistent-connections-evil/

I still don't know how you have so many connections.

With pconnect() it is done once per user session (per request), Do you have thousands of users pinging the DB at the same time?

If so, you might need to go enterprise level, increase harware and setup i guess. Increase number of ports/default connections between PHP and MySQL (Google it as i've never done this)

Hope that helps buddy,


Dan
Yes, I have average 100 users pinging at time. At time, it might be no one. Its an online entrance test site. So it depends upon at what time the test is.

Using mysql_connect, "Error: Too many connections" occurs like 1'ce in every 10 tries while testing in a lab of more then 100 clients. While there are 50 allowed connections by the server host.

Using mysql_pconnect, it sounds like only one connection will be used. But I need to utilize all the 50 allowed connections, else it would slow down the speed.

Will read out the stuff at the link provided. Then will think something.

Thanks for the response.



Regards,
Harpreet
May 25 '08 #3
dlite922
1,584 Recognized Expert Top Contributor
Yes, I have average 100 users pinging at time. At time, it might be no one. Its an online entrance test site. So it depends upon at what time the test is.

Using mysql_connect, "Error: Too many connections" occurs like 1'ce in every 10 tries while testing in a lab of more then 100 clients. While there are 50 allowed connections by the server host.

Using mysql_pconnect, it sounds like only one connection will be used. But I need to utilize all the 50 allowed connections, else it would slow down the speed.

Will read out the stuff at the link provided. Then will think something.

Thanks for the response. :)

Regards,
Harpreet

Sounds good, but still 100 users is not nearly enough for MySQL to trip about it. I'm not sure what's causing this error.

And to be honest, I've never run into this issue before so I'm kind of guiding you blind.

I'm interested in the solution though,


Dan
May 26 '08 #4
hsriat
1,654 Recognized Expert Top Contributor
Sounds good, but still 100 users is not nearly enough for MySQL to trip about it. I'm not sure what's causing this error.

And to be honest, I've never run into this issue before so I'm kind of guiding you blind.

I'm interested in the solution though,


Dan
Content there was good, but got no idea what to do. Their (guys in that blog) arguments rather made me more confused about the matter.

I have two options now.
  • Review code and make sure connection is only made when required and closed as soon as there's no more use.
  • In my database.php file, replace mysql_connect with mysql_pconnect, and replace mysql_close with return.
Will try the second one first, do that 100 client testing, for which they charge me

, see the results, and then do changes accordingly.

oh btw... nice hat and goggles.



cheers...
May 26 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2541
by: Yun Guan | last post by:
Hello folks, In my php scripts, those mysql functions, like mysql_pconnect() and mysql_connect() are said to be undefined. What do I miss here? Thanks. -- Allen Guan 281-489-2314
1
2738
by: Hal Halloway | last post by:
mysql_pconnect("localhost","user","password") Is there a way so that password will not be text? So someone looking at the file would not be able to know the password? Thanks Ps my sysadmin...
0
1468
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
4156
by: Angelos | last post by:
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...
8
5208
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is...
1
1851
by: tom_b | last post by:
I get this error when I try to connect to my database Fatal error: Call to undefined function mysql_pconnect() in c:\program files\apache group\Apache\htdocs\flash.php on line 11 Here's the...
1
1523
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
1664
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"> ...
2
1941
by: EsahakNoorul | last post by:
hi, I want to know the difference between mysql_connect and mysql_pconnect Regards, Noorullah
0
7103
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7307
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7370
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...
0
7478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.