vectordotdev / vectordotdev/vector

Add block-level compression for ClickHouse sink (ArrowStream)

Open
#25,756 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
22.6k
Forks
2.3k
Avg merge
1d 7h
Merged PRs (30d)
146

Description

A note for the community
  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
Use Cases

Today the only way to compress an ArrowStream payload is a whole-payload HTTP gzip Content-Encoding.

This is effective on size but expensive on CPU, which is important in high-throughput scenarios with ArrowStream.

Ideally we can compress the payload that keeps CPU cost low on the Vector agent and let ClickHouse decompress efficiently on ingest (particularly when egress bandwidth is metered e.g. cross-region / cross-cloud).

Attempted Solutions

Today the only option is a whole-payload HTTP gzip Content-Encoding — good on size, heavy on CPU. Arrow IPC's own block-level (columnar) compression (LZ4/ZSTD) is cheaper but isn't exposed through the sink.

Local benchmark (50k-row batch, ~7.95 MB uncompressed Arrow IPC, single-threaded encode).

Method Compressed size Encode time Throughput (1 core) vCPU @ 200k rows/s
HTTP gzip (current) ~2.17 MB ~203 ms ~39 MB/s ~0.81
IPC LZ4_FRAME ~4.34 MB ~7 ms ~1200 MB/s ~0.03
IPC ZSTD ~2.55 MB ~15 ms ~528 MB/s ~0.06

On the Clickhouse side, median decode CPU for a 200k INSERT seems to be actually lower compared to the gzip path as well: ZSTD ~14 ms, LZ4 ~18 ms, uncompressed ~18 ms, gzip Content-Encoding ~28 ms

Proposal

Add a compression option to the clickhouse sink's arrow_stream batch encoding, applied as Arrow IPC block compression:

sinks:
  my_clickhouse:
    type: clickhouse
    inputs: [my_source]
    endpoint: http://clickhouse:8123
    database: mydb
    table: mytable
    format: arrow_stream
    batch_encoding:
      codec: arrow_stream
      compression: zstd   # one of: none (default) | lz4_frame | zstd
References

No response

Version

0.57.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the ClickHouse sink's arrow_stream batch encoding path and inspect how the existing HTTP gzip option and codec configuration are handled. Add support for the proposed none, lz4_frame, and zstd compression values, keeping none as the default, and verify that the resulting ArrowStream payload is accepted by ClickHouse.

Written by the indexing model from the issue text.

Assessment

Tech stack
clickhouse, rust
Domain
data-engineering, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.