{"id":46873,"date":"2023-06-04T05:09:21","date_gmt":"2023-03-12T06:47:42","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/apache-kafka%e6%80%a7%e8%83%bd%e6%b5%8b%e8%af%95%ef%bc%883%ef%bc%89%ef%bc%9abroker%e8%b0%83%e4%bc%98%e7%bb%93%e6%9e%9c\/"},"modified":"2024-04-30T07:16:09","modified_gmt":"2024-04-29T23:16:09","slug":"apache-kafka%e6%80%a7%e8%83%bd%e6%b5%8b%e8%af%95%ef%bc%883%ef%bc%89%ef%bc%9abroker%e8%b0%83%e4%bc%98%e7%bb%93%e6%9e%9c","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/apache-kafka%e6%80%a7%e8%83%bd%e6%b5%8b%e8%af%95%ef%bc%883%ef%bc%89%ef%bc%9abroker%e8%b0%83%e4%bc%98%e7%bb%93%e6%9e%9c\/","title":{"rendered":"Apache Kafka\u6027\u80fd\u6d4b\u8bd5\uff083\uff09\uff1aBroker\u8c03\u4f18\u7ed3\u679c"},"content":{"rendered":"<p>\u53d1\u5e03\u65e5\u671f: 2018\u5e7411\u67081\u65e5<br \/>\n\u4f5c\u8005: \u4f0a\u85e4\u96c5\u535a\uff0c\u65e5\u7acb\u5236\u4f5c\u682a\u5f0f\u4f1a\u793e<\/p>\n<h1>\u9996\u5148<\/h1>\n<p>\u672c\u5e16\u4ecb\u7ecd\u4e86\u6211\u57282017\u5e74\u4f01\u4e1a\u7ea7\u5f00\u6e90\u4f1a\u8bae\u4e0a\u53d1\u8868\u7684\u201c\u76ee\u6807\uff01\u6210\u4e3aKafka\u5927\u5e08 \uff5e\u5982\u4f55\u5728Apache Kafka\u4e2d\u53d1\u6325\u6700\u4f73\u6027\u80fd\uff5e\u201d\u6f14\u8bb2\u7684\u9a8c\u8bc1\u8c03\u67e5\u5185\u5bb9\uff08\u51718\u6b21\uff09\u3002\u672c\u5e16\u5185\u5bb9\u662f\u57fa\u4e8e2017\u5e746\u6708\u53d1\u5e03\u7684Kafka 0.11.0\u7684\u7248\u672c\u3002<\/p>\n<p>\u8fd9\u4e00\u6b21\u662f\u7b2c\u516d\u6b21\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecdBroker\u7684\u8c03\u4f18\u7ed3\u679c\u3002\u5728\u4e0a\u4e00\u6b21\u7684\u6295\u7a3f\u4e2d\uff0c\u6211\u4eec\u4f18\u5316\u4e86Producer-Broker\u4e4b\u95f4\u7684\u901a\u4fe1\u541e\u5410\u91cf\u3002\u5728\u8fdb\u884c\u4e86\u8fd9\u4e00\u4f18\u5316\u4e4b\u540e\uff0c\u8fd9\u6b21\u6211\u4eec\u5c06\u5206\u522b\u8c03\u4f18Broker\u7684\u65e5\u5fd7\u5237\u65b0\u6027\u80fd\u548cBroker\u4e4b\u95f4\u7684\u590d\u5236\u6027\u80fd\uff0c\u4ee5\u8fdb\u4e00\u6b65\u4f18\u5316\u541e\u5410\u91cf\u3002<\/p>\n<p>\u6295\u7a3f\u4e00\u89a7\uff1a<br \/>\n1. Apache Kafka\u7684\u6982\u8ff0\u548c\u67b6\u6784<br \/>\n2. Apache Kafka\u7684\u751f\u4ea7\u8005\/\u4ee3\u7406\/\u6d88\u8d39\u8005\u5de5\u4f5c\u539f\u7406\u548c\u914d\u7f6e\u5217\u8868<br \/>\n3. Apache Kafka\u7684\u63a8\u8350\u914d\u7f6e\u548c\u6027\u80fd\u4f30\u7b97\u65b9\u6cd5<br \/>\n4. Apache Kafka\u7684\u6027\u80fd\u9a8c\u8bc1(1)\uff1a\u9a8c\u8bc1\u73af\u5883\u548c\u53c2\u6570\u8c03\u4f18\u5185\u5bb9<br \/>\n5. Apache Kafka\u7684\u6027\u80fd\u9a8c\u8bc1(2)\uff1a\u751f\u4ea7\u8005\u8c03\u4f18\u7ed3\u679c<br \/>\n6. [Apache Kafka\u7684\u6027\u80fd\u9a8c\u8bc1(3)\uff1a\u4ee3\u7406\u8c03\u4f18\u7ed3\u679c\uff08\u672c\u6295\u7a3f\uff09<br \/>\n7. Apache Kafka\u7684\u6027\u80fd\u9a8c\u8bc1(4)\uff1a\u751f\u4ea7\u8005\u518d\u8c03\u4f18\u548c\u6d88\u8d39\u8005\u8c03\u4f18\u7ed3\u679c<br \/>\n8. Apache Kafka\u7684\u6027\u80fd\u9a8c\u8bc1(5)\uff1a\u6574\u4f53\u7cfb\u7edf\u5ef6\u8fdf\u95ee\u9898<\/p>\n<h1>\u8c03\u6574\u7ecf\u7eaa\u4eba\u65e5\u5fd7\u5237\u65b0\u6027\u80fd<\/h1>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u5c06\u4f18\u5316\u5305\u62ecBroker\u65e5\u5fd7\u5237\u65b0\u5728\u5185\u7684\u541e\u5410\u91cf\u3002\u6211\u4eec\u5728\u4e0b\u56fe\u4e2d\u4ee5\u7ea2\u8272\u8868\u793a\u4e86\u8c03\u6574\u8303\u56f4\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d7b75913a08637a6995c3\/7-0.png\" alt=\"kafka06_01.png\" \/><\/div>\n<h2>\u5c06 acks \u4fee\u6539\u4e3a 1\u3002<\/h2>\n<p>\u5728\u7b2c5\u6b21\u63d0\u4ea4\u4e2d\uff0c\u4e3a\u6392\u9664Broker\u7684\u65e5\u5fd7\u5237\u65b0\u548c\u590d\u5236\u7684\u5f71\u54cd\uff0c\u6211\u4eec\u8fdb\u884c\u4e86acks=0\u7684\u8c03\u4f18\u3002\u5728\u672c\u6b21\u9a8c\u8bc1\u4e2d\uff0c\u4e3a\u4e86\u9a8c\u8bc1\u5305\u62ecBroker\u65e5\u5fd7\u5237\u65b0\u5728\u5185\u7684\u6027\u80fd\uff0c\u6211\u4eec\u5c06acks\u8bbe\u7f6e\u4e3a1\u3002\u4e0b\u9762\u662f\u5c06acks\u4ece0\u66f4\u6539\u4e3a1\u65f6\u541e\u5410\u91cf\u7684\u53d8\u5316\u3002<\/p>\n<p>\u5728\u672c\u6b21\u9a8c\u8bc1\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u590d\u5236\u56e0\u5b50=3\u8fdb\u884c\u6d4b\u91cf\uff0c\u5373\u5c06\u4ea7\u751f\u7684\u6570\u636e\u5728Broker\u4e4b\u95f4\u590d\u5236\u4e24\u500d\u6570\u91cf\uff0c\u4ee5\u4fbf\u66f4\u5bb9\u6613\u6bd4\u8f83\u590d\u5236\u541e\u5410\u91cf\u548c\u751f\u4ea7\/\u6d88\u8d39\u541e\u5410\u91cf\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u663e\u793a\u4e86\u4e00\u534a\u7684\u503c\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d7b75913a08637a6995c3\/11-0.png\" alt=\"kafka06_02.png\" \/><\/div>\n<p>\u5f53\u5c06acks\u66f4\u6539\u4e3a1\u65f6\uff0c\u751f\u6210\u7684\u541e\u5410\u91cf\u7565\u6709\u4e0b\u964d\uff0c\u4f46\u4ecd\u7136\u53ef\u4ee5\u786e\u8ba4\u5b83\u4fdd\u6301\u63a5\u8fd1\u4e8e\u7406\u8bba\u503c1,170MB\/s1\u7684\u541e\u5410\u91cf\u3002<\/p>\n<h2>\u65e5\u5fd7\u5237\u65b0\u8c03\u5ea6\u5668\u95f4\u9694\u65f6\u95f4\uff08log.flush.scheduler.interval.ms\uff09\u7684\u4f18\u5316<\/h2>\n<p>\u4e0b\u9762\u5c55\u793a\u4e86\u5728\u8c03\u6574Log Flush\u95f4\u9694\uff08log.flush.scheduler.interval.ms\uff09\u65f6\u7684\u541e\u5410\u91cf\u53d8\u5316\u3002\u6700\u5de6\u8fb9\u7684\u56fe\u8868\u8868\u793a\u9ed8\u8ba4\u8bbe\u7f6e\uff08Long\u578b\u6700\u5927\u503c\uff09\uff0cKafka\u4f1a\u4f9d\u8d56\u64cd\u4f5c\u7cfb\u7edf\u7684\u540e\u53f0\u5237\u65b0\u529f\u80fd\uff0c\u800c\u4e0d\u8fdb\u884c\u663e\u5f0f\u7684\u5237\u65b0\u64cd\u4f5c\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d7b75913a08637a6995c3\/15-0.png\" alt=\"kafka06_03.png\" \/><\/div>\n<p>\u5373\u4f7f\u66f4\u6539\u4e86\u95ea\u5149\u95f4\u9694\uff0cProduce\u7684\u541e\u5410\u91cf\u51e0\u4e4e\u6ca1\u6709\u53d8\u5316\u3002\u901a\u8fc7\u8fd9\u4e2a\u6d4b\u91cf\u7ed3\u679c\uff0c\u786e\u8ba4\u4e86\u95ea\u5149\u95f4\u9694\u5728\u9ed8\u8ba4\u8bbe\u7f6e\u4e0b\u6ca1\u6709\u95ee\u9898\u3002<\/p>\n<h2>num.io.threads\u7684\u8c03\u6574<\/h2>\n<p>\u4e0b\u9762\u5c55\u793a\u4e86\u8c03\u6574\u4e86\u8bf7\u6c42\u5904\u7406\u7a0b\u5e8f\u7ebf\u7a0b\u6570\uff08num.io.threads\uff09\u7684\u7ed3\u679c\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d7b75913a08637a6995c3\/19-0.png\" alt=\"kafka06_04.png\" \/><\/div>\n<p>\u4fee\u6539\u7ebf\u7a0b\u6570\u540e\uff0c\u751f\u4ea7\u541e\u5410\u91cf\u57fa\u672c\u4fdd\u6301\u4e0d\u53d8\u3002\u901a\u8fc7\u6b64\u6b21\u6d4b\u8bd5\uff0c\u786e\u8ba4\u8bf7\u6c42\u5904\u7406\u7a0b\u5e8f\u7684\u7ebf\u7a0b\u6570\u4f7f\u7528\u9ed8\u8ba4\u76848\u4e2a\u662f\u6ca1\u6709\u95ee\u9898\u7684\u3002<\/p>\n<h2>\u65e5\u5fd7\u95ea\u5b58\u6027\u80fd\u8c03\u4f18\u7ed3\u679c\u603b\u7ed3<\/h2>\n<p>\u6211\u5df2\u5c06Broker\u7684\u65e5\u5fd7\u5237\u65b0\u6027\u80fd\u8c03\u4f18\u7ed3\u679c\u603b\u7ed3\u5982\u4e0b\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d7b75913a08637a6995c3\/23-0.png\" alt=\"kafka06_05.png\" \/><\/div>\n<p>\u5728\u672c\u6b21\u9a8c\u8bc1\u4e2d\uff0c\u4e0d\u9700\u8981\u5bf9\u65e5\u5fd7\u5237\u65b0\u6027\u80fd\u8fdb\u884c\u8c03\u4f18\u3002\u8fd9\u662f\u56e0\u4e3a\u78c1\u76d8I\/O\u6027\u80fd\u7684\u7406\u8bba\u503c\u9ad8\u4e8e\u7f51\u7edcI\/O\u6027\u80fd\uff0c\u5e76\u4e14\u78c1\u76d8I\/O\u4e0d\u6210\u4e3a\u74f6\u9888\u7684\u539f\u56e0\u3002\u7ed3\u679c\u662f\uff0c\u751f\u4ea7\u8005\u7684\u53d1\u9001\u541e\u5410\u91cf\u5728acks=1\u7684\u60c5\u51b5\u4e0b\u8fbe\u52301,164 MB\/s\uff0c\u4f9d\u7136\u63a5\u8fd1\u7406\u8bba\u503c\uff081,170MB\/s\uff09\u7684\u541e\u5410\u91cf\u3002<\/p>\n<h1>\u5bf9Broker\u4e4b\u95f4\u7684\u590d\u5236\u6027\u80fd\u8fdb\u884c\u8c03\u4f18<\/h1>\n<p>\u4e0b\u4e00\u6b65\u662f\u4f18\u5316\u5305\u62ecBroker\u4e4b\u95f4\u7684\u590d\u5236\u5728\u5185\u7684\u541e\u5410\u91cf\u3002\u5728\u8fd9\u4e2a\u9a8c\u8bc1\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u8fdb\u884c\u8c03\u4f18\uff0c\u4ee5\u786e\u4fdd\u590d\u5236\u541e\u5410\u91cf\u7684\u53d8\u5316\u3002\u6700\u521d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528acks=1\u8fdb\u884c\u8c03\u4f18\u3002\u7136\u540e\uff0c\u5728\u590d\u5236\u541e\u5410\u91cf\u6539\u5584\u5230\u4e0e\u751f\u4ea7\u541e\u5410\u91cf\u76f8\u5339\u914d\u4e4b\u540e\uff0c\u6211\u4eec\u5c06\u5c06acks\u8bbe\u7f6e\u4e3aall\uff0c\u5e76\u8fdb\u884c\u6d4b\u91cf\u3002\u6211\u4eec\u5c06\u5728\u4ee5\u4e0b\u56fe\u8868\u4e2d\u7528\u7ea2\u8272\u8868\u793a\u8c03\u4f18\u8303\u56f4\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d7b75913a08637a6995c3\/27-0.png\" alt=\"kafka06_06.png\" \/><\/div>\n<h2>\u8c03\u6574 replica.fetch.response.max.bytes \u53c2\u6570\u7684\u503c\u3002<\/h2>\n<p>\u9996\u5148\uff0c\u6211\u5011\u5c07\u5c55\u793a\u66f4\u6539 Replica fetcher \u5728\u4e00\u6b21 Fetch \u8acb\u6c42\u4e2d\u7372\u53d6\u7684\u6700\u5927\u5927\u5c0f\uff08replica.fetch.response.max.bytes\uff09\u7684\u7d50\u679c\u3002\u6211\u5011\u5c07\u8a2d\u7f6e\u4e00\u500b\u8f03\u5927\u7684\u503c\uff08100MB\uff09\u7d66\u8a72\u53c3\u6578\uff0c\u7136\u5f8c\u901a\u904e\u8abf\u6574\u4ee5\u5206\u5340\u70ba\u55ae\u4f4d\u7684\u6700\u5927\u7372\u53d6\u5927\u5c0f\uff08replica.fetch.max.bytes\uff09\u4f86\u8abf\u6574\u7372\u53d6\u7684\u5927\u5c0f\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d7b75913a08637a6995c3\/30-0.png\" alt=\"kafka06_07.png\" \/><\/div>\n<p>\u901a\u8fc7\u8fd9\u4e2a\u66f4\u6539\uff0cReplicate\u7684\u541e\u5410\u91cf\u7565\u5fae\u63d0\u9ad8\uff0c\u4ece278 MB\/s\u589e\u52a0\u5230287 MB\/s\u3002<\/p>\n<h2>\u8c03\u6574 replica.fetch.max.bytes \u7684\u53c2\u6570<\/h2>\n<p>\u4ee5\u4e0b\u662f\u8c03\u6574\u4e86Replica fetcher\u5728\u5355\u4e2aFetch\u8bf7\u6c42\u4e2d\u83b7\u53d6\u7684Partition\u5355\u4f4d\u7684\u6700\u5927\u5927\u5c0f\uff08\u5373replica.fetch.max.bytes\uff09\u7684\u7ed3\u679c\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d7b75913a08637a6995c3\/34-0.png\" alt=\"kafka06_08.png\" \/><\/div>\n<p>\u901a\u8fc7\u5c06\u6b64\u53c2\u6570\u4ece1MB\u589e\u52a0\u52305MB\uff0c\u590d\u5236\u541e\u5410\u91cf\u4ece287MB\/s\u63d0\u9ad8\u5230356MB\/s\u3002<\/p>\n<h2>\u8c03\u6574 num.replica.fetchers \u548c num.network.threads\u3002<\/h2>\n<p>\u5f53\u589e\u52a0\u590d\u5236\u6293\u53d6\u8fdb\u7a0b\u6570\uff08num.replica.fetchers\uff09\u65f6\uff0c\u4f1a\u589e\u52a0\u4e0e\u7ecf\u7eaa\u4eba\u4e4b\u95f4\u7684\u8fde\u63a5\u6570\uff0c\u4ece\u800c\u7ed9\u7ecf\u7eaa\u4eba\u7684\u5957\u63a5\u5b57\u670d\u52a1\u5668\u5e26\u6765\u8d1f\u8f7d\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u540c\u65f6\u8c03\u6574\u4e86\u590d\u5236\u6293\u53d6\u8fdb\u7a0b\u6570\u548c\u5957\u63a5\u5b57\u670d\u52a1\u5668\u7684\u7f51\u7edc\u7ebf\u7a0b\u6570\uff08num.network.threads\uff09\u3002\u4ee5\u4e0b\u662f\u901a\u8fc7\u6b64\u8c03\u6574\u83b7\u5f97\u7684\u590d\u5236\u541e\u5410\u91cf\u7684\u53d8\u5316\u60c5\u51b5\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d7b75913a08637a6995c3\/38-0.png\" alt=\"kafka06_09.png\" \/><\/div>\n<p>\u901a\u8fc7\u8c03\u6574 num.replica.fetchers \uff0c\u6211\u4eec\u53ef\u4ee5\u663e\u8457\u589e\u52a0\u6027\u80fd\uff0c\u800c num.network.threads \u7684\u5f71\u54cd\u8f83\u5c0f\u3002\u968f\u7740 num.replica.fetchers \u7684\u589e\u52a0\uff0c\u541e\u5410\u91cf\u4f1a\u4e0d\u65ad\u63d0\u9ad8\uff0c\u4f46\u5f53 num.replica.fetchers \u662f3\u7684\u500d\u6570\u65f6\uff0c\u541e\u5410\u91cf\u6709\u4e0b\u964d\u7684\u8d8b\u52bf\u3002\u7a0d\u540e\u6211\u4eec\u5c06\u89e3\u91ca\u539f\u56e0\u3002<\/p>\n<p>\u7ecf\u8fc7\u6d4b\u8bd5\uff0c\u5f53\u5c06num.replica.fetchers\u4ece1\u589e\u52a0\u523016\u65f6\uff0cReplicate\u541e\u5410\u91cf\u4ece356MB\/s\u63d0\u5347\u5230784MB\/s\u3002\u4e0b\u9762\u5c55\u793a\u4e86\u5728num.network.threads=9\u6761\u4ef6\u4e0b\uff0cProduce\/Replicate\/Consume\u7684\u541e\u5410\u91cf\u53d8\u5316\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d7b75913a08637a6995c3\/41-0.png\" alt=\"kafka06_10.png\" \/><\/div>\n<p>\u968f\u7740num.replica.fetchers\u7684\u589e\u52a0\uff0cProduce\u541e\u5410\u91cf\u4e0b\u964d\uff0c\u800cReplicate\u541e\u5410\u91cf\u4e0a\u5347\u3002\u5f53num.replica.fetchers=16\u65f6\uff0c\u786e\u8ba4Replicate\u541e\u5410\u91cf\uff08784MB\/s\uff09\u548cProduce\u541e\u5410\u91cf\uff08780MB\/s\uff09\u51e0\u4e4e\u8fbe\u5230\u5e73\u8861\u3002<\/p>\n<h2>\u5c06 &#8220;acks&#8221; \u66f4\u6539\u4e3a &#8220;all&#8221;\u3002<\/h2>\n<p>\u4ee5\u4e0b\u662f\u5c06 acks \u4ece 1 \u66f4\u6539\u4e3a all \u65f6\u7684\u541e\u5410\u91cf\u3002\u7531\u4e8e\u672c\u6b21\u9a8c\u8bc1\u662f\u5728 min.insync.replicas=2 \u7684\u6761\u4ef6\u4e0b\u8fdb\u884c\u7684\uff0c\u56e0\u6b64\u8bbe\u7f6e acks=all \u53ef\u4ee5\u5728\u786e\u8ba4\u6570\u636e\u5df2\u88ab\u590d\u5236\u5230 Leader \u526f\u672c\u548c\u81f3\u5c11\u4e00\u4e2a Follower \u526f\u672c\u540e\uff0c\u5f00\u59cb\u5411 Producer \u8fd4\u56de\u54cd\u5e94\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d7b75913a08637a6995c3\/45-0.png\" alt=\"kafka06_11.png\" \/><\/div>\n<p>\u5c3d\u7ba1\u5728acks = 1\u7684\u65f6\u5019\uff0cProduce\u548cReplicate\u7684\u541e\u5410\u91cf\u51e0\u4e4e\u662f\u76f8\u7b49\u7684\uff0c\u4f46\u662f\u5f53\u8bbe\u7f6eacks = all\u65f6\uff0c\u541e\u5410\u91cf\u5374\u663e\u8457\u4e0b\u964d\u3002<\/p>\n<h2>\u590d\u5236\u6027\u80fd\u7684\u8c03\u4f18\u7ed3\u679c\u603b\u7ed3<\/h2>\n<p>\u6211\u603b\u7ed3\u4e86\u7ecf\u7eaa\u4eba\u4e4b\u95f4\u590d\u5236\u6027\u80fd\u8c03\u4f18\u7684\u7ed3\u679c\u5982\u4e0b\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d7b75913a08637a6995c3\/49-0.png\" alt=\"kafka06_12.png\" \/><\/div>\n<p>\u5728\u672c\u6b21\u9a8c\u8bc1\u4e2d\uff0c\u901a\u8fc7\u5c06acks\u8bbe\u7f6e\u4e3a1\uff0c\u6211\u6210\u529f\u5c06\u590d\u5236\u541e\u5410\u91cf\u63d0\u5347\u81f3784MB\/s\u3002\u7136\u800c\uff0c\u5f53\u5c06acks\u66f4\u6539\u4e3aall\u65f6\uff0c\u541e\u5410\u91cf\u5927\u5e45\u4e0b\u964d\u81f3405MB\/s\u3002<\/p>\n<h1>\u5bf9\u4e8e Replica fetcher \u7684 Partition \u5206\u914d\u7684\u4e0d\u5747\u8861\u60c5\u51b5<\/h1>\n<p>\u5728\u672c\u6b21\u9a8c\u8bc1\u4e2d\uff0c\u5f53 num.replica.fetchers \u662f3\u7684\u500d\u6570\u65f6\uff0c\u590d\u5236\u6027\u80fd\u4e0b\u964d\u3002\u8fd9\u662f\u7531\u4e8e\u5bf9\u4e8e Replica fetcher \u7684 Partition \u5206\u914d\u4e0d\u5747\u8861\u9020\u6210\u7684\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u5047\u8bbe\u67093\u4e2aBroker\uff0c\u5206\u914d\u4e866\u4e2aPartition\uff08\u7684Leader Replica\uff09\u3002\u5728\u521b\u5efa\u4e3b\u9898\u65f6\uff0cPartition 0\u7684Leader Replica\u5c06\u88ab\u5206\u914d\u5230\u4efb\u610f\u4e00\u4e2aBroker\uff0c\u800cPartition 1\u53ca\u5176\u540e\u7eed\u7684Partition\u5c06\u6309\u7167Broker ID\u7684\u987a\u5e8f\u5206\u914d\uff08\u8bf7\u53c2\u8003AdminUtils.scala\u548cPartitionStateMachine.scala\uff09\u3002\u4f8b\u5982\uff0c\u5982\u679c\u5c06Partition 0\uff08\u7684Leader Replica\uff09\u5206\u914d\u7ed9Broker1\uff0c\u5219\u5c06\u5f62\u6210\u4ee5\u4e0b\u5bf9\u5e94\u5173\u7cfb\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d7b75913a08637a6995c3\/54-0.png\" alt=\"kafka06_13.png\" \/><\/div>\n<p>\u5982\u679c\u6bcf\u4e2a broker \u90fd\u6709\u4e09\u4e2a replica fetcher \u7ebf\u7a0b\uff0c\u6bcf\u4e2a replica fetcher \u7ebf\u7a0b\u5c06\u8d1f\u8d23\u54ea\u4e2a partition\uff1f\u9996\u5148\uff0creplica fetcher 0 \u5c06\u88ab\u5206\u914d\u7ed9\u67d0\u4e2a partition\uff0c\u7136\u540e replica fetcher 1 \u5f00\u59cb\u4f9d\u6b21\u6309\u7167 partition ID \u8fdb\u884c\u5faa\u73af\u5206\u914d\uff08\u53c2\u8003 AbstractFetcherManager.scala\uff09\u3002\u4f8b\u5982\uff0c\u5982\u679c replica fetcher 0 \u88ab\u5206\u914d\u7ed9 partition 1\uff0c\u90a3\u4e48\u5c06\u5f62\u6210\u4ee5\u4e0b\u5bf9\u5e94\u5173\u7cfb\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d7b75913a08637a6995c3\/56-0.png\" alt=\"kafka06_14.png\" \/><\/div>\n<p>\u6839\u636e\u4e0a\u8ff0\u7b97\u6cd5\uff0c\u5982\u679cReplica Fetcher\u6570\u662fBroker\u6570\u7684\u500d\u6570\uff0c\u6bcf\u4e2aReplica Fetcher\u5c06\u88ab\u5206\u914d\u7ed9\u540c\u4e00\u4e2aBroker\u7684Partition\u3002\u56e0\u6b64\uff0c\u6bcf\u4e2aReplica Fetcher\u53ea\u8d1f\u8d23\u81ea\u5df1Broker\u7684Partition\uff0c\u4e0d\u518d\u88ab\u4f7f\u7528\uff08Replica Fetcher\u7528\u4e8e\u83b7\u53d6\u5176\u4ed6Broker\u4e0a\u7684Partition\u6570\u636e\uff09\u3002\u8fd9\u5c06\u5bfc\u81f4\u590d\u5236\u6027\u80fd\u4e0b\u964d\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u5982\u679c\u6709\u591a\u4e2a\u4e3b\u9898\uff0c\u526f\u672c\u63d0\u53d6\u5668\u7684\u5206\u914d\u5c06\u4f1a\u5206\u6563\uff0c\u4ece\u800c\u51cf\u8f7b\u8fd9\u79cd\u4e0d\u5747\u8861\u3002<\/p>\n<h1>\u6700\u540e<\/h1>\n<p>\u8fd9\u6b21\u6211\u4eec\u4ecb\u7ecd\u4e86\u7ecf\u7eaa\u4eba\u7684\u8c03\u6574\u7ed3\u679c\uff0c\u4f46\u662f\u5f53\u5c06acks\u8bbe\u7f6e\u4e3aall\u65f6\uff0c\u541e\u5410\u91cf\u663e\u8457\u4e0b\u964d\u3002\u8fd9\u662f\u56e0\u4e3a\u5728acks\u4e3a1\u548call\u65f6\uff0c\u9002\u5408\u7684\u8bb0\u5f55\u6279\u6b21\u5927\u5c0f\u548c\u751f\u4ea7\u8005\u6570\u91cf\u4e0d\u540c\u3002\u56e0\u6b64\u4e0b\u6b21\u6211\u4eec\u5c06\u518d\u6b21\u8fdb\u884cProducer\u7684\u8c03\u6574\uff0c\u4fdd\u6301acks\u4e3aall\u3002\u7136\u540e\u8fdb\u884cConsumer\u7684\u8c03\u6574\uff0c\u5c55\u793a\u4f18\u5316\u6574\u4e2a\u7cfb\u7edf\u541e\u5410\u91cf\u7684\u7ed3\u679c\u3002<\/p>\n<p>\u7b2c\u4e03\u90e8\u5206\uff1aApache Kafka\u7684\u6027\u80fd\u9a8c\u8bc1\uff084\uff09\uff1aProducer\u7684\u91cd\u65b0\u8c03\u6574\u4ee5\u53caConsumer\u7684\u8c03\u6574\u7ed3\u679c\u3002<\/p>\n<div>\u53ef\u53c2\u8003\u7b2c\u56db\u7bc7\u53d1\u5e03\u7684\u5185\u5bb9\u6765\u8fdb\u884c\u9a8c\u8bc1\u65f6\u7684\u53c2\u6570\u8bbe\u7f6e\u548c\u7406\u8bba\u4e0a\u7684\u6700\u5927\u541e\u5410\u91cf\u3002<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u53d1\u5e03\u65e5\u671f: 2018\u5e7411\u67081\u65e5 \u4f5c\u8005: \u4f0a\u85e4\u96c5\u535a\uff0c\u65e5\u7acb\u5236\u4f5c\u682a\u5f0f\u4f1a\u793e \u9996\u5148 \u672c\u5e16\u4ecb\u7ecd\u4e86\u6211\u57282017\u5e74\u4f01\u4e1a\u7ea7\u5f00\u6e90 [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-46873","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Apache Kafka\u6027\u80fd\u6d4b\u8bd5\uff083\uff09\uff1aBroker\u8c03\u4f18\u7ed3\u679c - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/apache-kafka\u6027\u80fd\u6d4b\u8bd5\uff083\uff09\uff1abroker\u8c03\u4f18\u7ed3\u679c\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Apache Kafka\u6027\u80fd\u6d4b\u8bd5\uff083\uff09\uff1aBroker\u8c03\u4f18\u7ed3\u679c\" \/>\n<meta property=\"og:description\" content=\"\u53d1\u5e03\u65e5\u671f: 2018\u5e7411\u67081\u65e5 \u4f5c\u8005: \u4f0a\u85e4\u96c5\u535a\uff0c\u65e5\u7acb\u5236\u4f5c\u682a\u5f0f\u4f1a\u793e \u9996\u5148 \u672c\u5e16\u4ecb\u7ecd\u4e86\u6211\u57282017\u5e74\u4f01\u4e1a\u7ea7\u5f00\u6e90 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/apache-kafka\u6027\u80fd\u6d4b\u8bd5\uff083\uff09\uff1abroker\u8c03\u4f18\u7ed3\u679c\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-12T06:47:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-29T23:16:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d7b75913a08637a6995c3\/7-0.png\" \/>\n<meta name=\"author\" content=\"\u6e05, \u5b87\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6e05, \u5b87\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/apache-kafka%e6%80%a7%e8%83%bd%e6%b5%8b%e8%af%95%ef%bc%883%ef%bc%89%ef%bc%9abroker%e8%b0%83%e4%bc%98%e7%bb%93%e6%9e%9c\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/apache-kafka%e6%80%a7%e8%83%bd%e6%b5%8b%e8%af%95%ef%bc%883%ef%bc%89%ef%bc%9abroker%e8%b0%83%e4%bc%98%e7%bb%93%e6%9e%9c\/\",\"name\":\"Apache Kafka\u6027\u80fd\u6d4b\u8bd5\uff083\uff09\uff1aBroker\u8c03\u4f18\u7ed3\u679c - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-03-12T06:47:42+00:00\",\"dateModified\":\"2024-04-29T23:16:09+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/apache-kafka%e6%80%a7%e8%83%bd%e6%b5%8b%e8%af%95%ef%bc%883%ef%bc%89%ef%bc%9abroker%e8%b0%83%e4%bc%98%e7%bb%93%e6%9e%9c\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/apache-kafka%e6%80%a7%e8%83%bd%e6%b5%8b%e8%af%95%ef%bc%883%ef%bc%89%ef%bc%9abroker%e8%b0%83%e4%bc%98%e7%bb%93%e6%9e%9c\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/apache-kafka%e6%80%a7%e8%83%bd%e6%b5%8b%e8%af%95%ef%bc%883%ef%bc%89%ef%bc%9abroker%e8%b0%83%e4%bc%98%e7%bb%93%e6%9e%9c\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Apache Kafka\u6027\u80fd\u6d4b\u8bd5\uff083\uff09\uff1aBroker\u8c03\u4f18\u7ed3\u679c\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e\",\"name\":\"\u6e05, \u5b87\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g\",\"caption\":\"\u6e05, \u5b87\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyu\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/apache-kafka%e6%80%a7%e8%83%bd%e6%b5%8b%e8%af%95%ef%bc%883%ef%bc%89%ef%bc%9abroker%e8%b0%83%e4%bc%98%e7%bb%93%e6%9e%9c\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Apache Kafka\u6027\u80fd\u6d4b\u8bd5\uff083\uff09\uff1aBroker\u8c03\u4f18\u7ed3\u679c - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/apache-kafka\u6027\u80fd\u6d4b\u8bd5\uff083\uff09\uff1abroker\u8c03\u4f18\u7ed3\u679c\/","og_locale":"zh_CN","og_type":"article","og_title":"Apache Kafka\u6027\u80fd\u6d4b\u8bd5\uff083\uff09\uff1aBroker\u8c03\u4f18\u7ed3\u679c","og_description":"\u53d1\u5e03\u65e5\u671f: 2018\u5e7411\u67081\u65e5 \u4f5c\u8005: \u4f0a\u85e4\u96c5\u535a\uff0c\u65e5\u7acb\u5236\u4f5c\u682a\u5f0f\u4f1a\u793e \u9996\u5148 \u672c\u5e16\u4ecb\u7ecd\u4e86\u6211\u57282017\u5e74\u4f01\u4e1a\u7ea7\u5f00\u6e90 [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/apache-kafka\u6027\u80fd\u6d4b\u8bd5\uff083\uff09\uff1abroker\u8c03\u4f18\u7ed3\u679c\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-03-12T06:47:42+00:00","article_modified_time":"2024-04-29T23:16:09+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d7b75913a08637a6995c3\/7-0.png"}],"author":"\u6e05, \u5b87","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u6e05, \u5b87","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/apache-kafka%e6%80%a7%e8%83%bd%e6%b5%8b%e8%af%95%ef%bc%883%ef%bc%89%ef%bc%9abroker%e8%b0%83%e4%bc%98%e7%bb%93%e6%9e%9c\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/apache-kafka%e6%80%a7%e8%83%bd%e6%b5%8b%e8%af%95%ef%bc%883%ef%bc%89%ef%bc%9abroker%e8%b0%83%e4%bc%98%e7%bb%93%e6%9e%9c\/","name":"Apache Kafka\u6027\u80fd\u6d4b\u8bd5\uff083\uff09\uff1aBroker\u8c03\u4f18\u7ed3\u679c - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-03-12T06:47:42+00:00","dateModified":"2024-04-29T23:16:09+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/apache-kafka%e6%80%a7%e8%83%bd%e6%b5%8b%e8%af%95%ef%bc%883%ef%bc%89%ef%bc%9abroker%e8%b0%83%e4%bc%98%e7%bb%93%e6%9e%9c\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/apache-kafka%e6%80%a7%e8%83%bd%e6%b5%8b%e8%af%95%ef%bc%883%ef%bc%89%ef%bc%9abroker%e8%b0%83%e4%bc%98%e7%bb%93%e6%9e%9c\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/apache-kafka%e6%80%a7%e8%83%bd%e6%b5%8b%e8%af%95%ef%bc%883%ef%bc%89%ef%bc%9abroker%e8%b0%83%e4%bc%98%e7%bb%93%e6%9e%9c\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"Apache Kafka\u6027\u80fd\u6d4b\u8bd5\uff083\uff09\uff1aBroker\u8c03\u4f18\u7ed3\u679c"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e","name":"\u6e05, \u5b87","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g","caption":"\u6e05, \u5b87"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyu\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/apache-kafka%e6%80%a7%e8%83%bd%e6%b5%8b%e8%af%95%ef%bc%883%ef%bc%89%ef%bc%9abroker%e8%b0%83%e4%bc%98%e7%bb%93%e6%9e%9c\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/46873","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=46873"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/46873\/revisions"}],"predecessor-version":[{"id":90479,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/46873\/revisions\/90479"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=46873"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=46873"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=46873"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}