kafka消费/发送消息,消息过大报错解决whose size is larger than the fetch size 1048576

目录

一、kafka消费报错原因

  • 问题原因一:个是kafka本身的配置没有调整到上限

  • 问题原因二:就是我们自己写python消费kafka代码的时候没有参数配置没有限制

  • RecordTooLargeError: ("There are some messages at [Partition=Offset]: {TopicPartition(topic='psadad', partition=1): 75} whose size is larger than the fetch size 1048576 and hence cannot be ever returned. Increase the fetch size, or decrease the maximum message size the broker will allow.", {TopicPartition(topic='psadad', partition=1): 75})

二、解决方案

1、原因一的解决方案
  • 在kafka中,默认的消息体大小为1M。在实际的业务场景,有时候需要修改kafka消息体大小,修改kafka消息体大小需要注意下面的几个方面
    • message.max.bytes (broker配置)
    • replica.fetch.max.bytes (partition配置)
    • max.message.bytes (topic配置)
  • 在生产者端配置max.request.size,这是单个消息最大字节数,根据实际调整,max.request.size 必须小于 message.max.bytes 以及消费者的 max.partition.fetch.bytes。这样消息就能不断发送
  • kafka config服务端配置文件server.properties, server.properties中加上的message.max.bytes配置
2、原因二的解决方案
  • 如图添加参数max_partition_fetch_bytes=1048576 * 10

相关推荐
nothing&nowhere5 小时前
用 Python 做问卷数据清洗:无效样本检测与处理实战
开发语言·python·数据清洗·数据处理·问卷星·问卷星脚本·刷问卷
花酒锄作田5 小时前
如何发布自己的 Python 库到 PyPI
python
researcher-Jiang5 小时前
Design Patterns——Template Method入门到情景实战
python·设计模式·模板方法模式
飞猪~9 小时前
LangChain python 版本 第一集
开发语言·python·langchain
2601_9563198810 小时前
最新AI量化提效,先做可验证的小流程
人工智能·python
开飞机的舒克_11 小时前
FastAPI 实战入门:从路由、参数校验到依赖注入的后端开发指南
python·fastapi
霸道流氓气质11 小时前
Kiro 中反编译 JAR 包并分析字节码的流程指南
chrome·python·jar
人工智能时代 准备好了吗12 小时前
AI回答内容进入率监测:引用识别、文本匹配与语义判断
开发语言·人工智能·python
Metaphor69212 小时前
使用 Python 冻结 Excel 文件中的行、列和单元格
开发语言·python·excel