Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to speed up a PHP script running with Apache 2 + PHP in pre-fork mode + APC. It seems that my server takes 100ms to launch the PHP script, which seems way too much.

What are the ways to speed this up, or understand why the server wastes 100ms?

PS: Here is how I came up with this "100ms overhead":

When I test the script from my browser, Chrome's developer tools indicate the following average timing :

Connecting : 30ms
Waiting: 170ms
Receiving: 50ms

I've then added echo microtime(); to the first and last lines of my script. This shows a difference of 70ms, meaning that the whole script takes 70ms and Apache/PHP add 100ms in "overhead" to that.

share|improve this question
Since the page is dynamic and user-specific, solutions such as Varnish do not seem relevant to me. – Eric Nov 19 '12 at 13:58
How far is your browser from the server? The speed of light may well be the limiting factor here. – David Schwartz Nov 19 '12 at 19:06
How long does it take to ping your server? I've seen pings in the 100ms range over unreliable WiFi. – tjameson Nov 20 '12 at 2:58
I am 200 miles away from the server. But this "speed of light" should be in the "Connecting time" (30ms). I guess the "Waiting time" is the time after the initial hand-shake with the server. i.e. pure overhead, right? – Eric Nov 20 '12 at 8:18
It's definitely one factor in the waiting time. But you pay an additional speed of light penalty any time one side waits for the other. The client won't send the request until it gets the server's response to its attempt to open the connection. The server can't launch the script until it gets the client's request. The client can't shut down the connection until it gets the server's response. And so on. – David Schwartz Nov 21 '12 at 18:33

Your Answer


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

Browse other questions tagged or ask your own question.