Kakfa Large messages

Kakfa Large messages

#apachekafka

Did you know that .... ?

Kafka configuration limits the size of messages that it's allowed to send.?By default, this limit is 1MB.

At a minimum, we need to configure these two properties :

  1. Kafka producer Configuration: Property “max.request.size” needs to be updated to the expected size in Bytes.
  2. Kafka Topic Configuration : Property?“max.message.bytes” needs to be updated to the expected size in Bytes.This holds the value of Kafka's largest record batch size?after compression (if compression is enabled).

More Optional Configurations:

3. Kafka broker Configuration

Property, “message.max.bytes“, can be used to allow ALL topics on a?broker. add this property in Kafka Broker's server.properties?config file.

Note : he maximum value among “message.max.bytes”?and “max.message.bytes” will be the effective value used.

For consuming large messages, to avoid performance impact on the consumer application :

4. Consumer Configuration

  1. .max.partition.fetch.bytes:This property limits the number of bytes a consumer can fetch from a Topic's partition. It represents message fetch size from a single partition.
  2. fetch.max.bytes: This property limits the number of bytes a consumer can fetch from the Kafka server itself. for?consumer listening on multiple partitions,?it?represents the message size that can be fetched from multiple partitions?

Note : the value of?"fetch.max.bytes"?should be higher than?"max.partition.fetch.bytes".

Generally avoid sending large messages using Kafka. The processing of large messages consumes more CPU and memory of our producer and consumer OR :

  1. Compress messages
  2. Store the large messages in a file and send location on kafka message
  3. Split the large message into small messages of size 1KB then send all these messages to a single partition using the partition key to ensure the correct order.

Refrences :

[1] https://www.baeldung.com/java-kafka-send-large-message

[2] https://kafka.apache.org/documentation/#consumerconfigs_max.partition.fetch.bytes

Krit Petty

Sr. Software Engineering Manager for Streaming SRE at LinkedIn

1 年

FYI: Kafka is misspelled in the post title.

回复

要查看或添加评论,请登录

Marwa Ali的更多文章

  • Spring Security 6 with Spring Boot 3 + KeyCloak

    Spring Security 6 with Spring Boot 3 + KeyCloak

    What is KeyCloak ? KeyCloak Open Source Identity and Access Management.It provides user federation, strong…

    1 条评论
  • Spring Security 6 with Spring Boot 3 + JWT

    Spring Security 6 with Spring Boot 3 + JWT

    In continuation to my article Spring security 6 and spring boot 3 , Next introducing JWT token. Learn Jwt token here .

  • Spring Security 6 with Spring Boot 3

    Spring Security 6 with Spring Boot 3

    Say goodbye to Old security , Say Hi to Spring Security 6 with Spring Boot 3 . it is easier and simpler.

  • SpringBoot batch framework

    SpringBoot batch framework

    Spring Batch is a lightweight, comprehensive batch framework designed to enable the development of robust batch…

  • Dockerizing Springboot Application

    Dockerizing Springboot Application

    Docker is a powerful tool that allows developers to package their applications into containers that can be easily…

  • Kafka Event sourcing in Event Driven Architecture

    Kafka Event sourcing in Event Driven Architecture

    What is Event Sourcing ? Event Sourcing is ensuring every change to the state of an application is captured in an event…

  • Istio addons

    Istio addons

    #devops #istio #grafana #promtheus #servicemesh Please see my previous artcile at Grafana An open source monitoring…

  • Istio service mesh

    Istio service mesh

    #devops #kubernets #istio #servicemesh What is a service mesh? Developers and operators face chanllenges with a…

  • Springboot Distributed State Machine

    Springboot Distributed State Machine

    #statemachine What is a distributed state? An application may exist in a finite number of states. when something…

  • Microservices Saga Pattern with Spring State machine

    Microservices Saga Pattern with Spring State machine

    What are sagas in microservices ? A database-per-microservice model provides many benefits for microservices…

社区洞察

其他会员也浏览了