SSI 还是 PHP Include()?

发布于 2024-09-04 10:34:14 字数 295 浏览 5 评论 0原文

基本上我很快就会推出一个网站,我预计会有很多流量。就场景而言,假设我每天会有 100 万个独立用户。数据将是静态的,但我也需要包含

我只会在另一个 html 页面中包含一个 html 页面,没有动态(我有我的理由,我不会透露以保持简单)

我的问题是,性能方面哪个更快

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

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

携君以终年 2024-09-11 10:34:14

性能方面最快的方法是将模板存储在其他地方,生成完整的 HTML,并根据模板中的更改重新生成。

如果你真的想比较 PHP 和 PHP 之间的差异, SSI,我想 SSI 可能更快,而且更重要:没有 PHP 可以减轻网络服务器进程/线程所需的 RAM,从而使您能够拥有更多的 apache 线程/进程来服务请求。

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.

又爬满兰若 2024-09-11 10:34:14

SSI 内置于 Apache 中,而 Apache 必须生成 PHP 进程来处理 .php 文件,因此我希望 SSI 更快、更轻。

不过,我同意之前的答案,即采用 PHP 路线将为您在未来的更改提供更大的灵活性。

事实上,从整体来看,任何存在的速度差异都可能微不足道。

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.

羞稚 2024-09-11 10:34:14

也许你应该研究一下 HipHop for php,它将 PHP 编译成 C++。由于 C++ 的编译速度更快。 Facebook 使用它来减少服务器的负载。

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

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/

煮茶煮酒煮时光 2024-09-11 10:34:14

我认为没有人能为你明确回答这个问题。这取决于您的 Web 服务器配置、操作系统和文件系统选择、SSI 使用的复杂性、服务器上的其他竞争进程等。

您应该将一些示例文件放在一起,并在要部署的服务器上运行测试。使用一些 http 测试工具,例如 ab围攻httperfjmeter 生成一些负载并比较两种方法。这是获得适合您的环境的答案的最佳方法。

将 PHP 与 mod_php 和操作码缓存(如 APC)一起使用可能会非常快,因为它会自动缓存高需求文件。如果您关闭 apc.stat它根本不需要访问磁盘来提供 PHP 脚本(需要注意的是,这使得在正在运行的系统上更新 PHP 脚本变得更加困难)。

您还应该确保遵循其他高可扩展性最佳实践。使用 CDN 获取静态资源,优化脚本和样式表等。通过 Steve SoudersTheo & George Schlossnagle 并从头到尾阅读它们。

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.

脸赞 2024-09-11 10:34:14

我建议您使用像 Squid 这样的网络缓存,或者,对于更复杂的东西,Oracle Web 缓存

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文