简体   繁体   English

对于微服务,如何在运行时为Kafka和tb-rule-engine添加节点,会不会影响可用性?

[英]For microservice, how to add nodes for Kafka and tb-rule-engine at runtime, will it impact availability?

like how re-hash after adding nodes.就像添加节点后如何重新散列一样。 Will there be some period of time of unavailability?会有一段时间不可用吗?

There are no official documents for this answer, so I wonder if Thingsboard supports smooth dynamic expansion.这个答案没有官方文档,所以我想知道Thingsboard是否支持平滑的动态扩展。

ThingsBoard Rule Engine uses Zookeeper to detect the addition/deletion of sibling nodes. ThingsBoard 规则引擎使用 Zookeeper 来检测兄弟节点的添加/删除。 The data stream of Rule Engine messages is stored in Kafka topic with a configurable amount of partitions.规则引擎消息的数据 stream 存储在分区数量可配置的 Kafka 主题中。 When you add the node, the rule engine PartitionService.recalculatePartitions method is executed on each node to get the list of partitions that this node is responsible for.添加节点时,规则引擎PartitionService.recalculatePartitions方法会在每个节点上执行,得到该节点负责的分区列表。 So, old Rule Engine nodes will stop consuming a certain partition and the new rule engine node will start consuming those partitions.因此,旧规则引擎节点将停止使用某个分区,而新规则引擎节点将开始使用这些分区。 During a short period of time, you may notice a slight degradation in processing speed (due to the warm-up of the new node) but this should not affect the data processing logic itself.在短时间内,您可能会注意到处理速度略有下降(由于新节点的预热),但这不应该影响数据处理逻辑本身。

As a side effect, some of the messages may be processed twice in this case.作为副作用,在这种情况下,某些消息可能会被处理两次。 For example, rule engine A polled 1000 messages from the queue but has not committed the offset yet.例如,规则引擎 A 从队列中轮询了 1000 条消息,但尚未提交偏移量。 The messages are now traveling through the rule chains.消息现在正在通过规则链传输。 Then the 2nd node started and starts reading the same partition.然后第二个节点启动并开始读取同一个分区。 It will start processing the uncommitted messages again.它将再次开始处理未提交的消息。

If you must avoid duplicates in processing - configure your queue to process messages one-by-one (Sequentially, with the size of the pack equal to 1).如果您必须避免处理中的重复 - 将您的队列配置为一个接一个地处理消息(顺序地,包的大小等于 1)。 Although this will cause performance degradation.虽然这会导致性能下降。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM