Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On my server, PHP will take a long time to execute a script (say, 5 seconds) if it hasn't been cached by APC yet. After it is, it executes very fast.

I'd provide more information, but I wouldn't know where to begin. Can you guess and point me in the right direction? I'll edit this question once I have more info.

share|improve this question
    
This questions is probably more appropriate for Stack Overflow. –  berberich May 5 '09 at 16:01
    
No, this is most likely on the configuration side of things. If we can rule out config problems here, the author can make another post about code optimisation. –  Dana the Sane May 5 '09 at 16:04
    
Bart, does your application use any remote php include()'s, or are all the included scripts local the server? –  Dave Cheney May 5 '09 at 16:19
    
Everything is local. It's also bound to be something on the config side because 1. Some of the scripts are made by others (a MediaWiki, an SMF forum) 2. Some of the scripts have run on another server before, where they work fine. –  Bart van Heukelom May 5 '09 at 16:51
    
Hmm, 5 seconds is still a long time for a php script to execute. What is the load like on that host ? –  Dave Cheney May 5 '09 at 17:09
show 4 more comments

2 Answers 2

up vote 2 down vote accepted

This is why we have caches. ;) Seriously: it seems that executing the script is the problem. But is it:

  • starting up the interpreter
  • or: execution time of the script?

Is there a PHP module installed, or does the http server has to start a new process (php) for the script?

Are the disks busy?

What is the execution time of the script itself (easy to measure with two timestamps you print at the start and at the end of the script)?

share|improve this answer
    
I'm using Apache2's mod-php5. I wouldn't know about the disks. How can I find out? The server load is very low though, so it seems unlikely. –  Bart van Heukelom May 5 '09 at 16:52
add comment

Use xdebug to profile your scripts. Then you'll know what takes so long.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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