LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-26-2007, 08:05 AM   #1
anjanesh
Member
 
Registered: Sep 2004
Location: Navi Mumbai
Distribution: Ubuntu 14.04 64-bit
Posts: 230

Rep: Reputation: 30
usleep reduce CPU spikes ?


Hi

Does the usleep() function reduce CPU spikes ?

Thanks
 
Old 06-26-2007, 10:13 AM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
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?
 
Old 06-26-2007, 10:30 AM   #3
anjanesh
Member
 
Registered: Sep 2004
Location: Navi Mumbai
Distribution: Ubuntu 14.04 64-bit
Posts: 230

Original Poster
Rep: Reputation: 30
Quote:
why not run CPU intensive operations at low priority?
low priority - hows that ?

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.
 
Old 06-26-2007, 10:39 AM   #4
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
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.
 
Old 06-26-2007, 10:50 AM   #5
anjanesh
Member
 
Registered: Sep 2004
Location: Navi Mumbai
Distribution: Ubuntu 14.04 64-bit
Posts: 230

Original Poster
Rep: Reputation: 30
Quote:
However, if your shared hosting company requires you to keep your CPU usage low, get another hosting company.
- this is rule for all shared hosts - its our duty to keep it from using CPU for too long.
 
Old 06-26-2007, 11:02 AM   #6
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Quake4 cpu usage spikes windowlicker Linux - Games 5 01-23-2006 08:02 AM
rsync reduce cpu usage dtra Linux - Software 0 05-25-2005 08:04 PM
CPU load spikes every ten seconds, causes problems beetlenaut Linux - Software 14 09-04-2004 07:37 AM
Strange CPU/Network Spikes BenCarlisle Linux - Networking 7 03-01-2003 10:25 PM
Strange CPU Spikes BenCarlisle Linux - General 2 02-26-2003 05:48 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration