Re: Why persistent connection ?

From: Date: Fri, 07 Jul 2000 01:56:51 +0000
Subject: Re: Why persistent connection ?
Groups: php.db 
Request: Send a blank email to php-db+get-922@lists.php.net to get a copy of this message
Addressed to: Steve Lewis <nepolon@worlddomination.net> php-db@lists.php.net ** Reply to note from Steve Lewis <nepolon@worlddomination.net> Thu, 6 Jul 2000 12:43:39 -0700 (PDT) > > From: Chris Adams <chris@digitaria.com> > > >Yes, you'll need the pconnect call on each page. The pconnect function > >should behave identically to the regular connect function except that if > >a connection is already open, it will reuse that connection instead of > >opening a new one. > > Perhaps you can explain what I am doing wrong then? I was calling the > pconnect function exclusively, and to my surprise I discovered that in > a few hours of devleoping/testing I had about 23 conections to MySQL > open on my LAMP setup. Only 23 connections. You are probably not doing anything wrong. Max Number of Connections = Number of Apache Child Processes * Number of different username/password/hostname combinations in use. It is possible for every Apache child process to have every possible username/password/hostname open, and it is not possible to predict which child will get which request, so there is nothing to do but keep them all open. Or close them at random, and take the performance hit if you have to re-open it again. See mysql.max_persistent in the Configuration section of the manual. Just throw lots of ram at your database server, and kick up the number of MySQL connections. The sleeping processes don't use CPU time, just memory, and if they stay in RAM it will be fast. If you can't create enough MySQL processes, you either need to reduce the number of different logins, the number of Apache childred, or not use pconnect. Rick Widmer Internet Marketing Specialists www.developersdesk.com

« previous php.db (#922) next »