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

相关推荐
jason.zeng@1502207几秒前
(九)多轮对话式新增维修记录实现方案
python·prompt·交互·llama
黑妹天下第一乖6 分钟前
小智改造实战解读-首 token 延迟去哪了:云端与端侧大模型的分段对照
开发语言·人工智能·python·嵌入式硬件·自然语言处理·iot
坊钰15 分钟前
【LangChain框架入门级】10. 文本向量与向量数据库(Embedding / Redis / Pinecone / MMR)
数据库·python·langchain·embedding
benchmark_cc24 分钟前
本地已有一年历史 K 线,第二天更新别只拉“昨天一天”
python·数据分析·pandas·量化交易·股票数据·quantdash
做个文艺程序员28 分钟前
MinIO第05篇:MinIO事件通知机制与Kafka集成——构建SaaS平台的异步文件处理管道
kafka·消息队列·springboot·minio·事件驱动·异步处理
甜到心里的蛋糕33 分钟前
云主机部署图片/视频管理系统的实践经验
python·音视频
小园子的小菜42 分钟前
FastAPI 全方位入门实战:高性能 Python Web 框架开发指南
python·pycharm·fastapi
Helix2501 小时前
Python爬虫零基础实战:3步抓取网页数据并导出Excel
爬虫·python·beautifulsoup·excel·python教程·requests·网页数据
平生幻1 小时前
unbuntu虚拟机确认python安装位置
开发语言·python
jason.zeng@15022071 小时前
(七)「固化 Rest 接口 + Text-to-SQL 灵活查询」双模式 Agent 架构教程
数据库·python·sql·ai·架构·langchain·ai编程