WordPress is taking between 1.5 and 10 seconds to render pages on a shared host. A little application that I had written always runs blindingly fast. The problem seems to be the vast amount of .php code that needs to be loaded and parsed/compiled for each an every request.
The host runs suPhp, like most shared hosts, which means no code cache. Timings below sugest that the host is well resourced.
I am thinking of writing a microWordpress which just contains the bits I need to integrate my form application with WP. That would be wpdb, basic user/capability loading, and a crude template. It would be small, and thus fast. Has anyone already done this?
These are my timings:-
SLOW: Total Time used 7.94470310211 load 6.05444192886 wp 0.00354599952698 template 0.325224161148 burn 1.56150388718
FAST: Total Time used 1.72696900368 load 0.174858093262 wp 0.00763082504272 template 0.0830750465393 burn 1.46141815186
Total time is real time in seconds on the server, add a second or so to see in the client.
"load" is the time wp takes to read and parse all of its .php files -- (wp-load.php). I'm pretty sure nothing else much happens here.
"wp' and "template" is the time wp takes to think about and render.
"burn" is the real time that it takes a tight loop of 20,000,000 iterations to execute. (PHP is slow!)
First you will note the variance in total time, from slugish (1.7 seconds) to Slow (7.9 seconds).
The burn time does not vary very much. That suggests that there is plenty of CPU, and the CPU is also about as powerful as my local one.
The big time difference is the load time. Run twice in a row and it is normally fast, but wait a few seconds between runs and it is very slow.
There are two possible explanations. One is that all the .php files would normally be cached in *nix's kernal memory disk cache. But wait a bit and they will fall out. Reading files from cache is very fast.
The second is that the PHP process is in fact being reused by Apache in some way, and is caching the compiled op codes. Parsing all that code in just 170 ms (fast time) seems too fast to me.
For the first either kernal parameters or just more memory would keep the cached files in memory longer. For the second, if true, some Apache tweaking may help. Not my area, but is there some time to live while idle parameter for spawned processes?
Certainly, my raw forms (outside the /wp) always run blindingly fast, and 8 seconds is unnacceptably slow.
This must be a common issue with WP. Even just concatenating all the .php files into one big one might help, but I have not tried that.