Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 have a basic install of Apache2 server and PHP5.3 on my local Ubuntu machine.

I created file index.php and put sleep 30 seconds in it

sleep(30); // script sleep 30s

When i run "localhost/index.php" in web browser, request are waiting that 30 seconds.

During that time I delete that line sleep(30); and run in new tab "localhost/index.php"

Second request is waiting first to finish, so wait that 30s.

That is a problem because Apache run only one process/thread. How to configure Apache to run normally? Or can someone explain to me what's going on?

share|improve this question
How did you establish that the second request was waiting for the first one to finish, rather than just sleeping 30 seconds? Did you wait ten seconds and then time it, for example? It's much more likely that it was simply getting a cached copy of the script with the sleep in it. – David Schwartz Dec 18 '12 at 11:49
I tried that and it's the same thing. Second request wait first, and after 30s second, wait regular 10 seconds to give response. – tasmaniski Dec 18 '12 at 11:57

You probably have a deadlock on the session file; turn off session.auto_start, and/or call session_write_close() before sleep(30).

share|improve this answer

It's related to PHP's session. The session file (that bizarre file that is on /tmp/SOMETHING) gets locked for the first request.

You should call session_write_close() before the sleep() (or any time-wasting call). You might disable session_autostart if you don't want to use it either.

share|improve this answer

Your Answer


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.