位置
| 位置 | 参数 | 默认参考值 |
|---|---|---|
| 生产者 | max.request.size | 1MB |
| Broker | message.max.bytes | 约 1MB |
| 主题 | max.message.bytes | 继承 Broker |
| 消费者 | max.partition.fetch.bytes / fetch.max.bytes | 1MB / 50MB |
调整示例
调整示例
kafka-configs.sh --bootstrap-server localhost:9092 \
--entity-type topics --entity-name orders \
--alter --add-config max.message.bytes=5242880
# 生产者与消费者需同步调整
# producer: max.request.size=5242880
# consumer: max.partition.fetch.bytes=5242880大消息会放大内存与延迟,单条数 MB 的量级优先考虑拆分、压缩或改传对象存储引用。