上一篇 介绍了kafka的命令行使用,这一篇主要介绍 Consumer 客户端的参数设置(搬运官网 http://kafka.apache.org/documentation/#consumerconfigs)
名称 | 描述 | 类型 | 默认值 | 有效值 | 重要等级 |
---|---|---|---|---|---|
key.deserializer | key值 反序列化类 实现 org.apache.kafka.common.serialization.StringDeserializer | class | 高 | ||
value.deserializer | value值 反序列化类 实现org.apache.kafka.common.serialization.Deserializer | class | 高 | ||
bootstrap.servers | kafka集群列表格式(host1:port1,host2:port2,...) | list | “” | non-null string | 高 |
fetch.min.bytes | 一次拉取的最小数据量,如果没有足够的数据量,那么consumer会等待。默认值是1,意味着即使只有 1byte的数据客户端也会拉取,可以适当调大这个参数以改善性能。 | int | 1 | [0,...] | 高 |
group.id | 指定改消费者属于哪个消费组 | string | null | 高 | |
heartbeat.interval.ms | 使用kafka组管理时,预期的两次心跳间隔时间,心跳时间用来保证consumer的对话session处于存活状态,并在新的消费者加入或离开组时进行再平衡操作,该值必须保证低于session.timeout.ms值,但是一般应设置为高于其1/3大小。 | int | 3000 | 高 | |
max.partition.fetch.bytes | 每个分区会返回的最大数据量,消费者在批处理中读取的记录,如果在非空分区中第一个记录大于该值,仍然会被返回给消费者。最大批处理记录大小在broker中由message.max.bytes(broker config)或 max.message.bytes(topic config)设置 | int | 1048576 | [0,...] | 高 |
session.timeout.ms | kafka消费组监测消费者故障时候所用的超时时间,消费者定期向broker发送心跳,如果超过这个时间,消费组就会将其消费的partition分配给其他消费者,改值大小必须设置在 broker configure的group.min.session.timeout.ms 和 group.max.session.timeout.ms之间 | int | 10000 | 高 | |
auto.offset.reset | What 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):
| string | latest | [latest, earliest, none] | 中 |
default.api.timeout.ms | 指定consumer 可以进入阻塞状态时候的超时时间(毫秒) | int | 60000 | [0,...] | 中 |
enable.auto.commit | 如果设置为真,消费者的偏移量将会定期在后台提交 | boolean | true | 中 | |
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). | int | 52428800 | [0,...] | 中 |
isolation.level | 控制怎么读取事务性的消息,如果设置为 read_committed, consumer.poll() 只会等待事务性消息被提交后才会继续消费 | string | read_uncommitted | [read_committed, read_uncommitted] | 中 |
max.poll.interval.ms | 调用 poll() 方法的最大延迟,这个决定了下次获取更多数据前,consumer可以处于空闲时期的最长时间,如果在这个时间超时后poll() 方法都没有被调用,改consumer会被认为失败并被group reblance,将其分区分配给另外一个消费者 | int | 300000 | [1,...] | 中 |
max.poll.records | 由poll()方法一次返回的最大records数量 | int | 500 | [1,...] | 中 |
receive.buffer.bytes | The size of the TCP receive buffer (SO_RCVBUF) to use when reading data. If the value is -1, the OS default will be used. | int | 65536 | [-1,...] | 中 |
request.timeout.ms | 这个配置控制客户端等待响应的最长时间,如果超时,会重发一次,若重发仍然没有响应,会返回失败 | int | 30000 | [0,...] | 中 |
auto.commit.interval.ms | The frequency in milliseconds that the consumer offsets are auto-committed to Kafka if enable.auto.commit is set to true | int | 5000 | [0,...] |