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

相关推荐
巴里巴气24 分钟前
Python爬虫用Clash软件设置代理IP
爬虫·python·tcp/ip
Whoisshutiao41 分钟前
Python网安-zip文件暴力破解(仅供学习)
开发语言·python·网络安全
dessler1 小时前
Kafka-消费者(Consumer)和消费者组(Consumer Group)
linux·运维·kafka
龙潜月七1 小时前
Selenium 自动化测试中跳过机器人验证的完整指南:能用
python·selenium·机器人
蓝婷儿3 小时前
Python 机器学习核心入门与实战进阶 Day 1 - 分类 vs 回归
python·机器学习·分类
Devil枫4 小时前
Kotlin扩展函数与属性
开发语言·python·kotlin
.30-06Springfield4 小时前
利用人名语言分类案例演示RNN、LSTM和GRU的区别(基于PyTorch)
人工智能·pytorch·python·rnn·分类·gru·lstm
程序员阿超的博客5 小时前
Python 数据分析与机器学习入门 (八):用 Scikit-Learn 跑通第一个机器学习模型
python·机器学习·数据分析·scikit-learn·入门教程·python教程
xingshanchang6 小时前
PyTorch 不支持旧GPU的异常状态与解决方案:CUDNN_STATUS_NOT_SUPPORTED_ARCH_MISMATCH
人工智能·pytorch·python
费弗里9 小时前
Python全栈应用开发利器Dash 3.x新版本介绍(1)
python·dash