kafka 学习笔记(三)--- Consumer 参数设置(无加密的中高等级参数配置)

上一篇 介绍了kafka的命令行使用,这一篇主要介绍 Consumer 客户端的参数设置(搬运官网 http://kafka.apache.org/documentation/#consumerconfigs

kafka consumer 参数 意义及设置
名称描述类型默认值有效值重要等级
key.deserializerkey值 反序列化类 实现
org.apache.kafka.common.serialization.StringDeserializer
class  
value.deserializervalue值 反序列化类 实现org.apache.kafka.common.serialization.Deserializerclass  
bootstrap.serverskafka集群列表格式(host1:port1,host2:port2,...)list“”non-null string
fetch.min.bytes一次拉取的最小数据量,如果没有足够的数据量,那么consumer会等待。默认值是1,意味着即使只有 1byte的数据客户端也会拉取,可以适当调大这个参数以改善性能。int1[0,...]
group.id指定改消费者属于哪个消费组stringnull 
heartbeat.interval.ms使用kafka组管理时,预期的两次心跳间隔时间,心跳时间用来保证consumer的对话session处于存活状态,并在新的消费者加入或离开组时进行再平衡操作,该值必须保证低于session.timeout.ms值,但是一般应设置为高于其1/3大小。int3000 
max.partition.fetch.bytes每个分区会返回的最大数据量,消费者在批处理中读取的记录,如果在非空分区中第一个记录大于该值,仍然会被返回给消费者。最大批处理记录大小在broker中由message.max.bytes(broker config)或 max.message.bytes(topic config)设置int1048576[0,...]
session.timeout.mskafka消费组监测消费者故障时候所用的超时时间,消费者定期向broker发送心跳,如果超过这个时间,消费组就会将其消费的partition分配给其他消费者,改值大小必须设置在 broker configure的group.min.session.timeout.ms 和 group.max.session.timeout.ms之间int10000 
auto.offset.resetWhat to do when there is no initial offset in Kafka or if the current offset does not exist any more on the server (e.g. because that data has been deleted):
  • earliest: automatically reset the offset to the earliest offset
  • latest: automatically reset the offset to the latest offset
  • none: throw exception to the consumer if no previous offset is found for the consumer's group
  • anything else: throw exception to the consumer.
stringlatest[latest, earliest, none]
default.api.timeout.ms指定consumer 可以进入阻塞状态时候的超时时间(毫秒)int60000[0,...]
enable.auto.commit如果设置为真,消费者的偏移量将会定期在后台提交booleantrue 
fetch.max.bytes一次拉取请求中服务器可以返回的最大数据量, Records are fetched in batches by the consumer, and if the first record batch in the first non-empty partition of the fetch is larger than this value, the record batch will still be returned to ensure that the consumer can make progress,因此这并不是一个绝对的最大值,The maximum record batch size accepted by the broker is defined via message.max.bytes(broker config) or max.message.bytes(topic config). int52428800[0,...]
isolation.level控制怎么读取事务性的消息,如果设置为 read_committed,  consumer.poll() 只会等待事务性消息被提交后才会继续消费stringread_uncommitted[read_committed, read_uncommitted]
max.poll.interval.ms 调用 poll() 方法的最大延迟,这个决定了下次获取更多数据前,consumer可以处于空闲时期的最长时间,如果在这个时间超时后poll() 方法都没有被调用,改consumer会被认为失败并被group reblance,将其分区分配给另外一个消费者int300000[1,...]
max.poll.records由poll()方法一次返回的最大records数量int500[1,...]
receive.buffer.bytesThe size of the TCP receive buffer (SO_RCVBUF) to use when reading data. If the value is -1, the OS default will be used.int65536[-1,...]
request.timeout.ms这个配置控制客户端等待响应的最长时间,如果超时,会重发一次,若重发仍然没有响应,会返回失败int30000[0,...]
auto.commit.interval.msThe frequency in milliseconds that the consumer offsets are auto-committed to Kafka if enable.auto.commit is set to trueint5000[0,...] 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值