Kafka Exception RecordBatchTooLargeException
org.apache.kafka.common.errors.RecordBatchTooLargeException
Non-retriable
Producer
This record batch is larger than the maximum allowable size
Reviewed 2026-10-27 · 4.4.0 · source-reviewed. Source · Source
Common Causes
- A record batch or appended records cannot fit the target log segment. Segment size and maximum record-batch size are different constraints.
Solutions
- Inspect the actual batch size and topic segment.bytes, plus broker log.segment.bytes. A Java ProducerRecord list is not an API that forces all its records into one batch.
- Coordinate per-topic max.message.bytes, broker message.max.bytes and producer max.request.size, distinguishing compressed batches from uncompressed producer limits and complete requests. Split oversized application payloads or review segment capacity if justified.
Example Stack Trace
org.apache.kafka.common.errors.RecordBatchTooLargeException: The request included message batch larger than the configured segment size on the server.Diagnostic Commands
# Check topic segment configuration
kafka-configs.sh --bootstrap-server localhost:9092 --entity-type topics --entity-name <topic> --describe | grep segment
# Describe broker-level configuration
kafka-configs.sh --bootstrap-server localhost:9092 --entity-type brokers --entity-name <broker-id> --describe | grep -E 'segment|request.size'Related
Protocol error: RECORD_LIST_TOO_LARGE (code 18)
Related Producer exceptions: BufferExhaustedException · InvalidProducerEpochException · OutOfOrderSequenceException · RecordTooLargeException · TransactionAbortedException · UnknownProducerIdException · UnsupportedForMessageFormatException
Hitting
RecordBatchTooLargeException in production? Conduktor Console gives you real-time visibility into clients, consumer groups, and broker health. Browse every Kafka exception or protocol error code.