PHP应用程序的可扩展性

发布于 2024-10-08 11:29:03 字数 383 浏览 2 评论 0原文

我使用 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 技术交流群。

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

发布评论

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

评论(2

乄_柒ぐ汐 2024-10-15 11:29:03

如何提高网站性能?

如果不知道瓶颈在哪里,很难说。一种方法是:

  1. 首先优化 SQL 查询,启用慢速查询日志记录并检查它们,正确索引列,并根据需要更改 SQL Server 的配置。

  2. 分析 PHP 执行,分析报告并确保在需要时重构代码。

  3. 引入缓存、平面文件、SQL 缓存、APCMemcache 等(只是不要全部一起使用:)

  4. 优化服务器配置,包括软件和硬件。

  5. 移动到多个服务器。

数据库查询的结果限制是多少(10 秒)?

你是说执行时间?尽可能快:) 但话又说回来,这取决于查询本身。如果每天执行一次查询,则速度可能比每次请求都执行时慢。时间取决于上面的第一个问题/答案。

我应该将应用程序迁移到更新的技术或框架吗?

这个问题很难回答。同样,这取决于问题是什么以及您是否能够识别并解决它们。如果你可以通过优化查询和数据库、缓存等来解决它们,那么问题就不在框架中。我强烈建议在切换到另一种技术或重写代码之前仔细考虑一下。

How I can I improve my site performance?

Hard to say without knowing where the bottleneck is. One approach would be to:

  1. Start by optimising your SQL queries, enable slow query logging and examine them, properly index columns, and change SQL server's configuration if needed.

  2. Profile PHP execution, analyse report and make sure to refactor the code where needed.

  3. Introduce caching, flat files, SQL caching, APC, Memcache etc. (just don't use all of them together :)

  4. Optimize server configuration, including software and hardware.

  5. Move to several servers.

What is result limit from queries on the database(10s)?

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.

Should I move application to newer technology or framework?

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.

那片花海 2024-10-15 11:29:03

通过 google 快速搜索,找到了以下站点,所有这些站点都致力于大幅加快 CakePHP 的速度。此外,以下是我对 Cake 速度的看法:

  1. 确保您使用的是最新的 Cake 版本。从 Cake 1.2 到 1.3 的更新使我最大的应用程序的速度提高了约 20%。
  2. 确保您已打开缓存(对于大多数读取密集型应用程序,这将有很大帮助)。
  3. 如果您有很多相关但不经常使用的模型,请尝试延迟加载这些模型。

请记住,Cake 并不是真正为速度而构建的。这里的其他答案适用于一般情况,但对于 CakePHP,瓶颈通常在于 Web 层。因此,一种(相当简单)的横向扩展方法是通过代理服务器加载页面,该代理服务器将请求传递到后端处理场。

另外,我强烈建议您分析您的代码。这意味着使用像 Zend 这样的 IDE,您可以在其中插入断点来确定代码中速度较慢的部分。至少,安装 Cake 调试工具栏,它将显示应用程序主要部分的执行时间(请求处理程序加载、控制器执行、视图渲染时间等)。Google

搜索“优化 CakePHP 速度”的结果:

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:

  1. Make sure you're using the latest Cake release. The update from Cake 1.2 to 1.3 yielded about a 20% speed boost for my biggest app.
  2. Make sure you have caching turned on (for most read-intense applications, this will help massively).
  3. If you have a LOT of models that are related, but infrequently used, try loading those models lazily.

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":

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