https://github.com/fathyb/zstd-proxy
High-performance real-time TCP compression
https://github.com/fathyb/zstd-proxy
Last synced: 10 months ago
JSON representation
High-performance real-time TCP compression
- Host: GitHub
- URL: https://github.com/fathyb/zstd-proxy
- Owner: fathyb
- Created: 2022-10-20T10:37:50.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-12-19T23:22:46.000Z (over 3 years ago)
- Last Synced: 2025-03-14T15:51:50.038Z (over 1 year ago)
- Language: C
- Size: 48.8 KB
- Stars: 78
- Watchers: 6
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# zstd-proxy
High-performance TCP/UNIX proxy with Zstd compression, with Node.js bindings.
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`, compress `9001` to `9002` and decompress `9002` to `9001`
```console
$ zstd-proxy --listen=9001 --connect=9002 --compress=listen
```
- Create a server on port `9002`, compress `9003` to `9002` and decompress `9002` to `9003`
```console
$ zstd-proxy --listen=9002 --connect=9003 --compress=connect
```
### Library
- Create a server on port `9001`, compress `9001` to `9002` and decompress `9002` to `9001`
```ts
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`, compress `9003` to `9002` and decompress `9002` to `9003`
```ts
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)
```