[phpa] Re: Cached "static" PHP vs HTML

Hello,

Mark Rogers wrote:
> 
> Quick question:
> 
> Suppose I have a PHP script which is guaranteed to always generate the same
> output. That is, it contains no dynamic data, doesn't use sessions, no DB
> access or anything.
> 
> What sort of performance should I expect from PHPA compared with the two
> alternative extremes of PHP without a cache (the slowest) and the equivalent
> page as HTML served by Apache with no use of PHP?

I don't know with PHPA in particular, but static pages are much faster
to serve. Think about 3 times faster or more depending on what you do to
generate the pages, especially if the page content requires database
queries.


 
> I'm assuming that it's somewhere between the two, hopefully pretty close to
> the raw HTML end of trhe scale rather than the other end. Is that fair?

In most cases the PHP compilation that cache engines like PHPA speed up,
is not the most heavy factor. Database queries are more important to
optimize.

Anyway, making your content be served as static pages as opposed to run
with PHP with a cache engine, has another factor that is even more
important for scalability, that is memory consuption. Just by running
PHP you usually double memory usage (like maybe from 4MB to 8MB). When
you run a cache engine, it takes even more memory, often doubling again
the memory usage per server process.

This means that when your Web server is flooded, it will crash twice as
fast because crashes are usuaally due to memory exhaustion.


 
> (This is more a curiousity than anything else. The actual page is at
> www.stamfordtradefair.co.uk/exhibitors.php (it'll open frames around itself
> if you look at it). I'm using PHP because I have a bit of HTML which needs
> to be repeated for a whole load of companies which  are hard coded as an
> array into the PHP code. I could save the results as HTML and use that
> instead, but this is a freebie site for someone we're doing some other work
> for and I doubt it'll get the traffic to warrant it. It's just made me think
> about where the bottlenecks are and which ones phpa has removed. I'm
> guessing it's all outweighed by the size of the page at the end of the day
> anyway.)

I just did that in the PHP Classes site and I can tell you it was a
blessing well worthy of the time that was invested on rendering the site
non-personalized content as static pages.

Not only it saved me a lot of server CPU and memory usage, but also made
the internal search engine crawl the whole site pages much faster (from
several hours to just a few minutes).

Another side effect that was an intentional consequence is that now it
is possible and easy for me to let the site content be mirrored by many
other sites. You may want to take a look in any of these mirrors and see
that they serve the same non-personalized content to the users in a
transparent way. If the content was not rendered as static pages it
would be much more complicated to provide mirrors:

http://www.phpclasses.org/mirrors.html?closest=1

Regards,
Manuel Lemos
------------------------------------------------------------------------
  www.php-accelerator.co.uk           Home of the free PHP Accelerator

To post, send email to phpa@xxxxxxxxxxxxx
To unsubscribe, email phpa-request@xxxxxxxxxxxxx with subject unsubscribe


Other related posts: