简体   繁体   English

如果我有多个生产者向 Kafka 生产相同的数据,为每个生产者配置一个主题或为所有生产者配置一个主题是否有效

[英]If I have multiple producers producing same data to Kafka,Is it efficient to configure one topic for each producer or one topic for all producers

I have more number of producers let's say around 200. and each producer have 4 different kinds of data.我有更多的生产者,比如大约 200 个。每个生产者都有 4 种不同的数据。 so is it efficient to produce data from all producers to same topic or is it efficient to configure different topic for each producer?那么从所有生产者向同一主题生成数据是否有效,或者为每个生产者配置不同主题是否有效?

I want to collect each producer data separately at the consumer end.我想在消费者端分别收集每个生产者数据。

What are the available ways to handle data at the consumer end?在消费者端处理数据的可用方法有哪些?

There's no difference.没有区别。 The broker just stores bytes;代理只存储字节; it has no knowledge of "type".它不知道“类型”。

The main problem with putting everything into one topic is that your consumers will need to know how to deserialize and process those bytes, consistently.将所有内容都放在一个主题中的主要问题是您的消费者将需要知道如何一致地反序列化和处理这些字节。 Ie setting value.deserializer might not return a concrete class, but rather some generic type like JSON string or Avro GenericRecord, which then needs extra parsing and large switch-case logic in your consumer即设置value.deserializer可能不会返回具体的 class,而是返回一些通用类型,例如 JSON 字符串或 Avro GenericRecord,然后需要在您的消费者中进行额外的解析和大型 switch-case 逻辑

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

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