sleep() silently hogs CPU

performance, php, sleep

Solution

It could be that the called page opens a session and then doesn't commit it, in this case see this answer for a solution.

Problem

I'm running Apache on Linux within VMWare. One of the PHP pages I'm requesting does a `sleep()`, and I find that if I attempt to request a second page whilst the first page is `sleep()'ing`, the second page hangs, waiting for the `sleep()` from the first page to finish. Has anyone else seen this behaviour? I know that PHP isn't multi-threaded, but this seems like gross mishandling of the CPU. Edit: I should've mentioned that the CPU usage doesn't spike. What I mean by CPU "hogging" is that no other PHP page seems able to use the CPU whilst the page is sleep()'ing.

Original source

Related problems