# org.apache.kafka.common.errors.RecordBatchTooLargeException: The request included a batch of records larger than the maximum allowed size

- **ID:** `kafka/record-batch-too-large`
- **Domain:** kafka
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

A single batch of records exceeds the broker's max.message.bytes or message.max.bytes configuration.

## Workarounds

1. **Increase max.message.bytes on the broker: kafka-configs.sh --bootstrap-server localhost:9092 --entity-type brokers --entity-default --alter --add-config 'message.max.bytes=20971520'** (90% success)
   ```
   Increase max.message.bytes on the broker: kafka-configs.sh --bootstrap-server localhost:9092 --entity-type brokers --entity-default --alter --add-config 'message.max.bytes=20971520'
   ```
2. **Reduce batch.size on the producer to limit batch size: props.put("batch.size", "16384");** (80% success)
   ```
   Reduce batch.size on the producer to limit batch size: props.put("batch.size", "16384");
   ```
3. **Split large records into smaller ones before sending to Kafka.** (85% success)
   ```
   Split large records into smaller ones before sending to Kafka.
   ```

## Dead Ends

- **** — Increasing max.request.size on the producer without also increasing broker limits will still cause rejection. (85% fail)
- **** — Compressing the batch may not reduce size enough if individual records are too large. (70% fail)
