Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 11 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
首先,您应该知道目前 HipHop 没有完整的 PHP 5.3 支持,并且您无法使用所有扩展。
其次,如果你要构建一个在大小和用户基础上与 facebook 相当的应用程序(我真的很怀疑),那么使用 ORM 将是让项目沉没的最佳方法之一。
我无意重复同一首歌&再次讨论 ORM,所以,阅读之前的评论。
最后:在大型项目中,人们不使用固定框架。他们在内部编写一个然后使用它,因为大型项目有非常具体的要求,而流行的 mvc 框架往往采用“除了厨房水槽之外的一切”方法来添加功能。
如果你没有构建像 Facebook 这样大的项目,那么你就不需要 HipHop。
First of all, you should know that currently HipHop does not have full PHP 5.3 support and you cannot use all extensions.
Second , if you are going to build an application which is comparable in size and userbase to facebook ( which i honestly doubt ), then using ORM would be one of the best ways how to sink the project.
I have no intentions of repeating the same song & dance about ORMs again , so , read this earlier comment.
And the last: in large project people do not use canned frameworks. They write one in-house and then use it, because large scale project have very specific requirements, while popular mvc frameworks tend to have everything-but-kitchen-sink approach for adding features.
And if you are not building project that is as large as Facebook, then you do not need HipHop.
除非您确实遇到了可直接归因于 PHP 性能的性能问题,否则我强烈建议您避免使用 HipHop。它当然可以(如果使用得当)处理极高的流量,但它也与 PHP 不完全兼容。如前所述,并非所有 PHP 扩展都适用于 HipHop。
如果您遇到性能问题,那么在求助于 HipHop 之前您可以考虑其他替代方案。首先,检查脚本的性能,确定瓶颈并对其进行优化。这是应用程序中您最能控制的部分,因此也是您应该开始的地方。与外部资源(尤其是数据库和远程服务器)的交互是一个很好的起点,因为这是操作往往花费最多时间的地方。可以通过减少查询负载和明智地选择表索引来提高数据库性能(提示,ORM 往往会产生非常次优的查询模式)。您还可以将特别昂贵的操作卸载到 cron 作业以离线运行,并让在线脚本将操作排队。
如果这还不能提供足够的性能提升,那么 APC 可以将 PHP 代码缓存在“字节码”(需要一个更好的术语)中,在由 Zend 引擎运行之前无需进行解析。这提供了性能提升。您还可以执行其他操作,例如使用 memcache 进行缓存、缓存结果等,以获得进一步的性能提升。
如果您仍然没有获得足够的性能,那么,只有到那时,您才应该考虑 HipHop。您应该将其视为最后的手段,而不是首选。您也不应该开始担心项目的优化,直到项目明显出现性能问题为止。
永远不要进行过早的优化。
Unless you actually have a performance problem that can be directly attributed to PHP's performance, then I'd strongly advise avoiding HipHop. It can certainly (if used properly) handle extremely high traffic, but it also isn't fully compatible with PHP. As has already been stated, not all PHP extensions work with HipHop.
If you are having performance issues, then there are other alternatives you can look at before having to resort to HipHop. First, review the performance of your scripts, determine the bottlenecks and optimize them. This is the part of the application you have the most control over and therefore the place where you should start. Interaction with external resources, especially databases and remote servers, are a good starting point as this is where operations tend to have the most time-expense. Database performance can be improved by reducing the query load and wise choice of indexes for the tables (Hint, ORM tends to produce very sub-optimal query patterns). You can also offload especially expensive operations to cron-jobs to be run offline and have the online script just queue the operation.
If this doesn't provide enough of a performance boost, then there's APC which caches PHP code in a "byte code" (for want of a better term) that doesn't have to be parsed before it can be run by the Zend Engine. This provides a performance boost. There are also other things you can do such as caching with memcache, caching results and so on to gain further performance boosts.
If you still haven't gotten enough performance, then, and only then, should you consider HipHop. You should consider it a last resort, not a first resort. You also shouldn't start to worry about optimizing a project until such time as it's demonstrably suffering from performance issues.
Never do premature optimization.