zstd-proxy 中文文档教程
zstd-proxy
具有 Zstd 压缩和 Node.js 绑定的高性能 TCP/UNIX 代理。
这是为 Refloat CI 中的块存储基础设施构建的,针对低数量(< 100)的中等寿命连接(~ 3 分钟)、高吞吐量(~ 500Mbps)和低延迟要求(< 1ms)进行了优化。它在 Linux 上使用具有固定缓冲区的 io_uring 进行传输,无需任何系统调用。
可以启用可选的零拷贝发送模式,但它需要 Linux 6 并且似乎在 ARM 上崩溃。
使用
CLI
- 在端口
9001
上创建服务器,将9001
压缩为9002
并将9002
解压缩为9001< /code>
$ zstd-proxy --listen=9001 --connect=9002 --compress=listen
- 在端口
9002
上创建服务器,将9003
压缩为9002
并将9002
解压为9003
$ zstd-proxy --listen=9002 --connect=9003 --compress=connect
库
- 在端口
9001
上创建服务器,将9001
压缩为9002
并将9002
解压为9001
import { zstdProxy } from 'zstd-proxy'
createServer({ pauseOnConnect: true })
.on('connection', server => {
const client: Socket = connect(9002)
.on('connect', () => zstdProxy({ compress: server, to: client }))
})
.listen(9001)
- 在端口
9002
上创建服务器,将9003
压缩为9002
并将9002
解压缩为<代码>9003
import { zstdProxy } from 'zstd-proxy'
createServer({ pauseOnConnect: true })
.on('connection', server => {
const client: Socket = connect(9003)
.on('connect', () => zstdProxy({ compress: client, to: server }))
})
.listen(9002)
zstd-proxy
High-performance TCP/UNIX proxy with Zstd compression, with Node.js bindings.
This is built for the block storage infrastructre in Refloat CI, optimized for a low count (< 100) of medium-lived connections (~ 3 minutes) with high-throughput (~ 500Mbps) and low-latency requirements (< 1ms). It uses io_uring on Linux with fixed buffers to transmit without any syscall.
An optional zero-copy send mode can be enabled, but it requires Linux 6 and seems to crash on ARM.
Usage
CLI
- Create a server on port
9001
, compress9001
to9002
and decompress9002
to9001
$ zstd-proxy --listen=9001 --connect=9002 --compress=listen
- Create a server on port
9002
, compress9003
to9002
and decompress9002
to9003
$ zstd-proxy --listen=9002 --connect=9003 --compress=connect
Library
- Create a server on port
9001
, compress9001
to9002
and decompress9002
to9001
import { zstdProxy } from 'zstd-proxy'
createServer({ pauseOnConnect: true })
.on('connection', server => {
const client: Socket = connect(9002)
.on('connect', () => zstdProxy({ compress: server, to: client }))
})
.listen(9001)
- Create a server on port
9002
, compress9003
to9002
and decompress9002
to9003
import { zstdProxy } from 'zstd-proxy'
createServer({ pauseOnConnect: true })
.on('connection', server => {
const client: Socket = connect(9003)
.on('connect', () => zstdProxy({ compress: client, to: server }))
})
.listen(9002)