简体   繁体   English

SSI或PHP包含()?

[英]SSI or PHP Include()?

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. 为方案而言,假设我每天会有1米独立。 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) 我只会在另一个html页面中包含一个html页面,没有任何动态(我有我的理由,我不会透露这么简单)

My question is, performance wise what is faster 我的问题是,表现明智更快

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

or 要么

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

Performance wise fastest is storing the templates elsewhere, generating the full HTML, and regenerate based on alterations in your template. 性能最快的是将模板存储在其他位置,生成完整的HTML,并根据模板中的更改进行重新生成。

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. 如果你真的想要在PHP和SSI之间进行比较,我猜SSI可能更快,更重要的是:没有PHP在Web服务器进程/线程上需要更少的RAM,从而使你能够拥有更多的apache线程/进程服务请求。

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. SSI内置于Apache,而Apache必须生成一个PHP进程来处理.php文件,所以我希望SSI更快更轻。

I'll agree with the previous answer, though, that going the PHP route will give you more flexibility to change in the future. 我同意之前的回答,即PHP路由将为您提供更大的灵活性,以便将来进行更改。

Really, any speed difference that exists is likely to be insignificant in the big picture. 实际上,存在的任何速度差异在大局中可能都是微不足道的。

Perhaps you should look into HipHop for php which compiles PHP into C++. 也许你应该研究一下将PHP编译成C ++的PHP的HipHop。 Since C++ is compiled its way faster. 因为C ++的编译方式更快。 Facebook uses it to reduce the load on their servers. Facebook使用它来减少服务器的负担。

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

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. 这取决于您的Web服务器配置,操作系统和文件系统选择,SSI使用的复杂性,服务器上的其他竞争进程等。

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. 使用一些http测试工具(如absiegehttperfjmeter)来生成一些负载并比较这两种方法。 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. 将PHP与mod_php和像APC这样的操作码缓存一起使用可能会非常快,因为它会自动缓存高需求文件。 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). 如果关闭apc.stat它根本不必点击磁盘来提供PHP脚本(需要注意的是,这使得在运行的系统上更新PHP脚本变得更加困难)。

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. 使用CDN获取静态资源,优化脚本和样式表等。获取Steve SoudersTheoGeorge Schlossnagle的书籍并阅读封面封面。

我建议您使用像Squid这样的Web缓存,或者使用更复杂的Oracle Web Cache

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM