問題描述
Zend Framework 是一個很好的框架,但速度不是很快.您能否判斷將 Zend Framework 用于高負載項目是否值得,例如,對于可能包含大約十或數(shù)千名用戶的電子郵件營銷服務?使用 Zend Framework 是否可以達到可接受的性能?有人有這樣的經(jīng)歷嗎?非常感謝.
就我所見,對 Zend Framework 性能的最終防御和性能優(yōu)化建議來自 Padraic Brady:
PHP 框架基準:有趣但最終沒用
特別要注意他關于性能優(yōu)化的四項建議:
<塊引用>不要使用 Zend_Application.雖然 Zend_App 非常適合在標準化結構中創(chuàng)建一致的復雜引導程序,但它對基線性能的影響也很大.更直接的引導程序(ZF 在 Zend_App 到來之前是典型的)要快得多,而且無需配置文件即可完成.
跳過使用 ViewRenderer 插件.如果沒有 ViewRenderer,您需要手動配置 Zend_View 并向控制器添加 render() 調用.這實際上非常簡單,而且速度相當快 - 速度從來都不是 ViewRenderer 遺傳學的真正組成部分.
使用自動加載.從框架庫中去除 require_once 調用,以便忽略不需要的文件.用一個不那么瘋狂的自動加載器函數(shù)替換 Zend_Loader_Autoloader 的使用.事實上,祈禱 Zend_Loader 永遠不會被使用——它執(zhí)行了很多文件操作,迄今為止,我從未向我解釋過這些操作具有任何價值.
預加載所有內容(Symfony 2 Preview 可以!).它會為您購買一些性能 cookie 并平衡速度基線.使用簡單的預加載腳本并不難.
Zend Framework is a good framework but not very fast. Can you tell whether it's worth using Zend Framework for highload projects, for example, for email marketing service that can inlude about ten or houndred thousand of users? Is it possible to achive acceptable performance using Zend Framework? Has anybody such an expirience? Thank you very much.
For what I have seen, the definitive defense of Zend Framework performance and recommendations for performance optimization comes from Padraic Brady at:
PHP Framework Benchmarks: Entertaining But Ultimately Useless
In particular, note his four recommendations for performance optimization:
Don't use Zend_Application. While Zend_App is great for creating consistent complex bootstraps within a standardised structure, it doesn't come without a significant performance hit to baseline performance. A more direct bootstrap (typical of ZF until Zend_App arrived) is far faster and can also be done without configuration files.
Skip using the ViewRenderer plugin. Without the ViewRenderer, you need to manually configure Zend_View and add render() calls to Controllers. This is actually very simple to do and is fairly fast - fast was never really part of the ViewRenderer's genetics.
Use autoloading. Strip require_once calls from the framework library so unneeded files are ignored. Replace uses of Zend_Loader_Autoloader with a not-so-crazy autoloader function. In fact, pray Zend_Loader is never used - it does a lot of file ops that, to date, have never been explained to me as having any value.
Preload everything (Symfony 2 Preview does!). It buys you some performance cookies and equalises the speed baseline. Using a simple preload script is not that hard.
這篇關于將 Zend Framework 用于高負載項目的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!