Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

CentOS 5.6

NFS is mounted on the server for backup disk space. When the backup job started, it could reach 80MB/s and we really do not expect it took so much bandwidth. So i need to find a way to limit the speed of writing to NFS.

I tried rsync with --bwlimit=5000. However, it did limit the reading speed, but the accumulated data still was written at 80MB/s, and no writing activities for seconds.

Is there any way to limit the writing speed of NFS?

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

Sorry for opening such an old thread, but I wrote a little script to limit speed tranfer using the pv command, it works over NFS as well. The only thing I haven't gotten over yet is a drop of speed, it happens only when I use NFS over sshfs everything is fine.

My server NFS configuration (the exports):

rw,sync,no_subtree_check 

And the client configuration (mount options):

rsize=8192,wsize=8192,timeo=14,intr,_netdev,noauto,hard,sync

Here's my script:

 #!/bin/bash

 # Simple Script to mv files OR folders at $3 BPS  

tor_path="$1"  
mv_dir="$2"  
speed="$3"  
tor_dir="$(basename "$tor_path")"  
file=""  
tlines=""  
cnt=""   
file=""  

[[ "$mv_dir" != *"/" ]] && mv_dir=""$mv_dir"/"  

if [[ -f "$tor_path" ]] && [[ -d "$mv_dir" ]]  
  then  
  pv -L "$speed" "$tor_path" > "$mv_dir""$tor_dir"  
elif [[ -d "$tor_path" ]] && [[ -d "$mv_dir" ]]  
  then  
    tor_files="$(mktemp --tmpdir tor_files.XXXXXX)"  
    [[ "$tor_path" != *"/" ]] && tor_path=""$tor_path"/"  

    find "$tor_path" -type d > "$tor_files"  
    sed 's#'"$tor_path"'#'"$tor_dir"'/#g; s###g' -i "$tor_files"  

    tlines="$(wc -l < "$tor_files")"   
    cnt=0  
    while [ "$cnt" -lt "$tlines" ]  
      do  
        let cnt++  
        file="$(head -n $cnt $tor_files | tail -1)"  
        mkdir "$mv_dir""$file"  
    done  

    find "$tor_path" -type f > "$tor_files"  
    sed 's#'"$tor_path"'#'"$tor_dir"'/#g' -i "$tor_files"  

    tlines="$(wc -l < "$tor_files")"  
    cnt=0  
    while [ "$cnt" -lt "$tlines" ]  
      do  
        let cnt++  
        file="$(head -n $cnt $tor_files | tail -1)"  
        pv -L "$speed" "$tor_path""$(basename "$file")" > "$mv_dir""$file"  
    done  

    rm "$tor_files"  
else  
    exit 1    
fi  
share|improve this answer
add comment

NFS does not supply a method to limit the bandwidth used by the client.

The behaviour you're seeing where data accumulates and is then written out at full speed is the dirty pages growing on the client and then being flushed out to the NFS server. This is the expected way that IO works.

On a Linux NFS client, you can use tc to match and control traffic. This would be as simple as making a class with the NFS server's IP address as the destination, and ratelimiting that class.

This is covered in the Linux Advanced Routing & Traffic Control HOWTO, specifically in Chapter 9 Queueing Disciplines for Bandwidth Management and within man tc.

Here is an example of the exact commands to use: http://iomem.com/archives/17-Rate-limiting-with-sch_htb.html

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.