2

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.

Zian Choy
  • 2,846
  • 6
  • 33
  • 64

3 Answers3

1

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.

domsom
  • 3,163
  • 1
  • 22
  • 27
  • Unfortunately, I've already checked the session store using the default CakePHP page, the database is running locally, and the CakePHP page shows no errors. – Zian Choy Jan 22 '13 at 04:46
  • Do you have any suggestions for resources I could look at to learn more about adjusting php.ini for speed? – Zian Choy Jan 22 '13 at 04:47
  • I doubt that this is a tuning issue. It just looks like `session_start` encounters a situation that is fixable, but takes a while to figure out. You could setup a quick non-CakePHP test page that just runs `session_start` to narrow down the issue. If it persists, you know it's a PHP issue and you can start manually configuring your PHP session handling; if not, it's a CakePHP issue. – domsom Jan 22 '13 at 13:01
0

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.

Zian Choy
  • 2,846
  • 6
  • 33
  • 64
-1

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

Rafi
  • 833
  • 13
  • 17