Faster data transmission using tar + lz4/pigz + ssh

Source: Internet
Author: User

The previous article introduced how to extract the SCP transmission speed to the maximum extent. With this foundation, we can further use compression to accelerate the transmission speed. Only scp is used, and the transmission rate is about 90 MB at the earliest. This article uses compression to increase the transmission rate to about 250 MB/s (including the decompression process ).

Directory

  • 1. Conclusion
  • 2. About lz4
  • 3. Performance Environment Description
    • 3.1 disk read and drop
    • 3.2 package and unpack
    • 3.3 compression and decompression
    • 3.4 Transmission
    • 3.5 overall process
  • 4. Experiment Test
    • 4.1 Analysis
  • 5. lz4 Parameter Test
  • 5. Why not use nc?
  • 6. Can it be faster?
  • Appendix
  • Read more
1. Conclusion

Use tar + lz4 + ssh to achieve maximum transmission performance:

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. 067 s user 0m15. 553 s sys 0m16. 821 s

249 MB/s. It is 6 times the original scp (40 MB/s). It takes about 3 hours for the original GB transmission, and now it takes only 27 minutes.

Note 1: lz4's excellent decompression performance makes him very important in this case. If you do not need to decompress the transfer, you can consider using pigz/pbiz2

NOTE 2: using pv observation, the network traffic is about 80 MB, so replacing ssh with nc does not significantly improve performance.

NOTE 3: lz4 adopts-B4 (64 KB) for compression and-B7 (4 MB) for decompression, which is the optimal value in this case.

2. About lz4

Lz4 is a compression algorithm that enables "seeing people, seeing flowers and flowers". It can be well expanded on multiple cores, and Its compression speed and compression ratio do not have much advantage (pigz ), however, his decompression speed is amazing. In this case, the lz4 decompression speed is three times that of gunzip (more comparative tests ). Because of the efficient multi-core utilization during compression, coupled with amazing decompression, lz4 has been used in many important occasions: the Linux 3.11 kernel implements LZ4, it can also be used to compress and decompress the kernel image HBase: Add an LZ4 compression option to HFile and so on (refer ).

Lz4 is suitable for scenarios that require frequent compression and real-time decompression.

3. Performance Environment Description

Here we use the same two host environments as the previous article: ping to get RTT is 17 ms; Use iperf to test bandwidth is 115 MB (refer to the appendix );

There are several stages in the process: disk reading, packaging, compression, transmission, decompression, unpacking, and disk storage. The speed test is as follows:

3.1 disk read and drop

Disk Read (with page cache), up to 3 GB/s; disk write is about 428 MB:

# 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/s3.2 packaging, unpacking

The packaging and unpacking speed is greater than 350 MB/s:

# Time tar-cf sendlog.tar./sendlog/real 0m10. 996 s # time tar-xf sendlog.tar real 0m11. 564s3. 3 compression and decompression

Many people have made comparisons on the performance (compression, decompression, and compression ratio) of each compression tool. This article will not discuss it in detail. Here, gzip/pigz lz4 bzip is selected for comparison in this test:

| 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

For more information about compression tools, see Gzip vs Bzip2 vs LZMA vs XZ vs LZ4 vs LZO.

As you can see, lz4 is slightly inferior in terms of compression ratio (compared with pigz), but it has this amazing advantage in decompression speed.

  • 1
  • 2
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.