Question

I found that pages in my CakePHP application that do not call the database take about 4 seconds to load, which is way too slow.

I tried the following things to no avail:

  • Rebooting the computer
  • Reinstalling Uniserver
  • Toggling the debug level from 2 to 0
  • Switching to APC cache from FileCache

I got an XDebug profiler dump and observed in KCachegrind that the most time consuming function was php::session_start and that it was called by \webroot\index.php. I also checked the performance using the CakePHP Debug Kit and found that the most time consuming item was "Core Processing (Derived from $_SERVER["REQUEST_TIME"])".

What can I do to get my pages to load faster?

In case my hardware is relevant, I have described the operating environment below:

  • ThinkPad T400
  • Intel Core 2 Duo processor
  • OCZ SSD
  • 4 GB RAM
  • Windows 7 64-bit edition
  • CakePHP version 2.2.3

As a starting point, I compared my working copy of php.ini with the production version of php.ini provided by Uniserver and found the following major differences:

  • PHP error levels (E_ALL, E_NOTICE, E_STRICT, etc.)
  • $php_errormsg logging
  • mysqlnd.collect settings (2 of these)
  • Disable Xdebug

Then, I did some before and after comparisons. The green cells are values that are <= 1 second, which is the limit for humans perceiving something is "pretty fast." I realize that actually, one must be <= 0.1 seconds to be "instant" but that's seems a bit unrealistic.

Comparison of processing time required to display CakePHP pages

(To view the image in full-size, go to Windows SkyDrive at http://sdrv.ms/YomWdO.)

I tried using the website application while running under the "After" version of php.ini and things aren't awful but I still feel like I've hit a road bump when I launch most pages, especially when I can launch some pages instantly.

Was it helpful?

Solution 2

The solution is to change the following settings:

  • PHP error levels (E_ALL, E_NOTICE, E_STRICT, etc.)
  • $php_errormsg logging
  • mysqlnd.collect settings (the second one)
  • Disable Xdebug

Then, get a dedicated production server so that you don't have to keep switching copies of php.ini.

Last of all, if that doesn't speed things up enough and it's just a personal project (though it might be a critical personal project), give up and move on with life.

OTHER TIPS

Check your session configuration and make sure your session store is correctly set up. E.g. If you're using a database, make sure it's reachable on a fast network or local, and the user has all required privileges. If sessions reside in the file system, check availability and permissions. Finally, check your php configuration in general; this does not look like a Cake issue.

Same problem solved by Editing the file core.php

Change Configure::write('debug', 2); to Configure::write('debug', 0);

that is 2 to 0

path : app/config/core.php

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top