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

Because the limit lives in four places, changing it in one spot without the others causes partial failures rather than a clean error. The dangerous case: raising message.max.bytes on the broker but not replica.fetch.max.bytes, which stalls replication silently (see separate entry). Change all four together - max.request.size, message.max.bytes, replica.fetch.max.bytes, max.partition.fetch.bytes - or you ship a topic that accepts messages it cannot replicate or consume.

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.