<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sundar m on Medium]]></title>
        <description><![CDATA[Stories by Sundar m on Medium]]></description>
        <link>https://medium.com/@sundarm?source=rss-a81d249e47ea------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*plWIfyoSMc3xgxlsmx4jPg.jpeg</url>
            <title>Stories by Sundar m on Medium</title>
            <link>https://medium.com/@sundarm?source=rss-a81d249e47ea------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 12:15:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sundarm/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Kafka Standards]]></title>
            <link>https://medium.com/@sundarm/kafka-standards-c92e8f6efff3?source=rss-a81d249e47ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/c92e8f6efff3</guid>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[kafkaesque]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[kafka-streams]]></category>
            <category><![CDATA[kafka]]></category>
            <dc:creator><![CDATA[Sundar m]]></dc:creator>
            <pubDate>Wed, 11 Apr 2018 10:45:17 GMT</pubDate>
            <atom:updated>2024-09-08T06:55:35.024Z</atom:updated>
            <content:encoded><![CDATA[<h3>Kafka</h3><h3>Interface Standards</h3><h4>Producer API</h4><ul><li>Batching/Buffering</li><li>Do the performance benchmark with the help of the kafka-producer-perf-test utility.</li><li>Set the linger.ms for the time window on batching. The default is 0, but you can set it to a value based on the peak load that can happen on the producer.</li><li>Set the batch.size to a value which can accommodate the size of data that can come in at linger.ms interval.</li><li>Set the Buffer memory to around 32 MB per topic/partition, which can hold and send the messages to the broker within the maximum block.ms. If it is foreseen that the limit could be exceeded, then handle the Timeout Exception with retries.</li><li>Set block.on.buffer.full=true</li><li>Set retries=Long.MAX_VALUE</li><li>Every Producer should manage a client ID, which should be managed centrally by the Development Team.</li><li>Flush the buffer before closing the producer.</li><li>Formula to decide on the number of partitions/topics:</li><li>Required # of partitions= Max (T/P, T/C)</li><li>P = Throughput from producer to a single partition is</li><li>C = Throughput from a single partition to a consumer</li><li>T = Target throughput</li><li>Compression</li><li>Always set the producer and broker compression type to snappy.</li><li>Producers should use compression combined with batching.</li><li>Any custom serialization library used must have deserialization methods as well and should be managed centrally.</li><li>Retries/Timeouts</li><li>Set the retries to 2</li><li>All the request.timeout.ms should be set to 15000. Adjust the values if network latency is higher.</li><li>Set the retry.backoff.ms to 1000 intervals between each retry.</li><li>To maintain the order within a partition, set the max.in.flight.request.per.connection to 1.</li><li>Partitioners</li><li>Topics should be partitioned to have higher throughput.</li><li>Based on the partition logic</li><li>Custom Partitioners should not lead to hotspot issues. It should distribute the data across partitions reasonably even.</li><li>One thousand partitions per leader broker with a node count of 3 will lead to 20 ms latency. So, limit the number of partitions per broker and increase the brokers to increase the throughput.</li><li>When the number of partitions increases, the producer’s memory size is set to multiple partitions and buffer size.</li><li>Guaranteed Delivery</li><li>To get guaranteed delivery, set the producer ACKS_CONFIG to “all,” “-1”</li><li>To manage effectively, always use Producer.metrics() to collect the metrics and push them into Elastic for Kibana DashBoard &amp; Monitoring.</li><li>Implement ProducerInterceptors interface to add hooks on onSend/onAck/close into Producer.</li></ul><h4>Consumer API</h4><ul><li>To Load Balance in a topic, Always Use more than one consumer per partition in a consumer Group.</li><li>If we need more than one parallel consumer per topic per partition, we should always choose the option of having more than one consumer group.</li><li>The performance benchmark should be done with the help of the kafka-producer-perf-test utility.</li><li>When the consumer starts from a defined offset, ensure the offset is available within the partitions and set the retentions accordingly.</li><li>All the consumers should have Group.id managed centrally during development.</li><li>Manage offsets externally at every 10–20 minutes interval apart from kafka internal to validate the recovery plan.</li><li>Disable auto.offset.commit to avoid issues at the zookeeper.</li><li>Flush the offset commits to commitSync() with only the ACTIVE consumer thread in the consumer group. Don’t use this too often to avoid loading the zookeeper hit.</li><li>The consumer poll has to be within the max.poll.interval.ms, or else the consumer will be considered dead. In other words, the processing time between each poll should be within max.poll.interval.ms</li><li>Set the max.poll.records to a value that can be processed within max.poll.interval.ms</li><li>Avoid assigning () to manage consumer-to-partition mapping manually.</li><li>Use the New Kafka API from below maven for both consumer and Producer</li></ul><p>&lt;dependency&gt;</p><p>&lt;groupId&gt; org.apache.kafka &lt;/groupId&gt;</p><p>&lt;artifactId&gt; kafka-clients &lt;/artifactId&gt;</p><p>&lt;version&gt; ${kafka-version} &lt;/version&gt;</p><p>&lt;/dependency&gt;</p><h4>Streams API</h4><ul><li>Use Kafka Streams from Kafka version 0.10</li><li>Use Kafka Streams for event-based consumption.</li></ul><h3>Security</h3><ul><li>Secure the producer and consumer channels with SSL and signed CA.</li><li>The producer and consumer node restriction should be done with Ranger’s IP-based restriction.</li><li>All the Producers and Consumers should use the New API to connect to the cluster.</li></ul><h3>Configuration</h3><ul><li>All the Kafka Nodes &amp; Brokers should be running on the dedicated Node.</li><li>A higher number of partitions will help in throughput, but it will also lead to too many open files.</li><li>All brokers and Topics should have min.insync.replicas to 2 so that the cluster can survive a single node failure.</li><li>Set num.replica.fetchers in Brokers to more than or equal to 2 so the replication can be faster.</li><li>Set offsets.topic.replication.factor in Brokers to 3.</li><li>Disable unclean leader election</li><li>The retention for each topic should be mentioned, and it should be at a maximum of one day.</li><li>Set offsets.retention.minutes to a maximum SLA for the application as once the offset is gone then it has to start from the beginning.</li><li>Set the OS page cache to higher values so that it can hold enough data before flushing to disk, which increases the Broker write throughput.</li></ul><h3>Monitoring&amp; Alert</h3><h4>Options:</h4><ul><li>All the Kafka components/Producers/Consumers expose the JMX metric, which can be monitored using jConsole.</li><li>For central dashboarding and Alerting Requirements, it is preferred to upload the JMX Metrics in Real Time to Elastic and Create Kibana Dashboards on the same.</li><li>Kafka Manager can be used to monitor ONLY Kafka.</li><li>Prometheus &amp; Data Dog are proprietary versions for Cluster Monitoring.</li></ul><p><strong>Note:</strong> Many tools solve the same problem. The choice is made by the religion of the environment. The Topics, clients, and groupId have to be centrally managed to identify reusability and improve monitoring.</p><h3>High Availability</h3><ul><li>All the HA principles are addressed when the other section standards are met.</li><li>Use multiple instances of the Kafka-mirror-maker utility to replicate the data between Kafka clusters in real-time and set the — num.streams to a number for the consumer threads.</li><li><strong>Recommendations:</strong></li><li>Run the kafka mirror on a dedicated Node.</li><li>Set high socket buffer Size and consumer fetch size.</li><li>Offset cannot be managed across the Kafka cluster.</li><li>Monitor mirrors with the consumer lags.</li></ul><h3>Naming Standards</h3><h4>Consumer and Producer</h4><ul><li>Consumer groups should be prefixed with CG&lt;ConsumerApplicationName&gt; to manage the Consumer Groups and consumer IDs better.</li><li>Consumers and Producers should have client IDs managed centrally.</li></ul><h4>Topic Names</h4><ul><li>The topic names should be in Camel Case instead of using a ‘.’ ‘-’ ‘_’ as separators across the document.</li><li>Specifically, avoid ‘.’ in any of the Kafka-related entities, as the JMX metrics exposed by Apache Kafka have issues at specific versions.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c92e8f6efff3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>