如何限制安装 davfs 的云存储的带宽?

如何限制安装 davfs 的云存储的带宽?

我需要将大约 400 个文件(每个文件大约 25 MB)复制到安装了 davfs 的云存储。我尝试了以下命令来限制 CPU 负载和 IO 负载:

nice -n 15 ionice -c 3 rsync -avhW --no-compress --progress /src/ /dst/

我的目标文件夹dst是 davfs 安装的云存储。每当我传输一个文件时,rsync 只需几秒钟——至少它看起来这么快:

sending incremental file list
xxx
26.70M 100%   15.75MB/s    0:00:01 (xfer#1, to-check=0/1)
sent 26.70M bytes  received 31 bytes  7.63M bytes/sec
total size is 26.70M  speedup is 1.00

我没有看到任何 rsync 或好的进程正在运行,但系统反应非常慢,因为数据传输仍在后台运行。挂载的云存储只有一个davfs进程。几分钟后,我的系统再次响应,文件传输完成。

netstat显示与云存储的活动连接。

如何限制安装 davfs 的云存储的带宽以防止系统速度变慢?

答案1

Rsync(现在)有一个 bwlimit 选项:

   --bwlimit=RATE
          This option allows you to specify the maximum transfer rate for the data  sent  over  the
          socket,  specified  in units per second.  The RATE value can be suffixed with a string to
          indicate a size multiplier, and may be a fractional value (e.g.   "--bwlimit=1.5m").   If
          no suffix is specified, the value will be assumed to be in units of 1024 bytes (as if "K"
          or "KiB" had been appended).  See the --max-size option for  a  description  of  all  the
          available suffixes. A value of zero specifies no limit.

          For  backward-compatibility  reasons,  the  rate limit will be rounded to the nearest KiB
          unit, so no rate smaller than 1024 bytes per second is possible.

          Rsync writes data over the socket in blocks, and this option both limits the size of  the
          blocks  that  rsync  writes, and tries to keep the average transfer rate at the requested
          limit.  Some "burstiness" may be seen where rsync writes out a block  of  data  and  then
          sleeps to bring the average rate into compliance.

          Due  to  the  internal  buffering  of  data, the --progress option may not be an accurate
          reflection on how fast the data is being sent.  This is because some files can show up as
          being  rapidly  sent  when  the data is quickly buffered, while other can show up as very
          slow when the flushing of the output buffer occurs.  This may be fixed in a  future  ver‐
          sion.

相关内容