Support Clickhouse's TCP interface
Vector Version
vector 0.16.1 (x86_64-unknown-linux-gnu 739e878 2021-08-26)
Vector Configuration File
[sources.kfk_in]
type = "kafka"
bootstrap_servers = "10.1.0.17:9092"
group_id = "vector"
topics = [ "CVAPI-SIT" ]
[sinks.click]
type = "clickhouse"
inputs = [ "kfk_in" ]
database = "mydatabase"
endpoint = "tcp://10.xx.xx.xx:9000"
table = "vector_test"
compression = "gzip"
[sinks.out]
inputs = ["kfk_in"]
type = "console"
encoding = "text"
Debug Output
Expected Behavior
ok, http or tcp
Actual Behavior
vector::topology::builder: msg="Healthcheck: Failed Reason." error=Unexpected status: 400 Bad Request component_kind="sink" component_type="clickhouse"
Example Data
Additional Context
References
Hi @seanjoe . As you note, Vector only supports Clickhouse's HTTP interface. I'll mark this as an enhancement to add support for the native TCP interface.
Are you able to use the HTTP interface instead? Or is there a particular reason you want to use the TCP interface?
Hi @seanjoe . As you note, Vector only supports Clickhouse's HTTP interface. I'll mark this as an enhancement to add support for the native TCP interface.
Are you able to use the HTTP interface instead? Or is there a particular reason you want to use the TCP interface?
I'm a newer for vector. when I use it with tcp proto, there was considerable trouble for me. when I transfer to http proto, it work well.
Copying a note from https://github.com/vectordotdev/vector/issues/13701 that we will want to make sure that this is instrumented with latency metrics:
And before swtiching to tcp + native protocol, I suggest that we can add more metrics data to observe the insert performance:
histogram: remote_write_request_duration_seconds
It would be a huge effort to implement the protocol from scratch, but fortunately there's a klickhouse rust client library that uses the native TCP protocol. In my experience it's significantly (more than 10x) faster than the HTTP(S) proto.
Although it's sad to admit, according to https://github.com/vectordotdev/vector/pull/15660#issuecomment-1406935577, it seems there are no plans to support ClickHouse native protocol, as it's unstable and requires a lot of boilerplate code to be introduced to the Vector codebase. ClickHouse MySQL Interface seems to be the way, as it's also binary and more stable. Should this issue be closed then in favor of https://github.com/vectordotdev/vector/issues/6556?
I'm curious what @pront thinks, but I think the question for all of these alternate protocols for Clickhouse would require a comparison of pros/cons of each (performance, maintenance burden, other trade-offs, etc.). Granted, we likely want to implement the MySQL protocol, anyway, to integrate with MySQL.
https://github.com/vectordotdev/vector/issues/6556 (new MySQL sink) is one of the most upvoted issues in our repo so I think it is a win-win if we can implement it and use it for Clickhouse integration as well. We can take it from there and evaluate performance MySQL --> Clickhouse performance.
ClickHouse native procotol is the by-default high-performance data ingestion protocol when using ClickHouse. Intuitively the native protocol will eliminate one JSON serialization/deserialization, removing HTTP transaction management and line-based framing. These will make native TCP use less CPU than HTTP, increasing the maximum throughput. (Previous discussion noted HTTP protocol has lower latency than TCP. I've not tested it, but low-latency and high-throughput are two different scenarios and requires different optimizations)
Since ClickHouse is very popular in observability and OLAP use-case, I think it's reasonable to support its specialized protocol, instead of using less-popular MySQL/PG adapters.
Now we have klickhouse, a stable implementation of ClickHouse TCP protocol. We've been using it in our production environment, no issue. This makes adding the protocol without maintaining the protocol by ourself possible.
I can help implement and benchmark the TCP native protocol - please consider adding this if in high-throughput scenario and we reuse the klickhouse crate instead of writing it by ourself. This will make Vector more versatile.
Clickhouse put together an analysis of Input formats. Native clearly wins.
Clickhouse put together an analysis of Input formats. Native clearly wins.
Native does look like the overall winner, but it looks like ArrowSteam was recently added in https://github.com/vectordotdev/vector/pull/24373, arrow_stream Docs
I guess it depends on your goals, but ArrowStream and Native appear neck and neck. Native appears to be best for Inserts, where Arrow is more efficent per insert limited recourses It may depend on what's more important for someone's implementation. ~1% less compute or ~10% faster inserts.
ArrowStream is slightly more efficient per insert than Native, while Parquet is more efficient than RowBinary. However, Native achieves better compression (see the previous section), leading to faster overall inserts.
I'm guessing ArrowStream would be a large enough improvement on the current setup, without having to add more dependencies or effort.