您认为编写一个新的 PHP 框架作为 PHP 扩展(用 C 语言)在性能和可用性方面是一个好主意吗?
编辑:结果表明已经有新的 PHP 框架作为扩展编写。 http://code.google.com/p/yafphp,谢谢戈登 提到这一点。
简而言之,您认为编写 PHP 扩展这样的框架值得并且对社区有用吗?为什么?
动机:
- 在编写高性能 Web 应用程序时(每天数百万个页面) 视图),前端服务器的性能变得很重要 您需要多少硬件以及该硬件的情况 表演。
- 许多大型网络公司正在实施自己的解决方案,通过为重复性任务编写本机框架或特殊 PHP 扩展来增强 PHP 性能。
- 我不知道有任何众所周知/编写良好的 PHP 框架或模板引擎作为 PHP 扩展编写。
担忧
- 在许多情况下,在 PHP 用户空间中编写的代码仅占 Web 应用程序的 10-30% 左右。所有后端都是 Java/C/C++ 中的 Web 服务,前端仅渲染数据并打印数据。
- Web 转向编写单网页架构、Javascript MVC 和客户端模板 (Javascript)。
- NodeJS 是比 Apache/PHP 堆栈更快的新堆栈。
- 易于使用和安装。使用 PHP 编写的框架更容易使用和理解其内部结构,因为您可以查看其代码并学习。
- 易于维护,用 PHP 编写的框架比用 C 编写的框架有更大的社区
- 使用其他框架(例如 Zend/Cake/Symfony 等)的现有大社区。他们可能没有兴趣开始学习新框架。
EDIT: Yields that there is already new PHP framework written as extension. http://code.google.com/p/yafphp, thanks gordon for mentioning this.
In short, do you think writing such framework as PHP extension worth and can be useful to the community ? Why ?
Motivation:
- When writing high performing web application (millions of daily page
views), the performance of front-end servers become important in
terms of how much hardware you need and how this hardware is
performing. - Many big web companies are implementing their own solutions to enhance PHP performance, by writing native frameworks or special PHP extensions for repetitive tasks.
- I am not aware of any well-known/well-written PHP framework or template engine written as PHP extension.
Concerns
- In many cases code written in PHP user space is only about 10-30% of the web application. All back-end is web services in Java/C/C++ and the front-end are only rendering the data and print it.
- The web-shift into writing single-webpage-architecture, Javascript MVC and templating in the client-side (Javascript).
- NodeJS as new faster stack than Apache/PHP stack.
- Ease-of use and installation. It is easier to use and understand the internals of a framework written in PHP as you can look at its code and learn.
- Ease-of maintainability, bigger community for framework written in PHP over a one written in C
- An already existing big community using other frameworks such as Zend/Cake/Symfony, etc. they may not be interested to start learning a new one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅当您证明 PHP 代码造成了严重的时间延迟时,用 C 替换任何 PHP 代码才会有帮助。
在必须移动数百万个任何类型的 I/O(例如网页或文件)的应用程序中,您需要做的是让 I/O 硬件尽可能忙碌地传输数据。
这意味着最大限度地缩短从完成一个 I/O 事务到开始下一个 I/O 事务的 CPU 周转时间。
因此,如果您进行分析或随机暂停 理想情况下,您应该发现所有 I/O 线程几乎始终处于 I/O 等待状态。
如果不是,那么无论他们在做什么,都需要加快速度。
不要猜测他们在哪里。
让程序通过诊断告诉您它们在哪里。
Replacing any piece of PHP code with C will only help if you have proved that that PHP code is responsible for significant time-lag.
In apps that have to move millions of any sort of I/O, like web pages or files, what you need to do is keep the I/O hardware as busy as possible pumping the data.
That means minimizing the CPU turnaround time from the completion one I/O transaction to the start of the next.
So if you profile or randomly-pause it, ideally you should find all I/O threads in I/O-wait state nearly all the time.
If they are not, then whatever they are doing, it needs to be speeded up.
Don't guess where they are.
Let the program tell you where they are, by diagnosis.