Re: [PHP-DB] problem with pconnect
Hi Markus I assume you're using Apache with PHP installed as a DSO? If not ignore my ramblings... AFAIK, the persistent connections are per-process - i.e. each Apache process gets its own [set of] persistent processes. But when you connect to apache, you rarely get the same process as you got last time, so a few connections like that, and you end up creating a few persistent connections, one for each Apache process you hit. The benefits only become important when you increase the load... -- Shane On Tuesday 11 Dec 2001 3:39 pm, Markus Bruder wrote: > Hello all, > > I used to following test-script to analyze my problems with > sleeping-MySQL-pconnects: > > Script: > require ('database.php'); > $sql = "insert into ..."; > $res = query($sql); > echo "\">"; > ?> > > Required file (database.php): > function query($sql) > { > $hostname = ""; > $username = ""; > $password = ""; > $database = ""; > > $connect = mysql_pconnect("$hostname","$username","$password"); > mysql_select_db("$database",$connect); > $result = mysql_query($sql,$connect); > > return $connect; > } > ?> > > The first browser-connect opens up two processes, which are used every > time, the script reloads itself (rest of time 'Sleep'). > The second browser-connect opens up two processes, too. > And so on. > After ending this browser-connects, the processes are all in state 'Sleep'. > Next browser-connect doesn't re-use any of this processes - it opens up two > more. > > I thought (according to the php-manual) the pconnect-function would re-use > existing connections, but it doesn't. > > Does anybody know how to solve this problem? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] problem with pconnect
Hi, Check the description and the comments on www.php.net/manual/en/features.persistent-connections.php there is a very good explanation of this problem. The basic idea is that mysql_pconnect() will not reuse connections opened by different httpd processes. If you don't expect more than 100 concurrent connections stick to the mysql_connect function() Hope this helps Dobromir Velev Web Developer http://www.websitepulse.com/ -Original Message- From: Markus Bruder <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] <[EMAIL PROTECTED]> Date: Tuesday, December 11, 2001 18:04 Subject: [PHP-DB] problem with pconnect >Hello all, > >I used to following test-script to analyze my problems with >sleeping-MySQL-pconnects: > >Script: >require ('database.php'); >$sql = "insert into ..."; >$res = query($sql); >echo "\">"; >?> > >Required file (database.php): >function query($sql) > { > $hostname = ""; > $username = ""; > $password = ""; > $database = ""; > > $connect = mysql_pconnect("$hostname","$username","$password"); > mysql_select_db("$database",$connect); > $result = mysql_query($sql,$connect); > > return $connect; > } >?> > >The first browser-connect opens up two processes, which are used every time, >the script reloads itself (rest of time 'Sleep'). >The second browser-connect opens up two processes, too. >And so on. >After ending this browser-connects, the processes are all in state 'Sleep'. >Next browser-connect doesn't re-use any of this processes - it opens up two >more. > >I thought (according to the php-manual) the pconnect-function would re-use >existing connections, but it doesn't. > >Does anybody know how to solve this problem? > > > > > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]