Re: [PHP] Whats more efficient? (Conclusion)
On Wed, 22 Oct 2003, Ryan A wrote: > what do you suggest? and any urls for reading up on caching? Some benchmarks on content and bytecode caching: http://www.appelsiini.net/~tuupola/articles/benchmarking-phpa/ -- 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] Whats more efficient? (Conclusion)
* Thus wrote Ryan A ([EMAIL PROTECTED]): > Hey Curt, Hey ryan! I put this back on the list in case people were ever so curious of the system I use. > > /* > In most cases a document has a top, left, content and bottom. And > in standard conditions the top and left should be sent before the > content is processed (which tends to take the longest to process). > That way the page appears to load much quicker, than sitting there > waiting for the website to respond with content while php is > gathering all the html to send. > */ > > How do you do that and what engine are you using? Smarty or something > differient? Actually i'm not using a template engine per se. I'm looking right now for a template engine that can do that. I havn't yet looked at smarty but I am hoping that it has those capabilities. What I DO do though, with my site that I have in my sig below . Is Basically I have one controlling file called 'html' (I set apache to run html as a php file in apache) and its logic goes something like this: I split the parts in the uri after the html into an array of items so the uri: /html/php/code/xtpl/ turns into: $parts = array ('php', 'code', 'xtpl'); So then what 'html' does is look at the first item in the list which happens to by 'php' in this case. It then includes a file from a file defined file structure called php.conf. php.conf decides a certain couple things. Like are we going to send out html, text, authentication or just redirect someplace. It Also sets variables like the page title and the like. if php.conf returns successfully 'html' now goes through and includes some common files like 'doctype.php, header.php, top.php leftside.php' And sends those to the browser. And when that is done, 'html' now includes the file 'php.php' (the first php in the filename is based off of $parts[0]). This is the muscle of the content area (in this case the php area) and does everything inside that area. using the $parts and query_string to determain what it needs to do. And finally 'html' sends out the bottom.php and footer.php /html/php aka php.php.. uses and old method of outputing stuff. It echo's all the content to the browser ..while.. /html/mlists aka mlists.php.. uses a templating system to generate the html. Which can be found in 'code' section under xtpl Nothing on this site is really production level, It is mainly a place I toy around with my ideas and stuff. HTH even the slightest bit :) Curt -- "My PHP key is worn out" PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? (Conclusion)
--- Ryan A <[EMAIL PROTECTED]> wrote: > My main pages are basically querying the databases for hosting plans > depending on what the client chooses > what do you suggest? and any urls for reading up on caching? Caching is a generic term, so it's tough to search for documentation about a specific type of caching. The type I am referring to is a lot like how Slashdot works. Imagine if they queried the database and generated every single page (with mod_perl) for every single request. That would take a lot of resources to sustain, right? But, they only have a handful of servers. Most of their popular content (like the front page) are generated on the server at regular intervals, not at request time. So, when you request the front page, you get a static document, even though the content is dynamic. This is why you will notice a slight delay in refreshes (number of posts, etc.). This is a good way to take control of the load on your server. If you generate a page once per minute, that page will only be generated 525,600 times (I enjoyed Rent, if you're wondering if I calculated that). Compare this to millions of generations a day, and you can see how you can significantly reduce the amount of resources you need. The site I currently operate gets 10 million hits a day, which works out to about 3.5 billion hits a year. So, I could generate content once a second, and it would still be better than doing it once per request. That wasn't the greatest explanation, but hopefully you get the idea. Chris = My Blog http://shiflett.org/ HTTP Developer's Handbook http://httphandbook.org/ RAMP Training Courses http://www.nyphp.org/ramp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? (Conclusion)
* Thus wrote Chris Shiflett ([EMAIL PROTECTED]): > --- Ryan A <[EMAIL PROTECTED]> wrote: > > Just one last question, you guys can reply to this off list or on: > > does using a templating engine slow down pages a lot (as i have > > heard) or increase speed (as i have heard again) ? :-D > > Things like Smarty are slow in terms of performance alone, yes. The tradeoff is > that the design these solutions allow might make life easier for the > developers. > > If your applications are serving ten million requests a day, Smarty is going to > be problematic, but you can still overcome this with some good server-side > caching (for example, is it necessary to dynamically generate a response for > every request if the data isn't very volatile?). (more i do things like...) I usually set up a minimum of 3-4 levels of caching: . regular document, only regenerate when last modified. (much easier if apache handles this) . Session lifetime. Things that change specifically to a session. Like last-login: . Per visit. although harder to detect, things like page counters. . per request. Usually this level means no caching but in certain cases this can fine tune performance under heavy loads. So when I set up a page I'll assign it a different cache level for it and generate a fresh copy depending on the level and all the rules I set up for the level. Curt -- "My PHP key is worn out" PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Whats more efficient? (Conclusion)
What I find easy to do, Is have the top, left in a file, say we call it header.php And have the bottom html in a page called footer.php Both pages mainly contain html exept if php is required. Many sites / database the top, left is html code and never changes, There is no need to place this inside php, there is no need to slow down the engine Advantages of this is that it is kind of like a template, where you could change the header, and it take effect site wide, as well as been able to change the view by having multiple headers for people to choose their own. Hope that made sense -- Chris Kay (CK) Eleet Internet Services M: 0415 451 372 P: 02 4620 5076 F: 02 4620 7008 E: [EMAIL PROTECTED] -Original Message- From: Ryan A [mailto:[EMAIL PROTECTED] Sent: Wednesday, 22 October 2003 1:28 PM To: Chris Shiflett Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Whats more efficient? (Conclusion) Hey, thanks for replying. /* ...but you can still overcome this with some good server-side caching (for example, is it necessary to dynamically generate a response for every request if the data isn't very volatile?). */ My main pages are basically querying the databases for hosting plans depending on what the client chooses what do you suggest? and any urls for reading up on caching? Thanks, -Ryan -- 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] Whats more efficient? (Conclusion)
On Tue, 2003-10-21 at 23:12, Ryan A wrote: > Hey all, > > Thanks for clearing up my little doubt, I wanted to know if there was a > major differience. > > John, thanks for the reply and I know it makes sense (like all your replies) > but I just kind of got my feet wet with php > and getting to the interesting stuff, learning while i go along of course. > > I dont think I can take trying to learn a who new templating > language/package while doing this because I hear > some of them (eg smarty) can be quite tricky sometimes for the > beginner...and I get enough PHP errors so dont want to add templating errors > to that :-) > > Just one last question, you guys can reply to this off list or on: > does using a templating engine slow down pages a lot (as i have heard) or > increase speed (as i have heard again) ? :-D TemplateJinn (part of InterJinn :) is a compiling template engine. You can run it from the command line (or via a compile page) to generate your site, in which case there is no overhead whatsoever since the output is embedded PHP in content. The other style is to have it automatically compile missing files that have yet to be compiled, or compile updates -- this has a small overhead while it checks dependencies at page load time. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? (Conclusion)
Hey, thanks for replying. /* ...but you can still overcome this with some good server-side caching (for example, is it necessary to dynamically generate a response for every request if the data isn't very volatile?). */ My main pages are basically querying the databases for hosting plans depending on what the client chooses what do you suggest? and any urls for reading up on caching? Thanks, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? (Conclusion)
* Thus wrote Ryan A ([EMAIL PROTECTED]): > Hey all, > > Just one last question, you guys can reply to this off list or on: > does using a templating engine slow down pages a lot (as i have heard) or > increase speed (as i have heard again) ? :-D One thing I always try to avoid is having the template engine buffer everything while processing all the data from start to finish. In most cases a document has a top, left, content and bottom. And in standard conditions the top and left should be sent before the content is processed (which tends to take the longest to process). That way the page appears to load much quicker, than sitting there waiting for the website to respond with content while php is gathering all the html to send. Curt -- "My PHP key is worn out" PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? (Conclusion)
--- Ryan A <[EMAIL PROTECTED]> wrote: > Just one last question, you guys can reply to this off list or on: > does using a templating engine slow down pages a lot (as i have > heard) or increase speed (as i have heard again) ? :-D Things like Smarty are slow in terms of performance alone, yes. The tradeoff is that the design these solutions allow might make life easier for the developers. If your applications are serving ten million requests a day, Smarty is going to be problematic, but you can still overcome this with some good server-side caching (for example, is it necessary to dynamically generate a response for every request if the data isn't very volatile?). Chris = My Blog http://shiflett.org/ HTTP Developer's Handbook http://httphandbook.org/ RAMP Training Courses http://www.nyphp.org/ramp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? (Conclusion)
Ryan A wrote: Just one last question, you guys can reply to this off list or on: does using a templating engine slow down pages a lot (as i have heard) or increase speed (as i have heard again) ? :-D Depends upon your application and the templating engine. Many options either way. In my cases, the benefit is easier code to maintain with no noticable slowdown. Good trade off for me. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? (Conclusion)
Hey all, Thanks for clearing up my little doubt, I wanted to know if there was a major differience. John, thanks for the reply and I know it makes sense (like all your replies) but I just kind of got my feet wet with php and getting to the interesting stuff, learning while i go along of course. I dont think I can take trying to learn a who new templating language/package while doing this because I hear some of them (eg smarty) can be quite tricky sometimes for the beginner...and I get enough PHP errors so dont want to add templating errors to that :-) Just one last question, you guys can reply to this off list or on: does using a templating engine slow down pages a lot (as i have heard) or increase speed (as i have heard again) ? :-D Cheers, -Ryan Chris Shiflett wrote: > --- "John W. Holmes" <[EMAIL PROTECTED]> wrote: > >>Use a template engine to separate your presentation from your logic. :) > > > Isn't PHP a templating engine? :-) Of course it is, but what's that got to do with separating presentation from logic (business logic)? Each one can be PHP code... :) Bad answer, I know, because his code could be a PHP "template". I'm sure it's not, though. I just wanted to give a different answer from the many "it doesn't matter" answers. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals - www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php