Kafka Message Size Calculator
Calculate Kafka message size, storage, bandwidth and optimal configuration. Compression, batching and replication.
Last updated: March 2026
TL;DR
This calculator turns message size, batching, compression, replication, and retention into disk and bandwidth estimates so you can sanity-check brokers before you provision.
Formula: Approximate bytes/sec ≈ (messages/sec × effective message size × replication factor).
When to use this
- Sizing new topics or clusters from expected producer traffic.
- Comparing compression codecs and batch sizes for cost tradeoffs.
How the math works
How the math worksLaTeX model and TypeScript reference — same logic as the calculator on this page.
This describes the implementation behind the numbers as of 2026-03-26. It is engineering documentation, not legal or compliance advice.
Specification citation
Logic reflects our proprietary implementation of the following public specifications: Apache Kafka documentation.
This snippet represents the core logic of our proprietary calculation engine, verified against Apache Kafka documentation and common message-size / throughput sizing practice.
Model (LaTeX source)
Kafka message size (duckkit.dev model)
Let B_body be average message body bytes, f_format the serialization overhead factor,
B_key wire key bytes, H headers bytes, O_record record framing floor, O_batch batch overhead
amortized per message, ρ_c compression ratio (compressed/raw, capped at 1).
B_raw = round(B_body · f_format) + O_record + O_batch + B_key + H
B_comp = min(B_raw, ceil(B_raw · ρ_c))
Throughput and storage modules consume B_comp and cluster inputs (replication factor,
messages/s, retention) for bandwidth and disk estimates.Reference implementation (TypeScript, excerpt from shipped modules)
// lib/kafka-calculator/calculate-all.ts — pipeline
export function calculateAll(inputs: KafkaInputs): KafkaResults {
const messageSize = calculateMessageSize(inputs)
const throughput = calculateThroughput(inputs, messageSize)
const storage = calculateStorage(inputs, messageSize)
const recommendations = calculateRecommendations(
inputs,
throughput,
messageSize,
storage,
)
return { messageSize, throughput, storage, recommendations }
}
// lib/kafka-calculator/message-size.ts — format + compression cap
const rawPayloadBytes = Math.max(
0,
Math.round(inputs.averageBodyBytes * FORMAT_OVERHEAD[inputs.dataFormat]),
)
const compressedBytes = Math.min(
totalRawBytes,
Math.ceil(totalRawBytes * COMPRESSION_RATIOS[inputs.compressionType]),
)Compressed message size 552 B. Cluster bandwidth 1.66 megabytes per second. Storage about 5.66 gibibytes per hour.
At a glance
Configuration
Adjust values — results update automatically (short debounce).
Quick presets
Applies batching, linger, and compression only — payload and cluster fields stay as you set them.
Results
Estimates from your inputs — expand sections to focus.
How one record adds up on the wire before batching effects. Total = payload + key + headers + Kafka record overhead
Compression is off — wire size equals raw total. Enable a codec above to see compressed size and savings.
✓ Within a typical range for many Kafka workloads
Producer & batching
Consumer & cross-AZ (FinOps model)
Formulas & broker replication detail
- Producer MB/s = (msg/s × compressed bytes) / 10⁶ — same on-wire basis as cluster ingress/replication/fetch below.
- Cluster network MB/s = (msg/s × compressed × RF) / 10⁶ — matches bytes brokers must accept from clients for this topic/partition mix (simplified).
- Replication MB/s = (msg/s × compressed × (RF−1)) / 10⁶ — traffic from leader to follower brokers only.
💡 MSK / Confluent Cloud: broker-to-broker replication is included in the service; cross-AZ fees usually apply to client connections, not this internal line item. Self-hosted: counts toward broker NIC utilization.