Go Back   HostGator Peer Support Forums > Public Forums > Suggestions

Notices

Reply
 
Thread Tools
  #1  
Old 12-01-2005, 05:12 AM
twisty twisty is offline
Baby Croc
 
Join Date: Nov 2005
Posts: 50
Default Persistent Connections

IMHO, it would probably save both support and customers much grief (ie. max connections errors, suspended accounts) by disabling persistent connections altogether in PHP.INI (especially if 25 concurrent is the max which is on the low side)

mysql.allow_persistent Off

This way, even if the customers' software has persistent enabled, this directive will automatically and seamlessly switch it to mysql_connect without having to modify scripts or configurations on the user side.

It'll be a win-win situation for everyone
Reply With Quote
  #2  
Old 12-01-2005, 07:10 PM
Serra's Avatar
Serra Serra is offline
Veteran Croc
 
Join Date: Feb 2005
Location: Orange Park, FL
Posts: 5,073
Default Re: Persistent Connections

Sounds nice, but what about people who NEED persistent connections?
Reply With Quote
  #3  
Old 12-01-2005, 08:44 PM
twisty twisty is offline
Baby Croc
 
Join Date: Nov 2005
Posts: 50
Default Re: Persistent Connections

Quote:
Originally Posted by Serra
Sounds nice, but what about people who NEED persistent connections?
Under what circumstance would someone absolutely need it? I don't know of any myself

Actually, many shared hosts disable it outright because it causes A LOT of unnecessary problems with server resources.

Dedicated servers, ok now that's a different story. If anything goes wrong then at least it won't affect other customers
Reply With Quote
  #4  
Old 12-01-2005, 10:23 PM
Serra's Avatar
Serra Serra is offline
Veteran Croc
 
Join Date: Feb 2005
Location: Orange Park, FL
Posts: 5,073
Default Re: Persistent Connections

Oddly, you would use a persistent connection to reduce server load. Opening and closing connections puts a heavy load on mySQL/PHP. So a script that needed to read and write a lot to a database using mysql_connect() instead of mysql_pconnect() would greatly increase the server load as it opened and closed the connection many times.

Of course, if the mysql_pconnect() is used and sits idle it burns processor juice too, so that is why they don't want anyone using mysql_pconnect(). Correctly used, mysql_pconnect() is really a good thing in some cases.



Neat! A way to handle the "too many connections" thing:
http://dev.mysql.com/doc/refman/5.0/...nnections.html
Reply With Quote
  #5  
Old 12-02-2005, 08:09 AM
twisty twisty is offline
Baby Croc
 
Join Date: Nov 2005
Posts: 50
Default Re: Persistent Connections

Quote:
Originally Posted by Serra
Correctly used, mysql_pconnect() is really a good thing in some cases.
I guess what I'm trying to say is that pconnect really has no place on a typical shared host server where mysql is on localhost - reconnects are very fast & efficient, and the overhead is minimal in that situation.

Furthermore, the default apache config is not set up to correctly deal with it. A lot of fine-tuning and tweaking is needed to make it work properly even when it may be a good idea to use it. Especially the MaxRequestsPerChild setting which defaults to 0 (unlimited).

Otherwise runaway scripts / child processes cause all sorts of havoc with load and memory.

Btw the new mysqli extension in PHP 5 has dropped support for persistent
connections alltogether.

Last edited by twisty; 12-02-2005 at 08:24 AM.
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 09:55 PM.