Linux – Throttling network speed when copying files to SMB mounted NAS drive

linuxnetworkingrate-limitingserver-message-blockUbuntu

I have a fairly modest Ubuntu box (Jaunty) running as a small webserver. Each night i have a cron job which tar/gzip's important directories and does a simple cp to copy them over to a backup NAS drive which has been SMB mounted locally (effectively an "off-site" backup)

The network connection to the box is 802.11G (54Mbps) so naturally it's quite slow, but the issue is that when the files are being copied, the wireless bandwidth between the webserver and the router is completely saturated by the copy procedure, and web-requests are either denied or incredibly slow to respond.

I've tried using Trickle in standalone mode to throttle the copy procedure, but this didn't appear to make any difference.

Anyone have suggestions or advice? I suspect i need to run some form of QoS on the server but truly have NFI. Was hoping for an easy, silver-bullet solution 😉

Thanks,
Xerxes

Best Answer

There is a wput utility which works the other way from the more known wget.
It can be used to upload your files at a controlled rate.

−−limit−rate=RATE

If you don’t want Wput to eat up all available bandwidth, specify this flag. RATE is a numeric value. The units ’K’ (for KiB) and ’M’ (for MiB) are understood. The upload rate is limited on average, meaning that if you limit the rate to 10K and Wput was just able to send with 5K for the first seconds, it will send (if possible) afterwards more than 10K until the average rate of 10K is fulfilled.


About trickle,

trickle is a userspace bandwidth manager. Currently, trickle supports the shaping of any SOCK_STREAM (see socket(2)) connection established via the socket(2) interface. Furthermore, trickle will not work with statically linked executables, nor with setuid(2) executables.

Related Topic