转自:http://serverfault.com/questions/461618/limit-the-speed-of-writing-files-to-nfs
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 expectit took so much bandwidth. So i need to find a way to limit the speed ofwriting to NFS.
I tried rsync with --bwlimit=5000. However, it did limit the readingspeed, but the accumulated data still was written at 80MB/s, and no writingactivities for seconds.
Is there any way to limit the writing speed of NFS?
The behaviour you're seeing where data accumulates andis then written out at full speed is the dirty pages growing on the client andthen being flushed out to the NFS server. This is the expected way that IOworks.
On a Linux NFS client, you can use tc to match and controltraffic. This would be as simple as making a class with the NFS server's IPaddress as the destination, and ratelimiting that class.
This is covered in the Linux Advanced Routing &Traffic Control HOWTO, specifically in Chapter 9Queueing Disciplines for Bandwidth Management andwithin man tc.
Here is an example of the exact commands to use: http://iomem.com/archives/17-Rate-limiting-with-sch_htb.html
第二个链接:
http://iomem.com/archives/17-Rate-limiting-with-sch_htb.html
Ever had a user who uses up far too much bandwidth on yournetwork? The Linux AdvancedRouting and Traffic Control Guide givesa good example of rate-limiting a single machine on your network, using the sch_cbqmodule; however, I wanted to do this on a Linksys WRT54-GS router runningOpenWRT, and sch_cbq is not available on there.
Fortunately, sch_htb, the HierarchicalToken Bucket isavailable on OpenWRT, which can do the same thing, but it's a lot morecomplicated to configure.
The following script will rate limit the single IP address of 192.168.0.67 to128kbps. All other addresses on the network will remain unlimited. Set the nameof the inside interface on your Linux router in DEV,the IP address in IP, the maximum rate on your inside network in MAXRATE andthe limit that you want to apply in LIMIT.
#!/bin/sh
DEV="br-lan"
IP="192.168.0.67"
MAXRATE="100mbps"
LIMIT="128kbps"
tc qdisc add dev $DEV root handle 1: htb default 11
tc class add dev $DEV parent 1: classid 1:1 htb rate $MAXRATE ceil $MAXRATE
tc class add dev $DEV parent 1:1 classid 1:10 htb rate $LIMIT ceil $LIMIT
tc class add dev $DEV parent 1:1 classid 1:11 htb rate $MAXRATE ceil $MAXRATE
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip dst $IPflowid 1:10
tc qdisc add dev $DEV parent 1:10 handle 20: pfifo limit 5
tc qdisc add dev $DEV parent 1:11 handle 30: sfq perturb 10
http://unix.stackexchange.com/questions/34116/how-can-i-limit-the-bandwidth-used-by-a-process