重新平衡后 Kafka 消费者的客户数量减少
Number of Kafka consumer's clients decrease after rebalancing
我注意到一段时间后 - 例如两天 - consumergroup 并发性变得比我配置的要低。
我使用 spring 引导,这是我的代码示例
factory.setConcurrency(10);
当我在声明 kafka 消费者后使用以下 kafka 命令时,它正好显示 10 个不同的消费者客户端
bin/kafka-consumer-groups.sh --describe --group samplaConsumer --bootstrap-server localhost:9092
一段时间后,我 运行 上层命令消费者客户端变得更低,例如 6 个不同的客户端并管理那 10 个分区。
我该如何解决这个问题,以便在重新平衡或任何客户端数量保持不变后
我发现如果消费者客户端花费的时间比 max.poll.interval.ms
处理轮询数据的时间多,消费者认为失败并且该组将重新平衡。
max.poll.interval.ms
The maximum delay between invocations of poll() when using consumer group management. This places an upper bound on the amount of time that the consumer can be idle before fetching more records. If poll() is not called before the expiration of this timeout, then the consumer is considered failed and the group will rebalance in order to reassign the partitions to another member.
而且我发现,如果这种情况发生很多次,消费者客户端就会认为已经死亡,并且不会再发生重新平衡,因此消费者并发客户端的数量将会减少。
我想到的一个解决方案是我可以减少 max.poll.records
的数量,这样记录的处理时间比 max.poll.interval.ms
少。
props.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, 50); // default is 200
我注意到一段时间后 - 例如两天 - consumergroup 并发性变得比我配置的要低。
我使用 spring 引导,这是我的代码示例
factory.setConcurrency(10);
当我在声明 kafka 消费者后使用以下 kafka 命令时,它正好显示 10 个不同的消费者客户端
bin/kafka-consumer-groups.sh --describe --group samplaConsumer --bootstrap-server localhost:9092
一段时间后,我 运行 上层命令消费者客户端变得更低,例如 6 个不同的客户端并管理那 10 个分区。
我该如何解决这个问题,以便在重新平衡或任何客户端数量保持不变后
我发现如果消费者客户端花费的时间比 max.poll.interval.ms
处理轮询数据的时间多,消费者认为失败并且该组将重新平衡。
max.poll.interval.ms
The maximum delay between invocations of poll() when using consumer group management. This places an upper bound on the amount of time that the consumer can be idle before fetching more records. If poll() is not called before the expiration of this timeout, then the consumer is considered failed and the group will rebalance in order to reassign the partitions to another member.
而且我发现,如果这种情况发生很多次,消费者客户端就会认为已经死亡,并且不会再发生重新平衡,因此消费者并发客户端的数量将会减少。
我想到的一个解决方案是我可以减少 max.poll.records
的数量,这样记录的处理时间比 max.poll.interval.ms
少。
props.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, 50); // default is 200