Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sleep() silently hogs CPU

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.

like image 455
Steve M Avatar asked Aug 21 '08 23:08

Steve M


1 Answers

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.

like image 150
Manuel Avatar answered Oct 08 '22 08:10

Manuel