3

I'm going to keys for kafka messages dynamically, depending on some configuration. And now I'm wondering, is there separate setting for message key length or it is only limited by (whole) message size?

I tried searching this information but everywhere only message size is mentioned.

bigbounty
  • 16,526
  • 5
  • 37
  • 65
Dmytro Kosh
  • 53
  • 1
  • 7

2 Answers2

4

In theory, the max size of the key is the size of a byte array, with the value and headers being null, minus other Kafka message metadata like the timestamp.

Ultimately, the max size that any message can be is determined by the broker

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
1

Key is sent as part of the message as you can see here:

Message =>
        Length => varint
        Attributes => int8
        TimestampDelta => varlong
        OffsetDelta => varint
        KeyLen => varint
        Key => data
        ValueLen => varint
        Value => data
        Headers => [Header]

So it's limited by the message size itself. Also look here.

vratojr
  • 818
  • 2
  • 8
  • 25