PHP应用程序的可扩展性
我使用 cakephp 构建了我的应用程序。效果很好。我的应用程序仍处于测试阶段,有 3000 名测试用户(基于邀请)。我想将其扩展到更大的最终用户群。
关于我的应用程序的一些事情。
1)我使用的mysql数据库表有大约25000条记录。 2)多个模型和多个hasMany、belongsTo和HABTM关系
第一个问题。 1) 如何提高我的网站性能。 2) 数据库查询的结果限制是多少(10 秒)。 4)我应该将应用程序转移到更新的技术或框架吗?
记录和关系的数量正在增长。
不到三个月前,我在 cakephp 中启动了应用程序,几乎没有(MVC)知识。构建和测试应用程序非常容易。我每天都会向朋友推荐它。
我很感激任何帮助。
谢谢。
I built my application using cakephp. It works fine. My application still in beta with 3000 beta users(invites based). I am want to expand it for bigger end user base.
Few things about my app.
1) I am using mysql database table has around ~ 25000 records.
2) Multiple models and many multiple hasMany and belongsTo and HABTM relationships
First Question.
1) How I can I improve my site performance.
2) What is result limit from queries on the database(10s).
4) Should I move application to newer technology or framework.
The number of records and relationships are growing.
I started app in cakephp less than three months back with little (MVC) knowledge. It is amazing easy to build and test applications. I would recommend it to friends anyday.
I appreciate any help.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果不知道瓶颈在哪里,很难说。一种方法是:
首先优化 SQL 查询,启用慢速查询日志记录并检查它们,正确索引列,并根据需要更改 SQL Server 的配置。
分析 PHP 执行,分析报告并确保在需要时重构代码。
引入缓存、平面文件、SQL 缓存、APC、Memcache 等(只是不要全部一起使用:)
优化服务器配置,包括软件和硬件。
移动到多个服务器。
你是说执行时间?尽可能快:) 但话又说回来,这取决于查询本身。如果每天执行一次查询,则速度可能比每次请求都执行时慢。时间取决于上面的第一个问题/答案。
这个问题很难回答。同样,这取决于问题是什么以及您是否能够识别并解决它们。如果你可以通过优化查询和数据库、缓存等来解决它们,那么问题就不在框架中。我强烈建议在切换到另一种技术或重写代码之前仔细考虑一下。
Hard to say without knowing where the bottleneck is. One approach would be to:
Start by optimising your SQL queries, enable slow query logging and examine them, properly index columns, and change SQL server's configuration if needed.
Profile PHP execution, analyse report and make sure to refactor the code where needed.
Introduce caching, flat files, SQL caching, APC, Memcache etc. (just don't use all of them together :)
Optimize server configuration, including software and hardware.
Move to several servers.
You mean execution time? As fast as possible :) But then again, depends on the query itself. If the query is executed once every day, it can be slower than if it is executed with every request. Time depends on first question/answer above.
This one is hard to answer. Again, depends on what the problems are and whether you can identify and fix them. If you can solve them by optimizing queries and database, caching etc., then the problem is not in the framework. I strongly advise to think about it thoroughly before switching to another technology or rewriting the code.
通过 google 快速搜索,找到了以下站点,所有这些站点都致力于大幅加快 CakePHP 的速度。此外,以下是我对 Cake 速度的看法:
请记住,Cake 并不是真正为速度而构建的。这里的其他答案适用于一般情况,但对于 CakePHP,瓶颈通常在于 Web 层。因此,一种(相当简单)的横向扩展方法是通过代理服务器加载页面,该代理服务器将请求传递到后端处理场。
另外,我强烈建议您分析您的代码。这意味着使用像 Zend 这样的 IDE,您可以在其中插入断点来确定代码中速度较慢的部分。至少,安装 Cake 调试工具栏,它将显示应用程序主要部分的执行时间(请求处理程序加载、控制器执行、视图渲染时间等)。Google
搜索“优化 CakePHP 速度”的结果:
http://www.endyourif.com/optimizing-cakephp-websites/
延迟加载模型:
http://bakery.cakephp.org /articles/Frank/2010/08/10/optimizing-model-loading-with-lazymodel
http://www. seudocoder.com/archives/2009/03/17/8-ways-to-speed-up-cakephp-apps/
A quick google search resulted in the following sites, all dedicated to speeding CakePHP up considerably. In addition, here are my thoughts on Cake's speed:
Remember that Cake isn't really built for speed. The other answers here are good for generic situations, but with CakePHP, the bottleneck is usually with the web layer. So one (fairly simple) way to scale out is to load your pages through a proxy server that passes requests to a backend processing farm.
Also, I highly recommend that you profile your code. This means using an IDE like Zend, where you can insert breakpoints to determine the slow sections of your code. At a minimum, install the Cake debug toolbar, which will show you execution times for major sections of your app (request handler loading, controller execution, view render time, etc.)
Results for google search on "optimizing CakePHP for speed":
Good CakePHP specific tips:
http://www.endyourif.com/optimizing-cakephp-websites/
Lazy Load models:
http://bakery.cakephp.org/articles/Frank/2010/08/10/optimizing-model-loading-with-lazymodel
http://www.pseudocoder.com/archives/2009/03/17/8-ways-to-speed-up-cakephp-apps/