SSI or PHP Include()?

霸气de小男生 提交于 2020-01-01 08:48:19

问题


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'; ?>

回答1:


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.




回答2:


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.




回答3:


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.

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




回答4:


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.




回答5:


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



来源:https://stackoverflow.com/questions/2993858/ssi-or-php-include

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!