usleep reduce CPU spikes ?
Hi
Does the usleep() function reduce CPU spikes ? Thanks |
Well, sort of. When your process is sleeping, it's not using any CPU. Rather than worry about spiking the CPU, why not run CPU intensive operations at low priority?
|
Quote:
I got to do all this to make sure the scripts dont run anything intensive on my shared-hosting company - otherwise they'll suspend the account for resource overuse on a shared a/c. |
To lower the priority, you use 'nice'. However, if your shared hosting company requires you to keep your CPU usage low, get another hosting company. They should be capping/limiting your resource usage instead of having you do it. They appear not to have the skills needed to offer reliable service, and that will just bite you sometime in the future.
|
Quote:
|
There are different ways to implement a shared host. Using a virtual private server allows the service provider to limit your access to the CPU to a fixed percentage. So while your virtual CPU may be a 100%, the real CPU may be at 10%. This is more complex to implement, but it also means that your hosting service isn't just thowing a bunch of people on a Linux box with no planning.
|
All times are GMT -5. The time now is 02:09 PM. |