I am running a small LAMP-based web server on which PHP-based pages seem to take a minimum of 5 seconds to render.

I believe that the problem is some issue with my PHP configuration in particular because:

  • requests for static pages take 0.5s or less to satisfy
  • requests for saved, static versions of PHP pages are served as fast as other static pages
  • requests for PHP-based pages take >5s to satisfy whether or not they make requests to the DB
  • the delay persists whether accessing the server by hostname or by IP, so it's not a DNS issue
  • looking at vmstat during the request shows 0 for swap-in and swap-out, so it's not pagefile thrashing
  • looking at top during the request shows that no apache process gets above 2-3% of CPU time, so it's not limited by CPU performance
  • looking at the apache logs during requests shows a GET request for the PHP-based page, a 5-second delay, and then a request for the first CSS file that the PHP page loads.

On that basis, I feel pretty sure that the problem is with the PHP configuration, but PHP configuration is foreign to me. What are my options for improving PHP performance here? What are some common problems I should check for?

The main use case for this server is running a site based on the Joomla CMS, but this problem appears to be independent of Joomla, because the performance problems are happening with all PHP pages.

A clarification in response to Zoredache's question:

  • On the server, running time curl is fast - tenths of a second.
  • Elsewhere on the local network, running time curl is slow - 5 seconds at least.
  • Downloading a static page really takes up to 0.5 seconds, that seems pretty high. And a single page view takes 5 seconds for a PHP page? How are you measuring the delay? Does that delay still happen if you use curl/wget locally on the webserver. – Zoredache May 25 '11 at 23:23
  • I measured those times by using time curl $foo for a variety of pages. – Brighid McDonnell May 25 '11 at 23:31

Rasmus (Creator of PHP) did a whole talk on PHP performance http://talks.php.net/show/digg (There's a video of him doing the talk somewhere but I can't remember where, if I find it I'll update this post)

The video is here

  • While that's interesting, that's not really an answer. – Brighid McDonnell Dec 9 '11 at 0:08

Are you using DNS names for resource addresses, such as the DB server address ? If so try replacing them with IP Addresses and see if the speed improves. This is a possible quick win.

Otherwise I suggest you try using https://github.com/facebook/xhprof to find your bottleneck

  • Yes, but I'm just getting started :) – Cillier Oct 10 '13 at 11:37
  • @LorenzMeyer This is not a forum. Good answers are welcome at any time. – Michael Hampton Oct 10 '13 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.