Kafka interview questions

How to Send Large Messages in Kafka ?

Kafka Issue:

Many time while trying to send large messages over Kafka it errors out with an exception – “MessageSizeTooLargeException”. These mostly occurs on the Producer side.

Fixes:

There are couple of configuration properties , you can try making changes and see it that works.

Producer: Increase max.request.size to send the larger message.

Kafka Broker side: replica.fetch.max.bytes – Size used to replicate the messages within the brokers as an practice of Replication.  The Brokers obey this size as a rule to create replicas of a message.  If this size is set as very small, the message is not replicated(fully committed). Hence message will not be committed. And so the consumer will not see the message.

Broker side: message.max.bytes – Maximum size of the message that a Broker can receive from a producer. Try setting this size on a higher side and see if the error exception goes away.

Broker side (per topic): max.message.bytes – Maximum size of the message allowed (by Broker) to be appended to a topic. Defaults is  broker’s message.max.bytes. It can be lower than the broker’s message.max.bytes.

Consumer: Increase max.partition.fetch.bytes to receive larger messages

Kafka Consumer side: fetch.message.max.bytes –  Maximum size of a message that can be consumed by the Kafka consumer.

 

Popular posts from this blog

What is Garbage collection in Spark and its impact and resolution

Window function in PySpark with Joins example using 2 Dataframes (inner join)

Complex SQL: fetch the users who logged in consecutively 3 or more times (lead perfect example)