PDA

View Full Version : mysql_pconnect disabled



natural
02-20-2008, 04:52 AM
Hi All

My site went down for a few hours last night. My hosts are excellent with their support and told me that the reason was that they have disabled mysql_pconnect on the server.

From now on I need to use mysql_connect.

I will be updating to the latest version of OR within the next couple of weeks. Will this solve the issue or is there anything else I need to do.

thanks all

Clive

Mick
02-20-2008, 05:44 AM
There is no issue to resolve. Persistent connections are more efficient and reduce latency as it doesn't require a new connection to be opened every time you do something with the database and thus why we use them instead of regular connections.

Reference:

http://www.php.net/manual/en/features.persistent-connections.php

natural
02-20-2008, 08:44 AM
Hi Mick, thanks for your answer..

I read the link through a few times and still have trouble understanding a lot of it...

I realise it's not an issue or bug in the real sense but this has happened twice in the last few months with my sites..

Both times I got onto the hosts technical support live chat and my sites were back on-line within minutes and when I ask what happened they say in the future I must use mysql_connect because mysql_pconnect is disabled on the server...

So is this something that my hosts need to know should not and does not need disabling? I really can't fault their service and would not want to move to a new company.


An important summary. Persistent connections were designed to have one-to-one mapping to regular connections. That means that you should always be able to replace persistent connections with non-persistent connections, and it won't change the way your script behaves. It may (and probably will) change the efficiency of the script, but not its behavior!

If my hosts won't enable persistent connections is the above possible?

Thanks

Clive

pbflash
02-20-2008, 08:57 AM
It is possible but it could affect the performance of your site. If your host is not willing to enable persistent connections then you should consider moving to a host that will. There is no reason that I can think of for a host to disable persistent connections.

In include/common.php change $conn->pconnect($db_server,$db_user,$db_password,$db_data base) to $conn->connect($db_server,$db_user,$db_password,$db_datab ase)

You will have to make this change every time you update OR.

the_sandking
02-20-2008, 09:35 AM
Both times I got onto the hosts technical support live chat and my sites were back on-line within minutes and when I ask what happened they say in the future I must use mysql_connect because mysql_pconnect is disabled on the server...

So is this something that my hosts need to know should not and does not need disabling? I really can't fault their service and would not want to move to a new company.


This is a sure fire indication your beloved host is oversharing their servers, otherwise, there is no reason to disable persistent connections. If you are fine with paying a host that overshares their servers, then by all means stay where you are.

natural
02-20-2008, 10:02 AM
Hi all,

Thank you very much for the explanations...

I will speak to my hosts and see if I can get them to comply before I make a move to new server and host.

Clive

natural
02-23-2008, 03:03 AM
Hi all,

Below is the reply from my hosts about pconnect. Having just moved up to a PHP5 server in order to try to keep up with current changes I now find myself having to downgrade to PHP4 or move to a new host...

Before I make this step I would value anyone's opinion on the reply below.

Hello ,

The mysql_pconnect is defined as persistent connection to the database which affects the server performance.


mysql_pconnect() acts very much like mysql_connect() with two major differences.

First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection.

Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established by mysql_pconnect()).

All this leads to slow down the server performance since it uses high mysql resources.We do have one of our server where all those who want mysql_pconnect are hosted but this server has PHP 4 version.

Does it really slow the server down so much?

Thanks all

Clive

Mick
02-23-2008, 09:57 AM
Basically see Sandking's reply as it still applies:


This is a sure fire indication your beloved host is oversharing their servers, otherwise, there is no reason to disable persistent connections. If you are fine with paying a host that overshares their servers, then by all means stay where you are.

Persistent connections speed up your application. Anybody looking to run a quality, mission critical website should plan on being with decent enough of a host to allow their site to run as fast and reliably as possible.