Should Avro be used to on both the key and value in Kafka?

electric_oasis

We're working to setup a Kafka cluster and exploring the use of Avro but I haven't been able to find guidance on if Avro should be used on both the key and value of a Kafka message. I've explored both use cases and I'm not really seeing the benefit of applying AVRO at the key level. Any good reasons to do so? And a follow-up if not using AVRO on the key what is the preferred converter (String, JSON, etc)?

JavaTechnical

If Avro should be used on both the key and value of a Kafka message

That is upto how you are going to use the key. Keys are usually (not always) a single field, possibly a String or a number but not complex objects. That being the case, there is no reason to use Avro format for them.

I've explored both use cases and I'm not really seeing the benefit of applying AVRO at the key level

You can evaluate the usage by considering what you will be putting in as key. If value is what you are mostly concerned about and that a simple string or a number would be enough to differentiate (or) classify your Kafka messages, you don't require Avro format.

Sometimes, there can be use-cases where multiple fields make up a key, just like we create a primary key in RDBMS out of multiple columns. If you suppose that your application has (or can have) such a use-case, then use avro in order to support schema evolution.

And a follow-up if not using AVRO on the key what is the preferred converter (String, JSON, etc)

JSON and Avro are for complex objects like your custom POJOs, whilst others like String, Long etc are for single field values.

If I want to stream a user information which can be identified by a user_id, then user_id will be my Kafka message key. In such a case we can use String or Long.

Avro has a compact binary format. For more on why use Avro for Kafka see this article.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

float value used as a key in multimap

分類Dev

Sequelize - To define foreign key, should I use references or belongsTo? or both?

分類Dev

Kafka Avro Schema evolution

分類Dev

For HashMap, should I override hashCode for key or value?

分類Dev

Where should I save the public key used for xml signature verification?

分類Dev

PHP - Inserting to an array by calling a method that returns both key and value

分類Dev

not able to sort entries in textarea basis on key and value both using javascript?

分類Dev

When should std::move be used on a function return value?

分類Dev

Kafka Avro Consumer with Decoderの問題

分類Dev

Kafka AVRO - conversion from long to datetime

分類Dev

NPE while deserializing avro messages in kafka streams

分類Dev

Cloudflow is unable to read avro message from kafka

分類Dev

Kafka Streams: Should we advance stream time per key to test Windowed suppression?

分類Dev

Kafka + Kubernetes + Helm + `/ usr / bin / kafka-avro-console-consumer`?

分類Dev

How to define Map with correlation between a key type and a value type, while they both are unions

分類Dev

Should a macro used in #if be defined?

分類Dev

Unknown magic byte with kafka-avro-console-consumer

分類Dev

What metadata to add to the front of an avro record to work with kafka?

分類Dev

How to utilize existing avro schema for my kafka consumer?

分類Dev

What's the default value of an union in avro Idl?

分類Dev

Should std::endl always be used?

分類Dev

Google Maps API key not used

分類Dev

value of the local variable not used

分類Dev

How do you link both spark and kafka in sbt?

分類Dev

What is the JSF resource library for and how should it be used?

分類Dev

When should the volatile keyword be used in C#?

分類Dev

When should the volatile keyword be used in C#?

分類Dev

When should the volatile keyword be used in C#?

分類Dev

Should accept() be used only at the end of a slot?

Related 関連記事

  1. 1

    float value used as a key in multimap

  2. 2

    Sequelize - To define foreign key, should I use references or belongsTo? or both?

  3. 3

    Kafka Avro Schema evolution

  4. 4

    For HashMap, should I override hashCode for key or value?

  5. 5

    Where should I save the public key used for xml signature verification?

  6. 6

    PHP - Inserting to an array by calling a method that returns both key and value

  7. 7

    not able to sort entries in textarea basis on key and value both using javascript?

  8. 8

    When should std::move be used on a function return value?

  9. 9

    Kafka Avro Consumer with Decoderの問題

  10. 10

    Kafka AVRO - conversion from long to datetime

  11. 11

    NPE while deserializing avro messages in kafka streams

  12. 12

    Cloudflow is unable to read avro message from kafka

  13. 13

    Kafka Streams: Should we advance stream time per key to test Windowed suppression?

  14. 14

    Kafka + Kubernetes + Helm + `/ usr / bin / kafka-avro-console-consumer`?

  15. 15

    How to define Map with correlation between a key type and a value type, while they both are unions

  16. 16

    Should a macro used in #if be defined?

  17. 17

    Unknown magic byte with kafka-avro-console-consumer

  18. 18

    What metadata to add to the front of an avro record to work with kafka?

  19. 19

    How to utilize existing avro schema for my kafka consumer?

  20. 20

    What's the default value of an union in avro Idl?

  21. 21

    Should std::endl always be used?

  22. 22

    Google Maps API key not used

  23. 23

    value of the local variable not used

  24. 24

    How do you link both spark and kafka in sbt?

  25. 25

    What is the JSF resource library for and how should it be used?

  26. 26

    When should the volatile keyword be used in C#?

  27. 27

    When should the volatile keyword be used in C#?

  28. 28

    When should the volatile keyword be used in C#?

  29. 29

    Should accept() be used only at the end of a slot?

ホットタグ

アーカイブ