RE: [php-objects] destructors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a message I sent to another PHP group (or maybe this one) a
few days ago copied and pasted here. Someone had asked when one should use
persistent connections, and my answer follows.

The short answer is "if you're unsure, don't use persistent
connections." The (minor) benefit that persistent connections give you is
that each child process that tries to open a connection to your DBMS only
needs to do it once. This is only an issue if it takes a really long time to
connect to your DBMS (say, 15 minutes). Instead of waiting 15 minutes each
time your script loads, you only have to wait 15 minutes the first time, and
then the connection is already established every time after that that your
script is loaded.

However, connections are only seen on a per-process basis, so if
you're running Apache with 500 child processes, you may have 500 connections
to your database open simultaneously, even if only 1 or 2 users are
currently browsing your site. Plus, if your DBMS has a limit on the number
of connections it can handle (say, 16), then only 16 out of 500 of your
users (pretty much based on random luck) will be able to actually use your
site. Further more, if you don't know how to release locks that you've
acquire on tables (most of SQL's transaction protocols automatically lock
tables that you try to write to, to make sure no other transactions are
reading from the table at the same time you're writing to it), then those
locks might never be released, so that only 1 person (the first person who
visits your site) can use your site, and everyone else will have the server
hang in deadlock, eternally waiting for that lock to be released so that it
can access the data.

So the final answer is "if you're unsure, don't use persistent
connections."

- Nebu


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Save up to 80% on top-quality inkjet cartridges and get your order fast!
FREE shipping on orders $50 or more to the US & Canada. Shop at Myinks.com!
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/v2G7ND/KfUGAA/ySSFAA/saFolB/TM
---------------------------------------------------------------------~->

Look here for Free PHP Classes of objects:
http://phpclasses.UpperDesign.com/
To unsubscribe from this group, send an email to:
php-objects-unsubscribe@egroups.com

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux