CakePHP 1.3: High CPU Usage

杀马特。学长 韩版系。学妹 提交于 2019-12-22 01:06:38

问题


I have a CakePHP application that is running on a shared hosting account, which the provider has been bugging me a lot (A2HOSTING) that my account is excessively using CPU resources, sometimes 100%.

Just on the last few hours alone, CPanel is reporting high CPU Usage. I have spoken with them and they said that everything is pointing to the 'webroot' directory. There I only have index.php and css.php.

Any ideas, what can be causing this issue, and what can I do to fix it, as they are threatening to suspend my account.

Thanks,


回答1:


There is not a whole lot to say without a more information. For now, Let's start with what is using 100% cpu? MySQL or PHP? Also, the conditions you use. Any associations and so on...

If it all works ok on your local setup then I would start by looking at any differences between that and your server. Versions of CakePHP, PHP, MySQL... are they different? Is the server running some infamous version of one of them?

Let's blame the database: Is the database structure and data really identical, really? Look carefully as every detail. Do you have the same content in them? Exactly? Clone your dev database including all table definitions and data.

Sometimes I notice a lapse of logic on my part where a "clean" database will cause problems because I have had data in it during the whole development and for some reason I have missed that something (seemingly unrelated) will fail if a table is empty.

Let's blame PHP: When PHP ends up at 100% cpu, the problem is usually that it is stuck in a loop somewhere. Do you have one near that line? If you let the request run, do you just get a timeout or an out of memory?

Finding "first" should never result in out of memory unless your server has 200'000 related records being loaded. Try specifying recursive -1. That is: load absolutely nothing from any other table.

Reference: https://groups.google.com/forum/?fromgroups#!topic/cake-php/lS91s355_Pw

This post might help you to decrease the CPU overload.



来源:https://stackoverflow.com/questions/11551401/cakephp-1-3-high-cpu-usage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!