zoukankan      html  css  js  c++  java
  • rsync传输性能测试总结 转

    测试环境

    1.1服务器硬件信息

    image

    1.2 服务器软件信息

    image1.3 Rsync所能够支持的功能

    (1)支持断点续传

    (2)支持使用ssh传输加密

    (3)支持128位MD4校验(3.0以后版本使用MD5加密)

    (4)支持镜像

    (5)支持限速

    (6)支持目录层级递归拷贝

    1.4常用Rsync参数详解

    -a, --archive

    It is a quick way of saying you want recursion and want to preserve almost everything.

    -r, --recursive

    This tells rsync to copy directories recursively.

    -t, --times

    This tells rsync to transfer modification times along with the files and update them on the remote system

    -u, --update

    This forces rsync to skip any files for which the destination file already exists and has a date later than the source file

    -z, --compress

    With this option, rsync compresses any data from the files that it sends to the destination machine

    -P

    断点续传 详细显示传输过程(传输进度)

    -c, --checksum

    This forces the sender to checksum all files using a 128-bit MD4 checksum before transfer

    -n, --dry-run

    This tells rsync to not do any file transfers, instead it will just report the actions it would have taken.

    --delete

    This tells rsync to delete any files on the receiving side that aren't on the sending side

    --bwlimit=KBPS

    This option allows you to specify a maximum transfer rate in kilobytes per second

    --protocol

    (隐藏参数)

    选择传输时使用的TCP/IP协议字段号

    -B

    --block-size=SIZE checksum blocking size (default 700)

    1.5服务器逻辑

    两台服务器相邻,在同一个机房

    1.6 rsync server模式配置

    1、目标主机(DST)设置:

    (1)添加rsyncd.conf配置文件

    cat>/etc/rsyncd.conf<<EOF

    uid=root

    gid=root

    secrets file = /etc/rsyncd.secrets

    max connections=36000

    use chroot=no

    log file=/var/log/rsyncd.log

    pid file=/var/run/rsyncd.pid

    lock file=/var/run/rsyncd.lock

    [rsyncDST]

    path=/home/work/rsyncDST/share/1/0/

    comment = rsync test

    ignore errors = no

    read only = no

    hosts allow =10.0.101.241

    hosts deny = *

    EOF

    (2)配置rsync.secrets认证文件

    cat>/etc/rsyncd.secrets<<EOF

    rsync:123456

    EOF

    (3)修改rsync.secrets认证文件权限

    chmod 600 /etc/rsyncd.secrets

    (4)启动rsync server

    /usr/local/rsync/bin/rsync --daemon

    Rsync传输测试

    2.1初始化

    (1)将两台机器加入监控

    (2)将两台服务器建立SSH信任关系

    2.2 传输压缩测试

    1、SSH隧道加密传输,启用压缩,不启用数据校验

    image

    2、SSH隧道加密传输,未启用压缩,不启用数据校验

    image

    3、数据分析:

    Rsync在传输时,不启用压缩,比启用压缩要快将近10倍

    压缩使用的场合:低带宽,或对带宽有要求。传输文件压缩比率大

    非压缩适用的场合:带宽充足,传输文件比较大,传输文件压缩比率小

    建议不启用压缩

    2.3 传输数据校验测试

    1、SSH隧道加密传输,未启用压缩,不启用数据校验

    image

    2、SSH隧道加密传输,未启用压缩,启用数据校验

    image

    3、数据分析:

    Rsync在传输时,启用数据校验,比不启用数据校验多耗时30%

    文件校验使用的场合:对文件完整性要求高

    非文件校验适用的场合:对文件完整性要求低

    建议使用文件校验

    2.4 传输方式测试

    1、SSH隧道加密传输,未启用压缩,启用数据校验

    image

    2、rsync server传输,未启用压缩,启用数据校验

    image

    3、数据分析:

    SSH隧道传输,速度比rsync server要快,但CPU资源消耗比较高,加密耗时较多

    SSH隧道传输适用的场合:安全性要求比较高,对CPU资源消耗要求低

    rsync server适用的场合:对安全性要求比较低,对CPU资源消耗要求高。

    建议使用SSH加密隧道模式传输

    2.5 其他影响传输速度的因素

    1、SSH加密算法影响文件传输速度

    image 

    注:以上文件传输测试过程中未启用压缩,未启用数据校验

    使用SSH加密隧道传输时,如果希望数据传输较快,建议使用arcfour弱加密算法

    2、修改TCP/IP协议字段,--protocol=29

    (1)SSH隧道加密传输,未启用压缩,启用数据校验,不修改TCP/IP协议字段

    image

    (2)SSH隧道加密传输,未启用压缩,启用数据校验,修改TCP/IP协议字段为29

    image

    (3)数据分析:

    修改TCP/IP协议字段,传输速度有了明显的提升。但是由于使用SSH加密隧道,程序运行耗时依旧很多。

    建议修改TCP/IP协议字段为29

    附: TCP/IP协议字段号

    image

    3、其他

    rsync server模式,未启用压缩,启用数据校验,修改TCP/IP协议字段为29。

    传输平均速度在120MB/S以上。传输耗时3m2.584s

    rsync server模式,未启用压缩,未启用数据校验,修改TCP/IP协议字段为29。

    传输平均速度在122MB/S以上。传输耗时2m14.185s

    测试过程中,调节—block-size参数等于512,可以缩短checksum时间,总传输时间可节省大概3s左右

    结 

    根据当前生产环境,以及测试数据,我得出的结论如下:

    1、 如果对数据安全性要求低,建议选择rsync server模式,未启用压缩,启用数据校验,修改TCP/IP协议字段号为29。

    2、 如果对数据安全性要求高,建议选择SSH隧道加密传输,arcfour弱加密算法,未启用压缩,启用数据校验,修改TCP/IP协议字段号为29

    3、 如果是第一次推送数据,建议加上-W参数,意思是不检查文件更新,直接传送整个文件,这样可以减少文件检测时间,节省程序总运行时间。

    4、 如果想进一步节省程序运行时间,可在使用checksum的同时,加上—block-size=512这个参数(默认是700)。数值建议是500以上,并且是2的N次方,最大不超过2048。推荐512,1024,2048这三个值。

    5、 在传输数据时,为了不影响线上正常业务,建议根据线上实际情况,通过—bwlimit=KPBS参数对带宽进行限制

  • 相关阅读:
    python之字符串【str】
    python之列表【list】
    python之os模块
    MySQL 模糊查询
    Dreamoon-Operating on a graph(并查集+链表)
    Dreamoon-Operation Love(凸包)
    CF1382D.Unmerge(背包)
    PAT-T1027 Larry and Inversions (树状数组)
    CF1379C.Choosing Flowers(二分)
    矩阵快速幂模板
  • 原文地址:https://www.cnblogs.com/liujianzuo888/p/5013112.html
Copyright © 2011-2022 走看看