Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spawning PHP instances

Status
Not open for further replies.

alphacooler

Programmer
Aug 29, 2005
73
US
So I am pretty new to php. I've picked up quite a bit but I'd like to know a little about performance.

I've heard people mention "spawning a lot of instance of PHP puts a load on the server". Well what exactly causes an instance of php to start?

Instead of echo'ing out a bunch of html, does jumping in and out of PHP on a page (<?php ?> html <?php ?>) kill resources?

Anything else I should be cautious of? I've got a pretty huge userbase on my site (a few thousand people on at any given moment).

Thanks!
 
if php is installed as a cgi, the executable gets called at each page request/script instance.

if as a SAPI then there i understand the memory handling is better but i'd guess that still each request is given a separate thread.

whether the load is too big for your hardware depends on
+ what these 1000s of users are doing on your site at any one time. ie. what scripts they will be calling on your site.
+ how much memory you have installed
+ what operating system you use
+ what other apps and server processes you are running on the hardware
+ what logging you use
+ whether your scripts are well designed (optimised)
+ what processor(s) you are using
+ (to a lesser extent) the speed of components such as your disk array

if you're worried about loading you should be running stress tests on your environment before deploying.

but ... if you're asking these kinds of questions and you've really got 1000s of users actively interacting with your site at any one time, it sounds as though success has caught you red-handed and it's time to invest in a top quality CTO to manage your infrastructure.

as for different styles of quoting. there is a very good article on the net (i can't find it at present) written by a bloke who did extensive testing of the different types of quoting. invariably using single quotes and concatenators came out quickest. Despite knowing this I still use heredoc for large quantities of html with few variables or, if i am in a templating system, i either use placeholders in the html with str_replace or (more often) short tags that are embedded in the template. To my mind the inherent latency of the web (and the really poor performance of most home ADSL routers) far outweighs the minor performance impact of a slightly sloppy coding style that, nevertheless, lends itself rather well to RAD and later readability. I know that there are those that disagree though!
 
Anyone else have any points on this subject? It would be much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top