dkduckkit.dev

message.max.bytes

Kafka

message.max.bytes is a Kafka broker (and topic-level) configuration that sets the maximum size of a single message batch that the broker will accept from a producer. The default is 1,048,576 bytes (1 MB). It must be kept in sync with three other configurations: max.request.size (producer-side limit), replica.fetch.max.bytes (replication limit), and max.partition.fetch.bytes (consumer-side limit). Mismatches between these four values are the source of some of Kafka's most common production bugs.

Formula

Configuration chain: max.request.size (producer) ≤ message.max.bytes (broker/topic) ≤ replica.fetch.max.bytes (replication) — all four must be consistently set for messages to flow end-to-end without data loss.

Why it matters in practice

The configuration chain means that changing the message size limit in one place without updating the others causes partial failures. The most dangerous: increasing message.max.bytes at the broker level without increasing replica.fetch.max.bytes causes silent replication failure (see separate entry). The Kafka Message Size Calculator on this site validates the full configuration chain and highlights mismatches.

Common mistakes

  • Changing only message.max.bytes and not the full configuration chain.
  • Not setting max.message.bytes at the topic level when the cluster default is too small — topic-level overrides allow large messages on specific topics without changing the cluster default.