EV-ClickHouse
view release on metacpan or search on metacpan
"chunked response too large", or "gzip body exceeds max\_recv\_buffer")
and the connection is torn down so no subsequent query can slip past
the cap on the same socket. `0` (default) keeps the historical
no-cap behaviour (still bounded internally by a hard 128 MB ceiling
on compressed paths). Recommended in production when the schema is
constrained and you want a hard upper bound (e.g.
`128 * 1024 * 1024` for 128 MB).
- http\_basic\_auth => 0 | 1
HTTP only. When set, send credentials as
`Authorization: Basic base64(user:password)` instead of the default
`X-ClickHouse-User` / `X-ClickHouse-Key` header pair. Use this when
the connection passes through an HTTP gateway (nginx, Envoy, ...) that
strips the X-ClickHouse-\* headers but forwards Basic auth verbatim.
Default: `0`.
- auto\_reconnect => 0 | 1
Reconnect automatically on connection loss. Default: `0`. When enabled,
queued (unsent) queries are preserved across reconnects; in-flight queries
`on_data => sub { }` in the per-query settings is the
lowest-overhead streaming path: each native data block is delivered as
soon as the parser has it, no per-row allocation overhead beyond the
batch arrayref. `iterate` is a synchronous-feeling pull wrapper around
the same machinery - useful when the surrounding code is procedural
(ETL scripts, exporters) and a callback shape doesn't fit. Both are
native-only.
- Connection in front of nginx / reverse proxy strips X-ClickHouse-\* headers
Pass `http_basic_auth => 1` to send the credentials as
`Authorization: Basic ...` instead. Most HTTP gateways forward
Authorization verbatim while filtering proprietary headers.
# TUNING
- Native vs HTTP
Native (port 9000) is typically 2-5x faster for insert and select-of-many-rows
because rows ship as binary columns instead of TSV text. Use HTTP only when
the network path requires HTTPS-only or when you need `raw => 1` CSV /
eg/auth_proxy.pl view on Meta::CPAN
#!/usr/bin/env perl
# HTTP basic auth behind a reverse proxy. Many gateway setups
# (nginx, Envoy, k8s ingress) strip the proprietary X-ClickHouse-User
# and X-ClickHouse-Key headers but forward Authorization verbatim.
# Pass http_basic_auth => 1 to send credentials as
# `Authorization: Basic base64(user:password)` instead.
#
# Pair with `auth_request` / `proxy_pass` in nginx, JWT middleware
# in Envoy, etc. â the client side is the same regardless.
use strict;
use warnings;
use EV;
use EV::ClickHouse;
my $host = $ENV{CLICKHOUSE_HOST} // '127.0.0.1';
lib/EV/ClickHouse.pm view on Meta::CPAN
"chunked response too large", or "gzip body exceeds max_recv_buffer")
and the connection is torn down so no subsequent query can slip past
the cap on the same socket. C<0> (default) keeps the historical
no-cap behaviour (still bounded internally by a hard 128 MB ceiling
on compressed paths). Recommended in production when the schema is
constrained and you want a hard upper bound (e.g.
C<128 * 1024 * 1024> for 128 MB).
=item http_basic_auth => 0 | 1
HTTP only. When set, send credentials as
C<Authorization: Basic base64(user:password)> instead of the default
C<X-ClickHouse-User> / C<X-ClickHouse-Key> header pair. Use this when
the connection passes through an HTTP gateway (nginx, Envoy, ...) that
strips the X-ClickHouse-* headers but forwards Basic auth verbatim.
Default: C<0>.
=item auto_reconnect => 0 | 1
Reconnect automatically on connection loss. Default: C<0>. When enabled,
queued (unsent) queries are preserved across reconnects; in-flight queries
lib/EV/ClickHouse.pm view on Meta::CPAN
C<<< on_data =E<gt> sub { } >>> in the per-query settings is the
lowest-overhead streaming path: each native data block is delivered as
soon as the parser has it, no per-row allocation overhead beyond the
batch arrayref. C<iterate> is a synchronous-feeling pull wrapper around
the same machinery - useful when the surrounding code is procedural
(ETL scripts, exporters) and a callback shape doesn't fit. Both are
native-only.
=item Connection in front of nginx / reverse proxy strips X-ClickHouse-* headers
Pass C<<< http_basic_auth =E<gt> 1 >>> to send the credentials as
C<Authorization: Basic ...> instead. Most HTTP gateways forward
Authorization verbatim while filtering proprietary headers.
=back
=head1 TUNING
=over 4
=item Native vs HTTP
( run in 3.141 seconds using v1.01-cache-2.11-cpan-cdf2f3d4e48 )