kafka
runtime_error
ai_generated
true
记录批次过大异常:请求包含的记录批次大小超过允许的最大值
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
85%修复率
86%置信度
1证据数
2024-06-18首次发现
根因分析
单个记录批次大小超过代理的 max.message.bytes 或 message.max.bytes 配置。
English
A single batch of records exceeds the broker's max.message.bytes or message.max.bytes configuration.
官方文档
https://kafka.apache.org/documentation/#brokerconfigs_message.max.bytes解决方案
-
在代理上增加 max.message.bytes:kafka-configs.sh --bootstrap-server localhost:9092 --entity-type brokers --entity-default --alter --add-config 'message.max.bytes=20971520'
-
在生产者上减少 batch.size 以限制批次大小:props.put("batch.size", "16384"); -
在发送到Kafka之前将大记录拆分为较小的记录。
无效尝试
常见但无效的做法:
-
85% 失败
Increasing max.request.size on the producer without also increasing broker limits will still cause rejection.
-
70% 失败
Compressing the batch may not reduce size enough if individual records are too large.