Skip to content

Commit

Permalink
Update compression docs (apache#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 authored Feb 2, 2024
1 parent 2cc67a7 commit 5afb2d2
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 23 deletions.
45 changes: 44 additions & 1 deletion _docs/en/administration/compression.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,47 @@
permalink: administration/compression
---

TRANSLATING
# Compression on the client side

Please refer to the [Java client - Data Serialization](/clients/java-client#data-serialization) and [Java client - Data Compression](/clients/java-client#data-compression).

# Compression on the server side

It's recommended:
* For the server with low CPU load, use the `zstd` algorithm with the highest compression ratio.
* For the server with high CPU load, use the `lz4` algorithm with good compression rate and speed.

The compression algorithms supported by the Pegasus server:
* snappy
* lz4 (Since Pegasus v1.11.2)
* zstd (Since Pegasus v1.11.2)

Configure the compression algorithm through [Configurations](config), for example:
```ini
[pegasus.server]
rocksdb_compression_type = lz4
```

Comparison of different compression algorithms (from [zstd official benchmark](https://facebook.github.io/zstd/)):

| Compressor name | Ratio | Compression (MB/s) | Decompress (MB/s) |
|------------------|-------|--------------------|-------------------|
| zstd 1.3.4 -1 | 2.877 | 470 | 1380 |
| zlib 1.2.11 -1 | 2.743 | 110 | 400 |
| brotli 1.0.2 -0 | 2.701 | 410 | 430 |
| quicklz 1.5.0 -1 | 2.238 | 550 | 710 |
| lzo1x 2.09 -1 | 2.108 | 650 | 830 |
| lz4 1.8.1 | 2.101 | 750 | 3700 |
| snappy 1.1.4 | 2.091 | 530 | 1800 |
| lzf 3.6 -1 | 2.077 | 400 | 860 |

![compression-comparation.png](/assets/images/compression-comparation.png){:class="img-responsive"}

This result is consistent with [lz4 official benchmark](https://github.com/lz4/lz4#benchmarks).

[Compression algorithm suggestions from RocksDB official](https://github.com/facebook/rocksdb/wiki/Compression):
> Use options.compression to specify the compression to use. By default it is Snappy. We believe LZ4 is almost always better than Snappy. We leave Snappy as default to avoid unexpected compatibility problems to previous users. LZ4/Snappy is lightweight compression so it usually strikes a good balance between space and CPU usage.
> If you want to further reduce the in-memory and have some free CPU to use, you can try to set a heavy-weight compression in the latter by setting options.bottommost_compression. The bottommost level will be compressed using this compression style. Usually the bottommost level contains majority of the data, so users get almost optimal space setting, without paying CPU for compress all the data ever flowing to any level. We recommend ZSTD. If it is not available, Zlib is the second choice.
> If you want have a lot of free CPU and want to reduce not just space but write amplification too, try to set options.compression to heavy weight compression type. We recommend ZSTD. Use Zlib if it is not available.
43 changes: 21 additions & 22 deletions _docs/zh/administration/compression.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,45 @@ permalink: administration/compression

# 客户端压缩

请参考 [Java客户端文档#数据序列化](/clients/java-client#数据序列化)[Java客户端文档#数据压缩](/clients/java-client#数据压缩)
请参考 [Java 客户端 - 数据序列化](/clients/java-client#数据序列化)[Java 客户端 - 数据压缩](/clients/java-client#数据压缩)

# 服务端压缩

**把总结放在最前面:**
* 对于CPU比较空闲的场景,建议采用压缩率高的`zstd`算法。
* 对于CPU比较繁忙的场景,建议采用综合性能比较优异的`lz4`算法。
建议:
* 对于 CPU 比较空闲的服务器,采用压缩率最高的 `zstd` 算法。
* 对于 CPU 比较繁忙的服务器,采用压缩率和速度都比较好的 `lz4` 算法。

Pegasus服务端支持的压缩算法
Pegasus 服务端支持的压缩算法
* snappy
* lz4 (从v1.11.2版本开始支持)
* zstd (从v1.11.2版本开始支持)
* lz4 (从 v1.11.2 版本开始支持)
* zstd (从 v1.11.2 版本开始支持)

通过[配置文件](config)来配置压缩算法,譬如
通过 [配置文件](config) 来配置压缩算法,例如
```ini
[pegasus.server]
rocksdb_compression_type = lz4
```

不同压缩算法的比较(数据来自[zstd官方的benchmark](https://facebook.github.io/zstd/)):
不同压缩算法的比较(数据来自 [zstd 官方的 benchmark](https://facebook.github.io/zstd/)):

Compressor name | Ratio | Compression(MB/s) | Decompress(MB/s)
-- | -- | -- | --
zstd 1.3.4 -1 | 2.877 | 470 | 1380
zlib 1.2.11 -1 | 2.743 | 110 | 400
brotli 1.0.2 -0 | 2.701 | 410 | 430
quicklz 1.5.0 -1 | 2.238 | 550 | 710
lzo1x 2.09 -1 | 2.108 | 650 | 830
lz4 1.8.1 | 2.101 | 750 | 3700
snappy 1.1.4 | 2.091 | 530 | 1800
lzf 3.6 -1 | 2.077 | 400 | 860
| Compressor name | Ratio | Compression (MB/s) | Decompress (MB/s) |
|------------------|-------|--------------------|-------------------|
| zstd 1.3.4 -1 | 2.877 | 470 | 1380 |
| zlib 1.2.11 -1 | 2.743 | 110 | 400 |
| brotli 1.0.2 -0 | 2.701 | 410 | 430 |
| quicklz 1.5.0 -1 | 2.238 | 550 | 710 |
| lzo1x 2.09 -1 | 2.108 | 650 | 830 |
| lz4 1.8.1 | 2.101 | 750 | 3700 |
| snappy 1.1.4 | 2.091 | 530 | 1800 |
| lzf 3.6 -1 | 2.077 | 400 | 860 |

![compression-comparation.png](/assets/images/compression-comparation.png){:class="img-responsive"}

这个结果与[lz4官方的benchmark](https://github.com/lz4/lz4#benchmarks)也是一致的
这个结果与 [lz4 官方的 benchmark](https://github.com/lz4/lz4#benchmarks) 是一致的

附上[RocksDB的压缩建议](https://github.com/facebook/rocksdb/wiki/Compression)
附上 [RocksDB 的压缩建议](https://github.com/facebook/rocksdb/wiki/Compression)
> Use options.compression to specify the compression to use. By default it is Snappy. We believe LZ4 is almost always better than Snappy. We leave Snappy as default to avoid unexpected compatibility problems to previous users. LZ4/Snappy is lightweight compression so it usually strikes a good balance between space and CPU usage.
> If you want to further reduce the in-memory and have some free CPU to use, you can try to set a heavy-weight compression in the latter by setting options.bottommost_compression. The bottommost level will be compressed using this compression style. Usually the bottommost level contains majority of the data, so users get almost optimal space setting, without paying CPU for compress all the data ever flowing to any level. We recommend ZSTD. If it is not available, Zlib is the second choice.
> If you want have a lot of free CPU and want to reduce not just space but write amplification too, try to set options.compression to heavy weight compression type. We recommend ZSTD. Use Zlib if it is not available.

0 comments on commit 5afb2d2

Please sign in to comment.