doc-exports/docs/dms/umn/kafka_faq_0061.html
Chen, Junjie ca9677b121 DMS UMN 20230201 Version
Reviewed-by: Antonova, Ekaterina <ekantono@noreply.gitea.eco.tsi-dev.otc-service.com>
Co-authored-by: Chen, Junjie <chenjunjie@huawei.com>
Co-committed-by: Chen, Junjie <chenjunjie@huawei.com>
2024-07-22 13:20:04 +00:00

50 lines
5.2 KiB
HTML

<a name="kafka_faq_0061"></a><a name="kafka_faq_0061"></a>
<h1 class="topictitle1">Why Is It Not Recommended to Use a Sarama Client for Messaging?</h1>
<div id="body0000001770681121"><div class="section" id="kafka_faq_0061__section104541133285"><h4 class="sectiontitle">Symptom</h4><p id="kafka_faq_0061__p814519775211">If a Sarama client is used to send and receive messages, the following issues may occur:</p>
<ul id="kafka_faq_0061__ul4485152552817"><li id="kafka_faq_0061__li11658103035315">Sarama cannot detect partition changes. Adding topic partitions requires client restart to enable consumption.</li><li id="kafka_faq_0061__li34831232205415">Sarama's default <strong id="kafka_faq_0061__b6972017115518">MaxProcessingTime</strong> is 100 ms. When this limit is reached, consumers can no longer consume messages.</li><li id="kafka_faq_0061__li15489727105514">If consumer offsets reset from the oldest (earliest) position, all messages starting from the earliest position may be repeatedly consumed after the client restarts.</li><li id="kafka_faq_0061__li1148512522816">A consumer that subscribes to multiple topics may not be able to consume any message from specific partitions.</li></ul>
</div>
<div class="section" id="kafka_faq_0061__section1088592912285"><h4 class="sectiontitle">Solution</h4><p id="kafka_faq_0061__p177701396577">Use <a href="https://github.com/confluentinc/confluent-kafka-go" target="_blank" rel="noopener noreferrer">confluent-kafka-go</a> as the Kafka client library.</p>
<p id="kafka_faq_0061__p47067561318">For details, see <a href="#kafka_faq_0061__table183502571446">Table 1</a>.</p>
<div class="tablenoborder"><a name="kafka_faq_0061__table183502571446"></a><a name="table183502571446"></a><table cellpadding="4" cellspacing="0" summary="" id="kafka_faq_0061__table183502571446" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Comparing common Go clients</caption><thead align="left"><tr id="kafka_faq_0061__row1235065718415"><th align="left" class="cellrowborder" valign="top" width="20.002000200020003%" id="mcps1.3.2.4.2.4.1.1"><p id="kafka_faq_0061__p203505574413">Client</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="38.97389738973897%" id="mcps1.3.2.4.2.4.1.2"><p id="kafka_faq_0061__p1535015718419">Pros</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="41.02410241024103%" id="mcps1.3.2.4.2.4.1.3"><p id="kafka_faq_0061__p635010571247">Cons</p>
</th>
</tr>
</thead>
<tbody><tr id="kafka_faq_0061__row53505571147"><td class="cellrowborder" valign="top" width="20.002000200020003%" headers="mcps1.3.2.4.2.4.1.1 "><p id="kafka_faq_0061__p1235085717417">confluent-kafka-go</p>
</td>
<td class="cellrowborder" valign="top" width="38.97389738973897%" headers="mcps1.3.2.4.2.4.1.2 "><ul id="kafka_faq_0061__ul1175413365115"><li id="kafka_faq_0061__li1275413601111">An official Kafka client by Confluent that supports full Kafka compatibility and all Kafka features</li><li id="kafka_faq_0061__li1775493691112">High stability and performance, and low latency based on librdkafka</li></ul>
</td>
<td class="cellrowborder" valign="top" width="41.02410241024103%" headers="mcps1.3.2.4.2.4.1.3 "><p id="kafka_faq_0061__p134085444305">High compiling complexity because Go compilers need extra resources to configure the imported C++ libraries</p>
</td>
</tr>
<tr id="kafka_faq_0061__row1835018570415"><td class="cellrowborder" valign="top" width="20.002000200020003%" headers="mcps1.3.2.4.2.4.1.1 "><p id="kafka_faq_0061__p1535075715411">kafka-go</p>
</td>
<td class="cellrowborder" valign="top" width="38.97389738973897%" headers="mcps1.3.2.4.2.4.1.2 "><ul id="kafka_faq_0061__ul3106191551214"><li id="kafka_faq_0061__li1810681511125">A simple and lite Kafka client easy for learning and usage</li><li id="kafka_faq_0061__li1810621581219">Reduced application size and complexity with limited library and fewer dependencies</li></ul>
</td>
<td class="cellrowborder" valign="top" width="41.02410241024103%" headers="mcps1.3.2.4.2.4.1.3 "><ul id="kafka_faq_0061__ul990351101218"><li id="kafka_faq_0061__li89015110122">Fewer advanced functions and configurations than confluent-kafka-go</li><li id="kafka_faq_0061__li29011512122">Applicable only to simple scenarios that require low performance and throughput</li></ul>
</td>
</tr>
<tr id="kafka_faq_0061__row435013575410"><td class="cellrowborder" valign="top" width="20.002000200020003%" headers="mcps1.3.2.4.2.4.1.1 "><p id="kafka_faq_0061__p1335012571046">Sarama</p>
</td>
<td class="cellrowborder" valign="top" width="38.97389738973897%" headers="mcps1.3.2.4.2.4.1.2 "><p id="kafka_faq_0061__p343113614123">Better asynchronization and higher concurrency (written in the original Go language)</p>
</td>
<td class="cellrowborder" valign="top" width="41.02410241024103%" headers="mcps1.3.2.4.2.4.1.3 "><ul id="kafka_faq_0061__ul84094417136"><li id="kafka_faq_0061__li17409104181313">Many bugs, limited documentation</li><li id="kafka_faq_0061__li7409645138">Deteriorates application performance when processing a large number of messages due to large memory consumption</li></ul>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="kafka-faq-191030001.html">Connections</a></div>
</div>
</div>