bizon-rs (Native Streaming Worker)
bizon-rs is a native streaming worker for Bizon. It reads Kafka and writes to BigQuery through the Storage Write API. It reads bizon’s YAML format, accepting a strict subset of it, and writes byte-identical rows, so you can swap the worker without changing tables or downstream queries.
The current release is v0.6.0. Like bizon-core, it is licensed under GPL-3.0.
When to Use It
Section titled “When to Use It”Use bizon-rs in place of the Python worker for pipelines with this shape:
source.name: kafkawithsync_mode: streamdestination.name: bigquery_streaming_v2engine.runner.type: stream
Anything else, including other sources, destinations, runners, and sync modes, stays on bizon-core. See Supported Configuration for the exact subset.
Kafka ──▶ decode (Avro via schema registry | UTF-8 JSON) ──▶ built-in transform ──▶ proto row ◀── commit acknowledged offsets ◀── AppendRows on <table>/_default, one pipelined connection per tablePerformance
Section titled “Performance”| Measurement | bizon-rs | Python worker |
|---|---|---|
| CPU per row (Debezium sample, ~2 KB rows, one core) | ~6.6 µs | ~35–40 µs |
| Write throughput, one AppendRows connection from GKE | ~118 MiB/s sustained for 15 min (ack p50 146 ms, p99 250 ms) | — |
| Resident memory, low-volume CDC pipeline | tens of MiB | — |
One production deployment moved 23 Kafka pipelines (all six built-in types, 13 Kafka clusters, 93 pods) from the Python worker to bizon-rs, keeping the same tables. It compared one week on each worker:
| Python worker | bizon-rs | ||
|---|---|---|---|
| CPU used, average | 38.5 cores | 2.5 cores | 15× less |
| Memory used, average | 231 GB | 11 GB | 21× less |
| CPU per GB of Kafka traffic | 0.40 core-h | 0.048 core-h | 8.2× less |
| CPU per 1,000 rows written | 4.8 core-s | 0.47 core-s | 10× less |
| Pods OOM-killed | 10 | 0 | |
| Freshness p95, Debezium CDC tables | 2.7–3.4 min | 1.2 s |
The week on the Python worker carried 1.85× the traffic, so CPU per GB and CPU per row are the fairest ratios.
Install
Section titled “Install”Release Binaries
Section titled “Release Binaries”Each release publishes Linux tarballs for x86_64 and aarch64. The binaries are built on Debian 12 (bookworm), so they need glibc from Debian 12 or newer.
VERSION=v0.6.0curl -LO https://github.com/bizon-data/bizon-rs/releases/download/${VERSION}/bizon-stream-${VERSION}-x86_64-unknown-linux-gnu.tar.gztar -xzf bizon-stream-${VERSION}-x86_64-unknown-linux-gnu.tar.gz./bizon-stream --versionFor ARM, use aarch64-unknown-linux-gnu in place of x86_64-unknown-linux-gnu.
Container Image
Section titled “Container Image”A multi-arch image (linux/amd64, linux/arm64) is published to GHCR:
docker run --rm ghcr.io/bizon-data/bizon-rs:0.6.0 --help| Tag | Points to |
|---|---|
ghcr.io/bizon-data/bizon-rs:<version> | A release. The version has no leading v, for example 0.6.0. |
ghcr.io/bizon-data/bizon-rs:latest | The latest release |
The image is based on gcr.io/distroless/cc-debian12:debug-nonroot, and its entrypoint is bizon-stream. The debug variant includes busybox, so kubectl cp can fetch the output of capture.
From Source
Section titled “From Source”Building from source needs Rust 1.87+ and a C toolchain. librdkafka and protoc are vendored.
git clone https://github.com/bizon-data/bizon-rs.gitcd bizon-rscargo build --release -p bizon-stream # target/release/bizon-streamThe binary is called bizon-stream. The run, check-config, and capture commands take --config, which defaults to /app/config/config.yml.
| Command | Description |
|---|---|
run | Start the streaming worker |
check-config | Validate a config against what bizon-rs supports, then print the topic count, record schema count, transform, encoding, batch_size, and consumer_timeout |
capture | Read a sample of messages into parity fixtures, without joining the consumer group or committing |
append-smoke | Push synthetic rows through AppendRows to benchmark the write client |
bizon-stream check-config --config config.ymlbizon-stream run --config config.ymlbizon-stream capture --config config.yml --since 1h --out ./capturecapture Options
Section titled “capture Options”| Option | Default | Description |
|---|---|---|
--since | 1h | Start point: epoch milliseconds, or a duration ago such as 30m, 6h, or 2d |
--per-topic | 200 | Messages to capture per topic |
--max-wait-secs | 300 | Maximum time to wait for messages |
--topics | All topics in the config | A comma-separated subset of the config’s topics |
--out | Required | Output directory |
append-smoke Options
Section titled “append-smoke Options”append-smoke writes to a table with the schema id INTEGER REQUIRED, payload JSON, __inserted_at TIMESTAMP. It needs --rows, --duration-secs, or both, and stops at whichever limit it reaches first.
bizon-stream append-smoke --table my-project.scratch.smoke --duration-secs 60 --writers 2| Option | Default | Description |
|---|---|---|
--table | Required | Target table as project.dataset.table |
--rows | Unlimited | Rows per writer |
--duration-secs | Unlimited | Duration of the run |
--batch | 500 | Rows per request |
--row-bytes | 1024 | Approximate payload size per row |
--max-inflight | 4 | Requests in flight per writer |
--writers | 1 | Concurrent connections to the same table |
--endpoint | BIZON_RS_BQ_WRITE_ENDPOINT | Storage Write endpoint override |
--quota-project | — | Quota project for the requests |
Supported Configuration
Section titled “Supported Configuration”bizon-rs reads the same config file as the Python worker, but it accepts only a subset. check-config and startup reject anything outside that subset. Unknown keys are rejected as well, so run check-config before you switch a pipeline over.
Required Values
Section titled “Required Values”| Field | Required value |
|---|---|
source.name | kafka |
source.sync_mode | stream |
source.authentication.type | basic |
source.authentication.schema_registry_type | apicurio (the default) |
source.topics | A non-empty list. The streams: form is not supported. |
destination.name | bigquery_streaming_v2 |
destination.config.unnest | true |
destination.config.bq_max_rows_per_request | 10000 or less (default 5000) |
destination.config.record_schemas | One entry for every topic’s destination_id |
transforms | Exactly one transform, using either builtin or a recognised python template |
engine.runner.type | stream |
Honoured Fields
Section titled “Honoured Fields”Source
| Field | Default | Notes |
|---|---|---|
bootstrap_servers | Required | |
group_id | bizon | |
topics[].name, topics[].destination_id | Required | destination_id is project.dataset.table |
message_encoding | avro | avro or utf-8 (JSON) |
consumer_config | bizon’s defaults | Passed through to librdkafka. If you set it, your map replaces the defaults instead of merging with them. |
consumer_timeout | 10 | Seconds. Also caps BIZON_RS_LINGER_MS. |
batch_size | 100 | Accepted and printed by check-config. Batching uses bq_max_rows_per_request, bytes, and linger time instead. |
skip_message_empty_value | true | |
skip_message_invalid_keys | false | |
skip_message_on_decode_error | false | Does not cover schema registry outages. See Differences from the Python Worker. |
authentication.params.username, .password | Required | Sent as SASL PLAIN |
authentication.schema_registry_url, _username, _password | — | Apicurio base URL with basic auth. Schemas are fetched from /apis/registry/v2/ids/globalIds/{id}. |
When you leave consumer_config unset, the default is auto.offset.reset: earliest, enable.auto.commit: false, session.timeout.ms: 45000, max.poll.interval.ms: 600000, and security.protocol: SASL_SSL. bizon-rs always sets queued.max.messages.kbytes from BIZON_RS_QUEUE_KBYTES.
Destination
| Field | Default | Notes |
|---|---|---|
project_id, dataset_id | Required | |
dataset_location | US | Used for large-row load jobs |
bq_max_rows_per_request | 5000 | Maximum 10000 |
time_partitioning | — | type and field, used when a table is created |
record_schemas[].record_schema | Required | name, type, mode (default NULLABLE), description, default_value_expression |
record_schemas[].clustering_keys | — | Used when a table is created |
These fields are accepted but ignored: source.stream (used only as a metrics tag), source.force_ignore_checkpoint, source.timestamp_ms_name, destination.config.max_concurrent_threads, buffer_size, buffer_flush_timeout, engine.runner.log_level (use RUST_LOG instead), and the top-level monitoring block.
Environment Placeholders
Section titled “Environment Placeholders”BIZON_ENV_* values resolve from the environment, as they do in bizon-core. A string value that starts with BIZON_ENV_ is replaced by that variable’s value. The replacement is read as a YAML scalar, so "5000" becomes an integer. env://NAME values are resolved too, and an unset one is an error. Placeholders inside lists are not resolved, matching bizon-core.
An unset BIZON_ENV_* variable becomes null. A required field that ends up null fails validation, and the error lists the unset variables. Set every referenced variable before you run check-config.
Minimal Example
Section titled “Minimal Example”This config passes check-config on v0.6.0 when BIZON_ENV_BOOTSTRAP_SERVERS, BIZON_ENV_KAFKA_USERNAME, and BIZON_ENV_KAFKA_PASSWORD are set:
name: orders-events
source: name: kafka stream: topic sync_mode: stream bootstrap_servers: BIZON_ENV_BOOTSTRAP_SERVERS group_id: orders-events message_encoding: utf-8 batch_size: 1000 consumer_timeout: 30 topics: - name: app.events.orders destination_id: my-project.events.orders consumer_config: auto.offset.reset: earliest enable.auto.commit: false session.timeout.ms: 60000 security.protocol: SASL_SSL partition.assignment.strategy: cooperative-sticky authentication: type: basic params: username: BIZON_ENV_KAFKA_USERNAME password: BIZON_ENV_KAFKA_PASSWORD
destination: name: bigquery_streaming_v2 config: project_id: my-project dataset_id: events dataset_location: US unnest: true bq_max_rows_per_request: 5000 time_partitioning: type: DAY field: __inserted_at record_schemas: - destination_id: my-project.events.orders record_schema: # Fields of the JSON message key are spread into the row - {name: order_id, type: STRING, mode: NULLABLE} - {name: payload, type: JSON, mode: NULLABLE} - {name: __operation, type: STRING, mode: NULLABLE} - {name: __deleted, type: BOOLEAN, mode: NULLABLE} - {name: __cluster, type: STRING, mode: NULLABLE} - {name: __kafka_partition, type: INTEGER, mode: NULLABLE} - {name: __kafka_offset, type: INTEGER, mode: NULLABLE} - {name: __kafka_topic, type: STRING, mode: NULLABLE} - {name: __schema, type: JSON, mode: NULLABLE} - {name: __event_timestamp, type: TIMESTAMP, mode: NULLABLE} - {name: __inserted_at, type: TIMESTAMP, mode: NULLABLE, default_value_expression: CURRENT_TIMESTAMP()} clustering_keys: [order_id]
transforms: - label: events builtin: {name: json_events, cluster: my-cluster}
engine: runner: type: streamdocker run --rm -v $PWD:/app/config:ro \ -e BIZON_ENV_BOOTSTRAP_SERVERS -e BIZON_ENV_KAFKA_USERNAME -e BIZON_ENV_KAFKA_PASSWORD \ ghcr.io/bizon-data/bizon-rs:0.6.0 check-config# ok: 1 topics, 1 record schemas, transform JsonEvents { cluster: "my-cluster" }, encoding Utf8, batch_size 1000, consumer_timeout 30sFor Avro topics, set message_encoding: avro and add schema_registry_url, schema_registry_username, and schema_registry_password under authentication. See the Kafka source reference and the BigQuery destination reference for what each field means.
Built-in Transforms
Section titled “Built-in Transforms”bizon-rs never executes Python. Instead, it ships six native transforms that cover the common streaming shapes. Each one takes cluster, which is written to __cluster. Only debezium_unwrap takes another option.
| Built-in | Input | Row |
|---|---|---|
debezium_unwrap | Avro Debezium envelope | payload = after (before for deletes), plus operation, deleted flag, and record schema |
avro_events | Avro record | payload = the record. __schema = its top-level fields. |
cloudevents | JSON with CloudEvents headers | payload = value. ce_type and ce_id headers required, ce_time optional. |
cloudevents_enriched | JSON, any headers | As cloudevents, plus every header in headers. All ce_* headers optional. |
json_cdc | JSON {before, after} | payload = after, __before = before, plus the ce_type and ce_id headers |
json_events | JSON | payload = value |
Every built-in also spreads the message key’s fields into the row, and adds the Kafka partition, offset, and topic, plus __event_timestamp and __inserted_at.
transforms: - label: debezium builtin: name: debezium_unwrap cluster: my-cluster columns_to_remove: app.cdc.users: [password_hash]columns_to_remove is optional and set per topic. The listed columns are dropped from payload and from __schema.
transforms: - label: events builtin: {name: cloudevents, cluster: my-cluster}The other built-ins use the same short form: json_events, json_cdc, cloudevents_enriched, and avro_events.
Inline Python Transforms
Section titled “Inline Python Transforms”A config that carries an inline python: transform is accepted only when the code matches one of the six templates bundled in crates/bizon-stream/src/transform/templates/. bizon-rs selects the template by comparing the code, not the label. It then reads the per-pipeline literals from the code: the __cluster value and, for Debezium, the TOPIC_COLUMN_TO_FILTER deny-list. Any other Python is rejected at startup.
A transform must set exactly one of builtin or python. For general-purpose Python transforms on the Python worker, see Transforms.
Environment Variables
Section titled “Environment Variables”Settings that are not part of bizon’s config come from BIZON_RS_* variables, so the mounted config can stay identical to the Python worker’s.
| Variable | Default | Description |
|---|---|---|
BIZON_RS_INFLIGHT_BYTES | 64 MiB | Encoded bytes in flight before consuming pauses |
BIZON_RS_LINGER_MS | 1000 | Maximum time a partial batch waits. Capped at consumer_timeout. |
BIZON_RS_QUEUE_KBYTES | 16384 | librdkafka queued.max.messages.kbytes |
BIZON_RS_HEALTH_PORT | 8080 | Port for /healthz, /readyz, and /metrics |
BIZON_RS_DRAIN_SECS | 20 | Drain budget on SIGTERM |
BIZON_RS_DECODE_WINDOW | 4 | Messages decoded concurrently. Results still reach the tables in delivery order. |
BIZON_RS_APPEND_DEPTH | 4 | AppendRows requests in flight per table |
BIZON_RS_ENSURE_TABLES | true | Create and extend tables before appending. Set false to skip. |
BIZON_RS_STALL_SECS | 600 | /healthz fails once a consumed message has waited this long for its BigQuery ack. 0 disables the check. |
BIZON_RS_RECOMMIT_SECS | 21600 | How often idle partitions’ offsets are committed again, so the broker doesn’t expire them (KIP-211). 0 disables it. |
BIZON_RS_BQ_WRITE_ENDPOINT / BIZON_RS_BQ_REST_ENDPOINT | Endpoint overrides, for example http://127.0.0.1:50051 for the bundled fake-bqwrite |
Other environment variables:
| Variable | Description |
|---|---|
ENVIRONMENT | Offsets are committed only when this is production, matching bizon-core. In any other environment, a restart re-reads from the last committed offset. |
GOOGLE_APPLICATION_CREDENTIALS | Path to a service account key. Without it, credentials come from the metadata server or Workload Identity. |
RUST_LOG | Log filter, for example debug or bizon_stream=debug. Default info. |
HOSTNAME | Used for the static membership ID and the pod_name metrics tag |
DD_AGENT_HOST | Enables DogStatsD metrics. See Health and Metrics. |
Delivery Semantics
Section titled “Delivery Semantics”- At-least-once. For each partition, bizon-rs tracks the contiguous range of offsets whose rows BigQuery has acknowledged (or that were skipped), and commits only up to that point.
- Rebalancing. Set
partition.assignment.strategy: cooperative-stickyinconsumer_config, as in the example above. On a cooperative revoke, the worker flushes the revoked partitions, waits up to 10 seconds for their acks, and commits them before releasing them. - Static membership.
group.instance.iddefaults to<group_id>-$HOSTNAME, unlessconsumer_configsets it. A restarted pod rejoins without triggering a rebalance. - SIGTERM stops consuming, drains for up to
BIZON_RS_DRAIN_SECS, commits, and exits 0. - Pipeline errors drain and commit what is safe (never the failing message), then exit non-zero.
- Append retries. Retryable failures reconnect and resend unacknowledged requests. After a 5-minute retry budget, the worker exits.
- Idle partitions have their offsets committed again every
BIZON_RS_RECOMMIT_SECS. Otherwise the broker could expire them, andauto.offset.reset: earliestwould re-read the topic. - Large rows. Rows over 8 MiB go through a BigQuery load job instead of AppendRows.
- Tables are created with the configured
time_partitioningandclustering_keys. Existing tables only ever get new columns. Types, partitioning, and clustering never change. - Memory is bounded by bytes in flight, not by a record count.
Differences from the Python Worker
Section titled “Differences from the Python Worker”The rows are byte-identical, but some behaviour differs on purpose:
| Situation | Python worker | bizon-rs |
|---|---|---|
| Schema registry outage | Skips the messages under skip_message_on_decode_error, which loses data | Stops the worker |
| Storage Write responses | Ignored | Inspected. Per-row and in-response errors are fatal. |
INVALID_ARGUMENT from BigQuery | Retried for 4 minutes in every case | Retried only within 10 minutes of adding columns |
| Batching | Per poll | Streaming, per table, by count, bytes, and linger time. Request limits match, but batch boundaries differ. |
| Schema cache | Keyed by full message bytes, unbounded | Keyed by schema id |
__inserted_at is taken per message from the wall clock, so its values differ from the Python worker’s by microseconds. A scale-0 Avro decimal beyond 64 bits, and NaN or Infinity in a JSON-string key, stop both workers on the same message. Only the reported stage differs.
Health and Metrics
Section titled “Health and Metrics”The worker serves three endpoints on BIZON_RS_HEALTH_PORT (default 8080):
| Endpoint | Returns |
|---|---|
/healthz | 200 ok, or 503 stalled once the oldest unacknowledged message is older than BIZON_RS_STALL_SECS |
/readyz | 200 ready once partitions are assigned, 503 not ready before |
/metrics | Prometheus text, with every series prefixed bizon_rs_ |
Key series:
| Series | Type | Description |
|---|---|---|
bizon_rs_messages | counter | Messages consumed |
bizon_rs_skipped{reason} | counter | Skipped messages, with reason set to empty_value, invalid_key, or decode_error |
bizon_rs_rows_appended, bizon_rs_bytes_appended | counter | Rows and bytes acknowledged by BigQuery |
bizon_rs_append_requests, bizon_rs_append_latency_us_total | counter | AppendRows requests and their total ack latency |
bizon_rs_append_latency_us_max | gauge | Largest ack latency since the last DogStatsD push |
bizon_rs_append_retries | counter | Append retries |
bizon_rs_large_rows | counter | Rows sent through a load job |
bizon_rs_commits, bizon_rs_commit_failures, bizon_rs_recommits | counter | Offset commits, failed commits, and idle re-commits |
bizon_rs_partitions_assigned, bizon_rs_partitions_revoked | counter | Rebalance events |
bizon_rs_schema_changes | counter | Table schema changes |
bizon_rs_inflight_bytes | gauge | Encoded bytes in flight |
bizon_rs_assigned_partitions | gauge | Partitions currently assigned |
bizon_rs_oldest_unacked_secs | gauge | Age of the oldest consumed message that is still waiting for an ack (0 when none is pending) |
bizon_rs_consumer_lag{topic} | gauge | Committed-offset lag per topic, from librdkafka statistics |
DogStatsD
Section titled “DogStatsD”If DD_AGENT_HOST is set, the same series are sent to $DD_AGENT_HOST:8125 every 10 seconds as bizon_rs.*. They are tagged with pipeline, kafka_cluster (the transform’s cluster), version, and pod_name. Counters are sent as deltas.
Rows written per table are also sent as bizon-core’s bizon_pipeline.records_synced, using bizon-core’s tag keys (pipeline_name, pipeline_stream, pipeline_source, pipeline_destination, destination_id). As a result, existing Bizon dashboards cover both workers. Large rows are also counted in bizon_pipeline.large_records.
Deploying on Kubernetes
Section titled “Deploying on Kubernetes”bizon-rs reads the same mounted config.yml as the Python worker, by default at /app/config/config.yml. To switch a pipeline, change the image and command, remove the unsupported engine keys, and add the BIZON_RS_* variables you need. For the Python-worker setup this replaces, see the Kafka to BigQuery tutorial.
- Probes. Point the liveness probe at
/healthzand the readiness probe at/readyz. A liveness failure restarts a worker whose writes have stopped making progress. - Memory. The memory ceiling is set by
BIZON_RS_INFLIGHT_BYTESplusBIZON_RS_QUEUE_KBYTES, on top of a small baseline. Leave headroom for large messages: a 35-minute soak with bursty 15–30 KB JSON messages held steady at 453–464 MiB resident. - Shutdown. Keep
terminationGracePeriodSecondsaboveBIZON_RS_DRAIN_SECS, so that the drain and the final commit can finish. - Static membership. A member that leaves does not send LeaveGroup. When you scale down, its partitions wait for
session.timeout.msbefore they are reassigned. The same mechanism lets a restarted pod rejoin without a rebalance. - Spread pods across nodes. In the production deployment above, the whole fleet fit on one preemptible node, and every replacement of that node restarted all pods. Those restarts set the worst-case freshness, at about 4 minutes.
A container spec fragment:
containers: - name: bizon-rs image: ghcr.io/bizon-data/bizon-rs:0.6.0 args: ["run", "--config", "/app/config/config.yml"] env: - name: ENVIRONMENT value: production - name: BIZON_RS_INFLIGHT_BYTES value: "67108864" ports: - name: health containerPort: 8080 livenessProbe: httpGet: {path: /healthz, port: health} readinessProbe: httpGet: {path: /readyz, port: health} volumeMounts: - name: config mountPath: /app/configAdd the BIZON_ENV_* variables referenced by your config (for example, from a Secret), and use Workload Identity or GOOGLE_APPLICATION_CREDENTIALS for BigQuery access.
Next Steps
Section titled “Next Steps”- Kafka Source - Source configuration fields
- BigQuery Destination -
bigquery_streaming_v2options - Kafka to BigQuery Tutorial - End-to-end streaming pipeline
- Transforms - Python transforms on bizon-core
- bizon-rs on GitHub - Source, design notes, and parity tests