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.

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

<?php
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"

That second request 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
add comment

2 Answers 2

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
add comment

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
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.