views:

151

answers:

6

Hi all, basically i am launching a site soon and i predict ALOT of traffic. For scenarios sake, lets say i will have 1m uniques a day. The data will be static but i need to have includes aswell

I will only include a html page inside another html page, nothing dynamic (i have my reasons that i wont disclose to keep this simple)

My question is, performance wise what is faster

<!--#include virtual="page.htm" -->

or

<?php include 'page.htm'; ?>
A: 

Neither is really any faster than the other. The PHP include functions just give you more options with what you can do with the data and allows off-site includes, whereas SSI will simply include the page. If you're building a more advanced site, you should stick with the PHP include and require, otherwise it doesn't really matter, your preference I guess. There aren't really any speed tests or benchmarks anywhere on the web.

animuson
If only that were true: 'neither is really any faster than the other since they are both handled on the server-side'... Some quaint reasoning.
Wrikken
Dude, it completely depends on what you're using it for, and after researching a bit on Google most all of the answers I found were pretty much the same as mine. You don't know either so you don't have any reason to say mine is wrong.
animuson
Even if it's indifferent which one is faster, "since they are both handled on the server-side" is a poor justification.
Artefacto
Indeed a non-argument but let's leave it at that. No reason to start a real argument over it.
Wrikken
+3  A: 

Performance wise fastest is storing the templates elsewhere, generating the full HTML, and regenerate based on alterations in your template.

If you really want a comparison between PHP & SSI, I guess SSI is probably faster, and more important: not having PHP is a lot lighter on RAM needed on the webservers processes/threads, thereby enabling you to have more apache threads/processes to serve requests.

Wrikken
A: 

SSI is built in to Apache, while Apache has to spawn a PHP process to process .php files, so I would expect SSI to be somewhat faster and lighter.

I'll agree with the previous answer, though, that going the PHP route will give you more flexibility to change in the future.

Really, any speed difference that exists is likely to be insignificant in the big picture.

zerocrates
Spawn a PHP process? You've never used mod_php or FastCGI?
Bill Karwin
I'm not entirely sure why I was thinking in terms of vanilla CGI when I wrote this; I almost exclusively serve PHP with mod_php.
zerocrates
+1  A: 

Perhaps you should look into HipHop for php which compiles PHP into C++. Since C++ is compiled its way faster. Facebook uses it to reduce the load on their servers.

http://wiki.github.com/facebook/hiphop-php/

Greg Guida
Although this would only work if the user had access to their server roots, I like this answer. If my server wasn't configured with cPanel, I'd try this out. (The cPanel thing just makes me not want to bother with anything.)
animuson
@animuson: I would hope that a site that expects to get 1m uniques a day is not using a consumer-grade hosted site, but has access to configure software any way they need to on their own dedicated servers.
Bill Karwin
If your host has decent customer service you could probably get on the phone with them and have them install it for you. Especially if it means less load on their servers.
Greg Guida
A: 

I don't think anyone can answer this definitively for you. It depends on your web server configuration, operating system and filesystem choices, complexity of your SSI usage, other competing processes on your server, etc.

You should put together some sample files and run tests on the server you intend to deploy on. Use some http testing tools such as ab or siege or httperf or jmeter to generate some load and compare the two approaches. That's the best way to get an answer that's correct for your environment.

Using PHP with mod_php and an opcode cache like APC might be very quick because it would cache high-demand files automatically. If you turn off apc.stat it won't have to hit the disk at all to serve the PHP script (with the caveat that this makes it harder to update the PHP script on a running system).

You should also make sure you follow other high-scalability best practices. Use a CDN for static resources, optimize your scripts and stylesheets, etc. Get books by Steve Souders and Theo & George Schlossnagle and read them cover to cover.

Bill Karwin
A: 

I suggest you use a web cache like Squid or, for something more sophisticated, Oracle Web Cache.

Artefacto