dataengref errors

Home / Kafka / Producer

Kafka producer: RecordTooLargeException: The message is N bytes when serialized which is larger than max.request.size

org.apache.kafka.common.errors.RecordTooLargeExceptionThe message is 1572864 bytes when serialized which is larger than 1048576, which is the value of the max.request.size configuration.

The producer refused to send a record that is larger than its own max.request.size (1 MiB by default). Raising only the producer limit is not enough: the broker and topic limits must allow the size too.

Causes · Fixes · Source

Common causes

  1. Individual records are larger than 1 MiB, for example whole documents or images.How to confirm: The message states the serialized size; compare it with the payloads your application sends.
  2. A serializer bug or unbounded collection makes records unexpectedly large.How to confirm: Log the serialized size of a few records; a few outliers point to bad data rather than a limit that is too low.

How to fix it

Keep large payloads out of Kafka: store them in object storage and send a reference.

If large records are expected, raise every limit on the path: producer, broker or topic, and consumer.

SettingDefaultNote
max.request.size1048576producer
message.max.bytes1048588broker; max.message.bytes per topic
max.partition.fetch.bytes1048576consumer

Enable compression, which can bring records under the limit.

SettingDefaultNote
compression.typenone

Where the message comes from

Message template in the source: The message is %d bytes when serialized which is larger than %d, which is the value of the max.request.size configuration.

References

Related errors

Last checked: