search
HomeDatabaseMysql Tutorial使用tar+lz4/pigz+ssh更快的数据传输

前面一篇介绍了如何最大限度的榨取SCP的传输速度,有了这个基础,就可以进一步的使用压缩来加速传输速度了。只使用scp,传输速率

前面一篇介绍了如何最大限度的榨取SCP的传输速度,有了这个基础,就可以进一步的使用压缩来加速传输速度了。只使用scp,传输速率最快约90MB,本文通过压缩将把最快传输速率提升到约250MB/s(包括解压的过程)。

目录

  • 1. 结论
  • 2. 关于lz4
  • 3. 性能环境说明
  • 4. 实验测试
  • 4.1 分析
  • 1. 结论

    使用tar+lz4+ssh的方式能够获得最大的传输性能:

    time tar -c sendlog/|pv|lz4 -B4|ssh -c arcfour128 \ -o"MACs umac-64@openssh.com" 10.xxx.xxx.36 "lz4 -d |tar -xC /u01/backup_supu" 3.91GiB 0:00:16 [ 249MiB/s] real 0m16.067s user 0m15.553s sys 0m16.821s

    249MB/s,妥妥的。是最原始scp(40MB/s)的6倍,原来400GB传输需要约3小时,现在只需要27分钟了。

    注1:lz4在解压方面的优异表现,使得他在本案例中非常重要。如果无需解压的传输,则可以考虑使用pigz/pbiz2

    注2:使用pv观察,网络流量约80MB,所以使用nc替换ssh并不会有明显的性能提升

    注3:lz4压缩使用-B4(64KB块大小),解压使用-B7(4MB块大小),是本案例的测试最优值

    2. 关于lz4

    lz4是一个让"人见人爱、花见花开"的压缩算法,能够在多核上很好的扩展,压缩速度和压缩比并没有太大优势(pigz),但是他的解压速度非常惊人,本案例测试lz4的解压是gunzip的3倍(更多的对比测试)。因为压缩时高效的多核利用,,再加上惊艳的解压,lz4已经在非常多重要场合使用了:Linux3.11内核实现了LZ4,并可以使用其压缩和解压kernel image HBase:Add an LZ4 compression option to HFile等等(参考)。

    对于需要频繁压缩、实时快速解压的场景来说,lz4非常适合。

    3. 性能环境说明

    这里使用同上一篇文章相同的两台主机环境:ping获得RTT是17ms;使用iperf测试带宽是115MB(参考附录);

    整个过程有几个阶段:磁盘读取-->打包(tar)-->压缩-->传输-->解压缩-->拆包-->落盘 对应了的速度测试:

    3.1 磁盘读取和落盘

    磁盘读取(有page cache),能到3GB/s;磁盘写入约428MB:

    # dd if=./sendlog.tar of=/dev/null bs=4096 count=1048576 1024002+1 records in 1024002+1 records out 4194314240 bytes (4.2 GB) copied, 1.33946 s, 3.1 GB/s # dd if=/dev/zero of=./x.zero.file bs=4096 count=1048576 1048576+0 records in 1048576+0 records out 4294967296 bytes (4.3 GB) copied, 10.0306 s, 428 MB/s

    3.2 打包、拆包

    打包和拆包速度都大于350MB/s:

    # time tar -cf sendlog.tar ./sendlog/ real 0m10.996s # time tar -xf sendlog.tar real 0m11.564s

    3.3 压缩、解压缩

    关于各个压缩工具的性能(压缩、解压、压缩率)已经有很多人做了比较,本文不做详细讨论,这里选择gzip/pigz lz4 bzip做本测试的比较:

    | input speed | output speed | rate | speed of decoder pigz -p 16 | 327.0MB/s | 57.2MB/s | 17.5% | 95 MB/s lz4 | 288.0MB/s | 79.2MB/s | 27.5% | 264 MB/s bzip2 | 4.9MB/s | 0.65MB/s | 13.1% | 25.6MB /s

    压缩工具的比较测试参考:

    可以看到,lz4在压缩率上略微逊色(对比pigz),但是在解压速度上有这惊人的优势。

    linux

    Statement
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Windows 11 中的 Telnet 完整教程 [安装/启用和故障排除]Windows 11 中的 Telnet 完整教程 [安装/启用和故障排除]May 22, 2023 pm 09:35 PM

    <p>Telnet是“终端网络”的简称。它是用户可以用来将一台计算机连接到本地计算机的协议。</p><p>这里,本地计算机是指启动连接的设备,而连接到本地计算机的计算机称为远程计算机。</p><p>Telnet在客户端/服务器主体上运行,虽然它已经过时,但在2022年它仍然被许多人使用。许多人已经转向Windows11操作系统,这是微软提供的最新操作系统。&

    如何从 iPad SSH 到 Mac如何从 iPad SSH 到 MacApr 14, 2023 pm 12:22 PM

    如何从 iPad SSH 到 Mac这是一个两部分的演练。首先,您将在 Mac 上启用 SSH 服务器,然后您将使用 ssh 客户端应用程序从 iPad 连接到它。在 Mac 上,启动 SSH 服务器您可以通过打开名为 Remote Login 的功能在 Mac 上启用 SSH 服务器。转到 Apple 菜单 > 系统偏好设置 > 共享 > 启用“远程登录”,并选中“允许远程用户完全访问磁盘”框Mac 现在是一个 SSH 服务器,为您提供从 iPad 连接的 shell。注意

    Python服务器编程:使用Paramiko实现SSH远程操作Python服务器编程:使用Paramiko实现SSH远程操作Jun 18, 2023 pm 01:10 PM

    随着云计算和物联网的发展,远程操作服务器变得越来越重要。在Python中,我们可以使用Paramiko模块来轻松实现SSH远程操作。在本文中,我们将介绍Paramiko的基本用法,以及如何在Python中使用Paramiko来远程管理服务器。什么是ParamikoParamiko是一个用于SSHv1和SSHv2的Python模块,可以用于连接和控制SSH客户

    Python基于ssh远程怎么连接Mysql数据库Python基于ssh远程怎么连接Mysql数据库May 27, 2023 pm 04:07 PM

    背景如果需要访问远程服务器的Mysql数据库,但是该Mysql数据库为了安全期间,安全措施设置为只允许本地连接(也就是你需要登录到该台服务器才能使用),其他远程连接是不可以直接访问,并且相应的端口也做了修改,那么就需要基于ssh来连接该数据库。这种方式连接数据库与Navicat里面界面化基于ssh连接一样。Navicat连接数据库安装支持库如果要连接Mysql,首先需要安装pymysqlpipinstallpymysql安装基于ssh的库sshtunnelpipinstallsshtunnel#

    linux自带有ssh吗linux自带有ssh吗Apr 06, 2023 pm 03:55 PM

    linux自带有ssh。linux系统会自带ssh软件,默认就是OpenSSH相关软件包,并将ssh服务添加为开机自启动,可以通过“ssh -V”命令来查看安装的ssh版本信息。执行“systemctl start sshd”命令即可启动sshd服务,默认端口使用的22端口。

    CentOS 7.9 安装及centos 7.9 安装sshCentOS 7.9 安装及centos 7.9 安装sshFeb 13, 2024 pm 10:30 PM

    在进行服务器搭建或者系统管理时,CentOS7.9是一个非常常用的操作系统版本,本文将为您提供关于CentOS7.9安装以及安装SSH的详细步骤和说明。CentOS7.9是一个免费且开源的Linux操作系统,它是基于RedHatEnterpriseLinux(RHEL)的二进制兼容版本,下面是CentOS7.9安装的步骤:1.您需要下载CentOS7.9的ISO镜像文件,您可以从CentOS官方网站上下载最新的CentOS7.9ISO镜像文件。2.在您的计算机上创建一个新的虚拟机或者物理机,并将

    Ansible工作原理详解Ansible工作原理详解Feb 18, 2024 pm 05:40 PM

    Ansible工作原理从上面的图上可以了解到:管理端支持local、ssh、zeromq三种方式连接被管理端,默认使用基于ssh的连接,这部分对应上面架构图中的连接模块;可以按应用类型等方式进行HostInventory(主机清单)分类,管理节点通过各类模块实现相应的操作,单个模块,单条命令的批量执行,我们可以称之为ad-hoc;管理节点可以通过playbooks实现多个task的集合实现一类功能,如web服务的安装部署、数据库服务器的批量备份等。playbooks我们可以简单的理解为,系统通过

    Linux怎么检查SSH版本Linux怎么检查SSH版本Feb 15, 2023 am 11:28 AM

    检查方法:1、用文本编辑器打开“/etc/ssh/sshd_config”,查看“Protocol”字段,若显示“Protocol 2”就代表服务器只支持SSH2,若显示“Protocol 1”就代表服务器同时支持两者。2、强制ssh使用特定的SSH协议,通过查看SSH服务器的响应来判断。3、使用scanssh工具,语法“sudo scanssh -s ssh ip地址”。

    See all articles

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    AI Hentai Generator

    AI Hentai Generator

    Generate AI Hentai for free.

    Hot Article

    R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
    2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    Repo: How To Revive Teammates
    4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    Hello Kitty Island Adventure: How To Get Giant Seeds
    4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

    Hot Tools

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SecLists

    SecLists

    SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

    MantisBT

    MantisBT

    Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

    mPDF

    mPDF

    mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

    ZendStudio 13.5.1 Mac

    ZendStudio 13.5.1 Mac

    Powerful PHP integrated development environment