Re: [PHP] Persistent Database Connections

2005-05-02 Thread Jochem Maas
Michael Phillipson wrote:
[Please note that even though I cite Interbase in my example, I believe my 
question can be generalized to all databases that allow persistent 
connections]

I recently installed a trial version of Interbase on a development server 
firebird-loon
have you tried the free trial version of Firebird, with the added bonus that
its not a trial... and has a cooler name :-/
/firebird-loon
that includes a nifty tool that allows me to monitor, among other things, 
...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Persistent Database Connections

2005-04-26 Thread Michael Phillipson
Thanks, Philip (and Richard also), for offering your impressions.

Per Philip's suggestion, I ran ab (Apache Benchmark) to stress test the 
page that loads my persistent connection.  Depending on the parameters I set 
for ab, I was able to increase the number of connections from my initial 9 
to anywhere between 15 and 25.  This number varied from one test to 
another - even if I left the ab parameters the same.  I probably could have 
boosted the total connections even further by raising the number of 
connections/requests initiated by ab.

So, while I still don't have a rock-solid way to predict just how many 
connections will be opened for a given number of users, at least I'm not 
stuck at 9 :-)  I guess it took using an automated approach to simulating 
server load (e.g., ab) to force Apache to open additional connections to 
the database.

Interestingly, I also observed during my testing that some connections 
opened by Apache were subsequently closed.  So, this seems to answer my 
other question re. whether persistent connections stay open forever.  I 
guess they don't.  What seems clear is that Apache decides when to terminate 
active connections, not the database.

Thanks again.

Mike

Philip Hallstrom [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 What I am baffled by is the fact that the total nunber of connections
 between the web server and my database seems to max out at 9.  Why 9? 
 Not
 that I have a problem with this number.  I just want to understand how 
 this
 limit was reached so that I might predict how the application will 
 perform
 in a production capacity.

 I can't think of a reason it would max out at 9 other than perhaps you 
 really don't have more than 9 connections open.  My understanding is that 
 Apache will open a connection per child, per database connection where a 
 connection is made up of the host, user, and database.

 How many apache processes are running when you take this measurement? 
 There's no gaurantee that each of them will have hit your web app and 
 start up there own connection.

 You might use something like ab (apache benchmark) to hit a page that 
 initiates a persistent connection to see what happens as the number of 
 apache processes grows. 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Persistent Database Connections

2005-04-25 Thread Philip Hallstrom
I recently installed a trial version of Interbase on a development server
that includes a nifty tool that allows me to monitor, among other things,
the number of active connections to my server.  After playing with this
feature briefly, I noticed that SEVERAL connections are opened between my
web server and the database.  At first, I thought this was a little weird
because I use the ibase_pconnect() function to establish communication with
my database, and I expected to see only 1 connection.  However, after doing
some reading, I discovered that this behavior is probably by design - the
result of Apache spawning several child processes, each one establishing its
own persistent connection(s) to the database.
What I am baffled by is the fact that the total nunber of connections
between the web server and my database seems to max out at 9.  Why 9?  Not
that I have a problem with this number.  I just want to understand how this
limit was reached so that I might predict how the application will perform
in a production capacity.
I can't think of a reason it would max out at 9 other than perhaps you 
really don't have more than 9 connections open.  My understanding is that 
Apache will open a connection per child, per database connection where a 
connection is made up of the host, user, and database.

How many apache processes are running when you take this measurement? 
There's no gaurantee that each of them will have hit your web app and 
start up there own connection.

You might use something like ab (apache benchmark) to hit a page that 
initiates a persistent connection to see what happens as the number of 
apache processes grows.

I have checked my Apache config (httpd.conf) file, and as far as I can tell,
the maximum number of child processes is set to 20.  So again I ask: why
does the number of connections max out at 9?  Shouldn't they max out at 20
or 21 (1 parent + 20 children)?
Not necessarily (see above).  It could very well be that for 20 children 
you could have *more* than that number of connections if your web pages 
connect to multiple databases...

And finally, I have noticed that the connections, once established, NEVER
expire.  I realize that this is sort of the point with persistent
connections, but I was curious whether persistent connections are ever
terminated or recycled.
I don't think so.  I suppose the database could kill lingering 
connections... I don't know about that.

What I've done in the past is to set the number of requests each apache 
child is allowed to serve to some number that will be reached on some 
reasonable frequency.  Then it closes that child which closes the 
connections...

Any explanations/impressions would be appreciated.
Mike
FYI... My php.ini file is set to allow unlimited connections/unlimited
persistent connections.  Also, the trial license of the database I am
testing claims to be limited to 1 client, and the only client accessing the
database is my web app.  Just thought I'd mention that as I don't think the
number of connections has any direct correlation to the client license.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Persistent Database Connections

2005-04-25 Thread Richard Lynch
On Mon, April 25, 2005 1:40 pm, Michael Phillipson said:
 What I am baffled by is the fact that the total nunber of connections
 between the web server and my database seems to max out at 9.  Why 9?

Either you never had more than 9 users at one time during your test, so
only 9 Apache children actually had to do any work, and the rest just laid
around doing nothing, or...

You may have configured Interbase (no idea how) to only allow 9
connections, or

The trial version of Interbase may limit you to 9 (or 10) connections.

If you also had, say, some kind of shell Interbase monitor program going,
or some kind of other application with a connection, that would have been
your 10th connection.

If this were MySQL, I'd tell you to look at your /etc/my.cnf file, or to
create one, and to make sure your limit on the number of connections is
*HIGHER* than the number of Children you allow in httpd.conf

Othewise, sooner or later, your server gets busy, and BAM! you've hit a
wal where Apache *wants* a MySQL connection, but MySQL won't give it one,
and your user gets some nasty error message about it, or, if you are
re-directing the errors, the page just plain doesn't work the way they
want, or...  Exactly what happens depends on your error settings and error
handling, and how good your code is at detecting error conditions.

You want the MySQL limit *HIGHER* than the Children, so that if all hell
breaks loose, *YOU* can use the mysql monitor from the shell command line
to log in and do admin tasks, yay even unto mysqladmin -u root -p stop

You don't want to get caught where your site is *SO* busy you can't even
get that to work. :-^

Interbase presumably has similar features, but I cannot say for certain.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Persistent database connections in PHP

2003-09-05 Thread Cody Phanekham
do people even look at the manual? or search the php.net website?

http://au2.php.net/manual/en/ref.mysql.php

Runtime Configuration
The behaviour of these functions is affected by settings in php.ini. 

Here's a short explanation of the configuration directives.

mysql.allow_persistent boolean
Whether to allow persistent connections to MySQL.

so if you installed PHP without modifying the ini file, all your connections should be 
persistent


  -Mensaje original-
  De: Shivanischal [mailto:[EMAIL PROTECTED]
  Enviado el: Viernes, 05 de Septiembre de 2003 01:05 a.m.
  Para: [EMAIL PROTECTED]
  Asunto: [PHP] Persistent database connections in PHP
  
  Hi friends,
  
  I wanted help on how to achieve persistent database connections in
 PHP.
  The
  database i use is MySQL. I would be grateful if u could 
 also guide me
 to
  resources that tell me how to do it.
  
  Thanks,
  -shiva
  
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


*
This e-mail, including any attachments to it, may contain confidential and/or personal 
information.
If you have received this e-mail in error, you must not copy, distribute, or disclose 
it, use or take any action 
based on the information contained within it.

Please notify the sender immediately by return e-mail of the error and then delete the 
original e-mail.

The information contained within this e-mail may be solely the opinion of the sender 
and may not necessarily 
reflect the position, beliefs or opinions of Salmat on any issue.

This email has been swept for the presence of computer viruses known to Salmat's 
anti-virus systems.

For more information, visit our website at  www.salmat.com.au.
*

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Persistent database connections in PHP

2003-09-05 Thread Cody Phanekham
ooppss forgot this as well...

http://au2.php.net/mysql_pconnect

 -Original Message-
 From: Cody Phanekham 
 Sent: Friday, 5 September 2003 16:06
 To: [EMAIL PROTECTED]
 Subject: RE: [PHP] Persistent database connections in PHP
 
 
 do people even look at the manual? or search the php.net website?
 
 http://au2.php.net/manual/en/ref.mysql.php
 
 Runtime Configuration
 The behaviour of these functions is affected by settings in php.ini. 
 
 Here's a short explanation of the configuration directives.
 
 mysql.allow_persistent boolean
 Whether to allow persistent connections to MySQL.
 
 so if you installed PHP without modifying the ini file, all 
 your connections should be persistent
 
 
   -Mensaje original-
   De: Shivanischal [mailto:[EMAIL PROTECTED]
   Enviado el: Viernes, 05 de Septiembre de 2003 01:05 a.m.
   Para: [EMAIL PROTECTED]
   Asunto: [PHP] Persistent database connections in PHP
   
   Hi friends,
   
   I wanted help on how to achieve persistent database connections in
  PHP.
   The
   database i use is MySQL. I would be grateful if u could 
  also guide me
  to
   resources that tell me how to do it.
   
   Thanks,
   -shiva
   
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
 
 **
 ***
 This e-mail, including any attachments to it, may contain 
 confidential and/or personal information.
 If you have received this e-mail in error, you must not copy, 
 distribute, or disclose it, use or take any action 
 based on the information contained within it.
 
 Please notify the sender immediately by return e-mail of the 
 error and then delete the original e-mail.
 
 The information contained within this e-mail may be solely 
 the opinion of the sender and may not necessarily 
 reflect the position, beliefs or opinions of Salmat on any issue.
 
 This email has been swept for the presence of computer 
 viruses known to Salmat's anti-virus systems.
 
 For more information, visit our website at  www.salmat.com.au.
 **
 ***
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Persistent database connections in PHP

2003-09-05 Thread murugesan
Just use the same header.
and in the next page use
body onload=window.open(yourpage)
...

Murugesan

- Original Message - 
From: Cesar Aracena [EMAIL PROTECTED]
To: 'Shivanischal' [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Friday, September 05, 2003 11:27 AM
Subject: RE: [PHP] Persistent database connections in PHP


 I haven't heard of persistent connections with MySQL before, and I think
 is because PHP can't handle it. PHP will connect to the DB every time it
 has to. Are you really that annoyed for that 0.0003 second that it
 probably takes your pages to connect to the DB?
 
 What I do to manage just ONE connection request per visitor, is request
 a mainfile.php which also declares a function that connects to the DB.
 After that is prepared to handle all the queries you want.
 
 HTH,
 
 Cesar Aracena
 www.icaam.com.ar
 
  -Mensaje original-
  De: Shivanischal [mailto:[EMAIL PROTECTED]
  Enviado el: Viernes, 05 de Septiembre de 2003 01:05 a.m.
  Para: [EMAIL PROTECTED]
  Asunto: [PHP] Persistent database connections in PHP
  
  Hi friends,
  
  I wanted help on how to achieve persistent database connections in
 PHP.
  The
  database i use is MySQL. I would be grateful if u could also guide me
 to
  resources that tell me how to do it.
  
  Thanks,
  -shiva
  
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Persistent database connections in PHP

2003-09-05 Thread Mika Tuupola
On Fri, 5 Sep 2003, Shivanischal wrote:

 I wanted help on how to achieve persistent database connections in PHP. The
 database i use is MySQL. I would be grateful if u could also guide me to
 resources that tell me how to do it.

http://www.php.net/manual/en/function.mysql-pconnect.php

-- 
Mika Tuupola  http://www.appelsiini.net/~tuupola/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Persistent database connections in PHP

2003-09-04 Thread Cesar Aracena
I haven't heard of persistent connections with MySQL before, and I think
is because PHP can't handle it. PHP will connect to the DB every time it
has to. Are you really that annoyed for that 0.0003 second that it
probably takes your pages to connect to the DB?

What I do to manage just ONE connection request per visitor, is request
a mainfile.php which also declares a function that connects to the DB.
After that is prepared to handle all the queries you want.

HTH,

Cesar Aracena
www.icaam.com.ar

 -Mensaje original-
 De: Shivanischal [mailto:[EMAIL PROTECTED]
 Enviado el: Viernes, 05 de Septiembre de 2003 01:05 a.m.
 Para: [EMAIL PROTECTED]
 Asunto: [PHP] Persistent database connections in PHP
 
 Hi friends,
 
 I wanted help on how to achieve persistent database connections in
PHP.
 The
 database i use is MySQL. I would be grateful if u could also guide me
to
 resources that tell me how to do it.
 
 Thanks,
 -shiva
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php