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.
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
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
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
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...
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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...
|
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",...
|
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...
|
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...
| |
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...
|
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...
|
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">
...
|
by: EsahakNoorul |
last post by:
hi,
I want to know the difference between mysql_connect and mysql_pconnect
Regards,
Noorullah
|
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...
|
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,...
| |
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: 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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |