-
Type:
New Feature Request
-
Resolution: Unresolved
-
Priority:
Trivial
-
None
-
Affects Version/s: None
-
Component/s: Proxy (P), Server (S)
-
None
Summary & Pull Request
Adds native Zstandard (libzstd) transport compression, 256-bit BLAKE3 ZBXD wire-header integrity verification, and canonical BLAKE3 batch deduplication between Zabbix Proxy (Active & Passive) and Zabbix Server, with automatic backward-compatible protocol negotiation for rolling upgrades.
- GitHub Pull Request (rebased on master): https://github.com/zabbix/zabbix/pull/195
- Patch attached: zabbix-master-zstd-blake3.patch
Motivation
- CPU & Bandwidth Efficiency (ZSTD vs zlib): Proxy-Server communications currently rely exclusively on zlib (ZBX_TCP_COMPRESS = 0x02). ZSTD cuts compressed JSON batch size by ~48% while running >2.3x faster.
- Pre-Allocation Wire Integrity (BLAKE3): Appends a 32-byte BLAKE3 digest over header_prefix || wire_payload in ZBXD headers (ZBX_TCP_BLAKE3 = 0x10), rejecting corrupted header lengths or payloads before allocating decompression buffers.
- Idempotent Batch Deduplication: Eliminates duplicate metric/discovery/autoregistration ingestion when TCP connections drop after Server processing but before the Proxy receives "response":"success".
Technical Changes
- libzbxhash (src/libs/zbxhash/blake3.c, include/zbxhash.h): Self-contained portable C implementation of official CC0 1.0 BLAKE3 using Zabbix-native types (zero external dependencies).
- libzbxcompress (src/libs/zbxcompress/compress.c, m4/libzstd.m4, configure.ac): Adds zbx_compress_zstd(), zbx_uncompress_zstd(), and zbx_compress_with_flags(), preserving zlib compatibility.
- libzbxcomms (include/zbxcomms.h, src/libs/zbxcomms/comms.c): Introduces ZBX_TCP_COMPRESS_ZSTD (0x08) and ZBX_TCP_BLAKE3 (0x10).
- Batch Coherence & Multi-Process Deduplication: Canonical batch_blake3 over deterministic batch sections, in-flight retry retention in datasender.c, shared-memory deduplication in ZBX_DC_PROXY (zbxcacheconfig), and echoed batch_blake3 ACK confirmation.
- Rolling-Upgrade Negotiation: zbx_negotiate_proxy_reply_flags() and automatic fallback to 0x03 (zlib) ensure seamless interoperability with outdated/legacy proxies and servers.
- Unit Tests (cmocka): Added zbx_blake3_hash, zbx_proxy_batch_blake3, and extended zbx_tcp_send_context_init under tests/libs/zbxcomms/.
Benchmark (500-metric proxy data JSON batch, 39,130 B raw, 200 iterations, x86_64 GCC -O2)
| Transport Mode | Compressed Size | Ratio | Time (200 batches) | Speedup |
|---|---|---|---|---|
| Legacy zlib (0x03) | 4,251 B | 9.20x | 25.36 ms | 1.00x |
| New ZSTD + BLAKE3 (0x19) | 2,215 B (-47.9%) | 17.67x | 10.77 ms | 2.35x |