Layne Weathers wrote:
>
> >> We are using PHPLib on multiple production servers each with multiple
> >> PHPLib-based sites, along with PHP (no PHPLib) and static sites. We
> >> had to change the mysql_pconnect() call in db_mysql.inc to
> >> mysql_connect() long ago to preserve resources in our environment.
> >
> > I also have to make this change on my server. Otherwise I finish up
> > with 40 mysql processes eating all my RAM.
The first solution is to lower the wait_timeout value in safe_mysqld.
The default is 28800 secs (8h) Otherwise you have an idle connection
between each apache child and mysql, that lives up to 8 hours. That
should go down to 120-180 secs, the time of visiting a couple pages.
See the comments too the manual page by Sasha of Mysql
http://www.php.net/manual/en/function.mysql-pconnect.php
Otherwise disable persistent connection all-the-way at php.ini level
(mysql.allow_persistent=Off), and mysql_pconnct continues to wors as a
standard mysql_connect
Gian
> >
> > I think changing the default is justified. Anyone using PHPLIB on a
> > busy dedicated server probably knows enough to change it back.
>
> Here is my proposition - use an instance variable to toggle between connect
> and pconnect allowing users to make the change at the local.inc level rather
> than the db_mysql.inc level. Any problems with this?
>
> In db_mysql.inc I'd add:
>
> var $PConnect = 0; ## Set to 1 to use mysql_pconnect instead of
> mysql_connect
>
> and in connect():
>
> if(!$this->PConnect) {
> $this->Link_ID = mysql_connect($Host, $User, $Password);
> } else {
> $this->Link_ID = mysql_pconnect($Host, $User, $Password);
> }
>
> Layne Weathers
> Ifworld Inc.
>
> _______________________________________________
> Phplib-core mailing list
> Php...@li...
> https://lists.sourceforge.net/lists/listinfo/phplib-core
|