Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Rate-limiting processes?
PostPosted: Wed Feb 09, 2005 4:59 pm 
Offline
Junior Member

Joined: Mon Apr 26, 2004 5:03 pm
Posts: 47
Is there any way to IO rate-limit an individual process inside a vps? I've got a process that md5's a lot of files and I'd like to slow it down so I don't use up all my io tokens.

Linux xxx 2.4.26-linode31-1um #1 Thu Jul 8 18:24:02 EDT 2004 i686 UML User Mode Linux GNU/Linux


Top
   
 Post subject:
PostPosted: Thu Feb 10, 2005 11:21 am 
Offline
Junior Member

Joined: Wed Jul 21, 2004 5:15 pm
Posts: 25
if you call the md5 process from a basic bash script you can include a wait command or you could even grep the iotoken counter too make sure you stay above a current amount.


Top
   
 Post subject:
PostPosted: Thu Feb 10, 2005 11:43 am 
Offline
Junior Member

Joined: Thu Oct 07, 2004 6:47 pm
Posts: 47
You could spawn the md5 process, fetch the process ID and as long as it is running, use a simple bash script that monitor /proc/io_status, send SIGSTOP to the PID when the bucket is below a fixed value and send a SIGCONT to the PID when the bucket is back above another.


Top
   
 Post subject:
PostPosted: Thu Feb 10, 2005 1:46 pm 
Offline
Junior Member

Joined: Wed Aug 20, 2003 2:13 pm
Posts: 38
Website: http://www.kotalampi.com/
AOL: r1sto
Location: Hayward, CA
Take a look at this:

http://www.kotalampi.com/scripts/watchtokens

It is watching your system load & available io tokens and will stop and start services if they go too low/high and restart when systems have returned to normal.

You can modify it for your purposes as follows:

Put your start/stop commands to these files:
$startfile ="/etc/rc.d/start.sh";
$stopfile ="/etc/rc.d/stop.sh";

When to stop services (when load/tokens is at these levels):
$maxload = 3.0;
$l = 0.2; # <20% of max io_tokens

When to restart services (when load/tokens is back at these levels):
$minload = 1.1;
$u = 0.5; # >50% of max io_tokens

Cheers,

Risto


Top
   
 Post subject:
PostPosted: Thu Feb 10, 2005 2:06 pm 
Offline
Junior Member

Joined: Mon Apr 26, 2004 5:03 pm
Posts: 47
The kill -STOP and CONT would work, but it is going to be pretty bursty. I was thinking more towards something that would keep the usage smooth.


Top
   
 Post subject:
PostPosted: Fri Feb 11, 2005 4:07 pm 
Offline
Senior Member

Joined: Sat Jun 05, 2004 12:49 am
Posts: 333
Quote:
$a2 = "\$$a2";
$a3 = "\$$a3";
$a4 = "\$$a4";
$a5 = "\$$a5";
$a6 = "\$$a6";


I'm scared looking at that code lol :)


Top
   
 Post subject:
PostPosted: Fri Feb 11, 2005 6:51 pm 
Offline
Junior Member

Joined: Wed Aug 20, 2003 2:13 pm
Posts: 38
Website: http://www.kotalampi.com/
AOL: r1sto
Location: Hayward, CA
Maybe this won't be that scary... :-)

if($out =~ /^(io_count=)(\d+)(\s+)(io_rate=)(\d+)(\s+)(io_tokens=)(\d+)(\s+)(token_refill=)(\d+)(\s+)(token_max=)(\d+)$/){
$io_rate = $5;
$io_tokens = $8;
$token_refill = $11;
$token_max = $14;
}
else
{
print STDERR "Invalid /proc/io_status syntax\n";
exit(-1);
}

New version is available in the URL above, too.

Risto


Top
   
 Post subject:
PostPosted: Sat Feb 12, 2005 10:04 pm 
Offline
Senior Member

Joined: Sat Jun 05, 2004 12:49 am
Posts: 333
(?:pattern) is your friend. ditto with |=


Top
   
PostPosted: Wed Feb 16, 2005 4:09 am 
Offline
Senior Member

Joined: Sat Dec 13, 2003 12:39 pm
Posts: 98
Also check out this thread:

http://www.linode.com/forums/viewtopic.php?t=1147

In the end of that thread caker alludes to an ionice-type capability being available in the future. Anybody know if that's here yet?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group