简体   繁体   English

卡夫卡主题-我应该增加还是减少?

[英]Kafka Topics--should I have more or fewer of them?

We are new to Kafka, so I am looking for some high level guidance. 我们是Kafka的新手,所以我正在寻找一些高级指导。 We have data for a single entity (we can call it an "Order") that is essentially a number of different entities (we can call one a "Widget" and one a "Gizmo," but there are about 20 different entity types). 我们有一个实体的数据(我们可以称其为“订单”),该数据实际上是许多不同的实体(我们可以将一个称为“小部件”,而将一个称为“ Gizmo”,但大约有20种不同的实体类型) 。

Obviously, there is benefit to thinking of Orders as a single topic because all the parts are related to one order. 显然,将订单视为单个主题是有益的,因为所有部分都与一个订单相关。 But design wise, does it make more sense for these to be separate topics (Orders, Widgets, Gizmos, etc.)? 但是从设计角度来看,将这些作为单独的主题(订单,小部件,Gizmos等)是否更有意义?

There is no direct correlation between the Widgets and Gizmos--the benefit of keeping them together would be things like order of processing, etc. And suggestions or good resources to read would be very helpful. 小部件和Gizmos之间没有直接的关联-将它们保持在一起的好处是诸如处理顺序之类的东西。建议或好的阅读资源将非常有帮助。 Thanks! 谢谢!

I would recommend initially recording the event as a single atomic message, and not splitting it up into several messages in several topics. 我建议最初将事件记录为单个原子消息,而不是将其分为几个主题中的多个消息。 It's best to record events exactly as you receive them, in a form that is as raw as possible. 最好以尽可能原始的形式准确记录收到的事件。 You can always split up the compound event later, using a stream processor—but it's much harder to reconstruct the original event if you split it up prematurely. 您以后总是可以使用流处理器拆分复合事件,但是如果过早地拆分原始事件,则要重构原始事件要困难得多。 Even better, you can give the initial event a unique ID (eg a UUID); 更好的是,您可以为初始事件赋予唯一的ID(例如UUID); that way later on when you split the original event into one event for each entity involved, you can carry that ID forward, making the provenance of each event traceable. 这样,以后当您将原始事件拆分为每个涉及到的实体的一个事件时,您可以将该ID向前发送,从而使每个事件的出处都可追溯。

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

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