{"id":90436,"date":"2026-08-05T09:25:28","date_gmt":"2026-08-05T01:25:28","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/90436.html"},"modified":"2026-08-05T09:25:28","modified_gmt":"2026-08-05T01:25:28","slug":"rocketmq-%e6%b6%88%e6%81%af%e5%a0%86%e7%a7%af%e6%80%8e%e4%b9%88%e5%8a%9e%ef%bc%9f%e7%ba%bf%e7%a8%8b%e6%b1%a0%e7%94%a8%e5%ae%8c%e6%89%8d%e6%98%af%e7%97%85%e6%a0%b9","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/90436.html","title":{"rendered":"RocketMQ \u6d88\u606f\u5806\u79ef\u600e\u4e48\u529e\uff1f\u7ebf\u7a0b\u6c60\u7528\u5b8c\u624d\u662f\u75c5\u6839"},"content":{"rendered":"<p>\u573a\u666f&#xff1a;\u4e1a\u52a1\u7aef\u5230\u7aef\u8017\u65f6\u4ece 200ms \u6da8\u5230 5s&#xff0c;\u6d88\u606f\u5806\u79ef 50 \u4e07\u6761\u3002\u4e1a\u52a1\u65b9\u6000\u7591\u751f\u4ea7\u8005\u6162&#xff0c;\u94fe\u8def\u8ffd\u8e2a\u53d1\u73b0\u6d88\u8d39\u7aef\u624d\u662f\u6839\u56e0\u2014\u201420 \u4e2a\u6d88\u8d39\u8005\u7ebf\u7a0b\u5168\u90e8\u5361\u5728\u540c\u6b65 DB \u5199\u5165\u4e0a&#xff0c;\u5f62\u6210 rebalance \u6b7b\u4ea1\u87ba\u65cb \u8def\u5f84&#xff1a;\u6d88\u8d39 lag \u76d1\u63a7 \u2192 \u6d88\u8d39\u8005\u7ebf\u7a0b\u6c60 \u2192 \u6d88\u8d39\u8005\u6e90\u7801 \u2192 \u4e1a\u52a1\u4ee3\u7801 \u2192 \u4fee\u590d\u65b9\u6848<\/p>\n<p>\u4e0a\u7bc7\u8bb2\u4e86 10909 VIP \u7aef\u53e3\u963b\u585e\u5bfc\u81f4 RocketMQ \u6d88\u606f\u53d1\u9001\u7aef\u5927\u91cf\u8d85\u65f6&#xff0c;\u8fd9\u6b21\u6211\u4eec\u6765\u770b\u6d88\u8d39\u7aef\u6700\u7ecf\u5178\u7684\u95ee\u9898\u2014\u2014\u6d88\u606f\u5806\u79ef\u3002<\/p>\n<p>\u4e0b\u5355\u63a5\u53e3\u8017\u65f6\u4ece 200ms \u6da8\u5230 5s&#xff0c;\u4e1a\u52a1\u65b9\u7b2c\u4e00\u53cd\u5e94\u662f\u6570\u636e\u5e93\u6162\u3002DBA \u67e5\u4e86\u4e00\u5708\u2014\u2014\u6570\u636e\u5e93\u6beb\u65e0\u538b\u529b\u3002<\/p>\n<p>\u770b\u751f\u4ea7\u7aef\u76d1\u63a7&#xff0c;send OK \u4f46 ack \u8017\u65f6\u5728\u6da8\u3002\u67e5 Broker \u8bf7\u6c42\u961f\u5217\u2014\u2014PUT \u8bf7\u6c42\u5728\u6392\u961f\u3002\u770b\u6d88\u8d39\u7aef\u2014\u2014\u5806\u79ef\u4e86 50 \u4e07\u6761\u6d88\u606f&#xff0c;20 \u4e2a\u6d88\u8d39\u8005\u7ebf\u7a0b\u5168\u90e8\u7e41\u5fd9\u3002<\/p>\n<p>\u4ee5\u540e\u4f60\u770b\u5230\u63a5\u53e3\u53d8\u6162\u3001\u6570\u636e\u5e93\u6b63\u5e38\u65f6&#xff1a; \u5148\u770b\u8c03\u7528\u94fe\u627e\u5230\u4e0b\u6e38\u7ec4\u4ef6&#xff0c;\u518d\u770b\u8fd9\u4e2a\u7ec4\u4ef6\u7684\u6838\u5fc3\u6307\u6807\u3002<\/p>\n<p>\u5982\u679c\u6d88\u8d39 lag \u5728\u6da8\u2014\u2014\u95ee\u9898 90% \u5728\u6d88\u8d39\u7aef&#xff0c;\u4e0d\u662f\u751f\u4ea7\u7aef\u3002<\/p>\n<h3>\u3010\u73b0\u8c61\u3011\u4e1a\u52a1\u8d85\u65f6 &#043; 50 \u4e07\u5806\u79ef<\/h3>\n<h4>\u4e1a\u52a1\u8868\u73b0<\/h4>\n<p>\u201cMQ \u6d88\u8d39\u7aef\u8d1f\u8d23\u4eba&#xff1a;\u4f60\u7684 topic \u5806\u79ef\u4e86 50 \u4e07\u3002\u201d \u201c\u4e1a\u52a1\u65b9&#xff1a;\u4e0d\u662f\u751f\u4ea7\u7aef\u7684\u95ee\u9898\u5427&#xff1f;\u201d<\/p>\n<p>\u8fd9\u4e24\u53e5\u5bf9\u8bdd\u5728\u4e2d\u95f4\u4ef6 team \u5f88\u5e38\u89c1\u3002\u6d88\u606f\u5806\u79ef\u51fa\u73b0\u65f6&#xff0c;\u4e1a\u52a1\u65b9\u5929\u7136\u5148\u6000\u7591\u751f\u4ea7\u7aef\u2014\u2014\u201c\u6211\u53d1\u4e0d\u51fa\u53bb\u600e\u4e48\u80fd\u53eb\u5806\u79ef\u5462&#xff1f;\u201d<\/p>\n<p>\u4f46\u76d1\u63a7\u6570\u636e\u7ed9\u51fa\u4e86\u5b8c\u5168\u76f8\u53cd\u7684\u753b\u9762&#xff1a;<\/p>\n<ul>\n<li>\u751f\u4ea7\u7aef TPS \u7a33\u5b9a\u5728 500\/s&#xff0c;send \u6210\u529f\u7387 99.99%<\/li>\n<li>\u6d88\u8d39\u7aef lag&#xff08;\u6d88\u8d39\u5ef6\u8fdf\u2014\u2014\u6d88\u8d39\u8005\u5f53\u524d\u4f4d\u7f6e\u4e0e\u6700\u65b0\u6d88\u606f\u7684\u8ddd\u79bb&#xff0c;\u5355\u4f4d\u662f\u6d88\u606f\u6761\u6570&#xff09;\u6301\u7eed\u589e\u957f&#xff0c;\u4ece 0 \u5230 50 \u4e07\u7528\u4e86\u4e0d\u5230 2 \u5c0f\u65f6<\/li>\n<\/ul>\n<p>\u6d88\u606f\u7684&#034;\u751f\u4ea7-\u6d88\u8d39&#034;\u6709\u4e24\u4e2a\u72ec\u7acb\u8def\u5f84\u3002\u751f\u4ea7\u7aef\u6b63\u5e38\u4e0d\u4ee3\u8868\u6d88\u8d39\u7aef\u6ca1\u95ee\u9898\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260805012447-6a7290df96064.png\" alt=\"\u6d88\u8d39 Lag \u544a\u8b66\u9762\u677f\" \/><\/p>\n<h4>\u7f51\u7edc\u5c42\u6392\u9664<\/h4>\n<p>\u4e0d\u5148\u6392\u7f51\u7edc\u5c31\u8c03\u914d\u7f6e\u662f\u4e2d\u95f4\u4ef6\u6392\u67e5\u7684&#034;\u4e03\u5b97\u7f6a&#034;\u4e4b\u9996\u3002<\/p>\n<p><span class=\"token comment\"># \u6d4b\u8bd5 Broker \u8fde\u901a\u6027<\/span><br \/>\n$ telnet <span class=\"token number\">10.0<\/span>.0.1 <span class=\"token number\">10911<\/span><br \/>\nTrying <span class=\"token number\">10.0<\/span>.0.1<span class=\"token punctuation\">..<\/span>.<br \/>\nConnected to <span class=\"token number\">10.0<\/span>.0.1.<br \/>\nEscape character is <span class=\"token string\">&#039;^]&#039;<\/span><span class=\"token builtin class-name\">.<\/span><\/p>\n<p><span class=\"token comment\"># \u6d4b\u7f51\u7edc\u5ef6\u8fdf\u548c\u4e22\u5305<\/span><br \/>\n$ <span class=\"token function\">ping<\/span> <span class=\"token parameter variable\">-c<\/span> <span class=\"token number\">10<\/span> <span class=\"token number\">10.0<\/span>.0.1<br \/>\nrtt min\/avg\/max\/mdev <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0.321<\/span>\/0.456\/0.623\/0.089 ms<br \/>\n<span class=\"token number\">0<\/span>% packet loss<\/p>\n<p>\u7f51\u7edc\u5ef6\u8fdf 0.5ms&#xff0c;\u65e0\u4e22\u5305&#xff0c;\u8fde\u901a\u6027\u6b63\u5e38\u3002<\/p>\n<h4>\u6d88\u8d39\u7ebf\u7a0b\u6c60\u5168\u6ee1<\/h4>\n<p><span class=\"token comment\"># \u67e5\u770b\u6d88\u8d39\u8005\u7ebf\u7a0b\u6c60\u72b6\u6001&#xff08;JMX&#xff09;<\/span><br \/>\n$ jmxterm <span class=\"token parameter variable\">-l<\/span> localhost:18926<br \/>\n$ bean <span class=\"token parameter variable\">-d<\/span> org.apache.rocketmq <span class=\"token parameter variable\">-n<\/span> org.apache.rocketmq.client.internal.thread.pool<br \/>\n<span class=\"token comment\"># \u6216\u8005\u901a\u8fc7 jstack<\/span><br \/>\n$ jstack <span class=\"token operator\">&lt;<\/span>consumer_pid<span class=\"token operator\">&gt;<\/span> <span class=\"token operator\">|<\/span> <span class=\"token function\">grep<\/span> <span class=\"token string\">&#039;consumeExecutor&#039;<\/span> <span class=\"token parameter variable\">-A<\/span> <span class=\"token number\">5<\/span><br \/>\n<span class=\"token string\">&#034;ConsumeMessageThread_1&#034;<\/span> <span class=\"token comment\">#44 prio&#061;5 os_prio&#061;0 tid&#061;0x00007f&#8230;<\/span><br \/>\n<span class=\"token string\">&#034;ConsumeMessageThread_2&#034;<\/span> <span class=\"token comment\">#45 prio&#061;5 os_prio&#061;0 tid&#061;0x00007f&#8230;<\/span><br \/>\n<span class=\"token punctuation\">..<\/span>.<br \/>\n<span class=\"token string\">&#034;ConsumeMessageThread_20&#034;<\/span> <span class=\"token comment\">#63 prio&#061;5 os_prio&#061;0 tid&#061;0x00007f&#8230;<\/span><\/p>\n<p>20 \u4e2a ConsumeMessageThread_* \u5168\u90e8\u5904\u4e8e RUNNABLE \u72b6\u6001&#xff0c;\u4f46\u6bcf\u4e2a\u7ebf\u7a0b\u90fd\u963b\u585e\u5728\u540c\u4e00\u4e2a\u5806\u6808\u2014\u2014orderService.save() \u7684 JDBC \u8c03\u7528\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260805012452-6a7290e4f2d7f.png\" alt=\"\u6d88\u8d39\u8005\u7ebf\u7a0b\u5806\u6808 \u2014 \u5168\u90e8\u5361\u5728 DB \u5199\u5165\" \/><\/p>\n<h3>\u3010\u8054\u67e5\u3011\u751f\u4ea7\u8005 \u2192 Broker \u2192 \u6d88\u8d39\u8005<\/h3>\n<h4>\u751f\u4ea7\u8005\u5c42&#xff1a;send OK \u4f46 ack \u6162<\/h4>\n<p>\u751f\u4ea7\u8005\u53d1\u9001\u6b63\u5e38&#xff0c;\u4f46 sendResult \u7684\u8017\u65f6\u4ece\u6b63\u5e38 &lt;50ms \u6da8\u5230 1-2s\u3002<\/p>\n<p>\u8fd9\u8bf4\u660e Broker \u6536\u5230\u4e86\u6d88\u606f&#xff0c;\u4f46\u5904\u7406\u53d8\u6162\u4e86\u2014\u2014Broker \u7684\u5904\u7406\u7ebf\u7a0b\u4e5f\u5728\u6392\u961f\u3002<\/p>\n<h4>OS \u5c42\u6392\u67e5&#xff1a;\u6392\u9664\u7cfb\u7edf\u8d44\u6e90\u7ade\u4e89<\/h4>\n<p>\u5f53\u6d88\u8d39\u7aef\u74f6\u9888\u5b9a\u4f4d\u5230&#034;\u5904\u7406\u6162&#034;\u540e&#xff0c;\u9700\u8981\u786e\u8ba4\u662f\u4e1a\u52a1\u4ee3\u7801\u6162\u8fd8\u662f\u7cfb\u7edf\u8d44\u6e90\u4e0d\u591f\u3002\u8fd9\u4e00\u6b65\u7ecf\u5e38\u88ab\u8df3\u8fc7\u2014\u2014\u7ed3\u679c\u8c03\u4e86\u534a\u5929\u914d\u7f6e&#xff0c;\u53d1\u73b0\u662f\u78c1\u76d8 IO \u6253\u6ee1\u4e86\u3002<\/p>\n<p><span class=\"token comment\"># \u67e5\u770b CPU \u4f7f\u7528\u7387\u548c\u7ebf\u7a0b\u7ea7\u8d1f\u8f7d<\/span><br \/>\n$ <span class=\"token function\">top<\/span> <span class=\"token parameter variable\">-H<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token operator\">&lt;<\/span>consumer_pid<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token function\">top<\/span> &#8211; <span class=\"token number\">10<\/span>:32:45 up <span class=\"token number\">30<\/span> days, load average: <span class=\"token number\">4.8<\/span>, <span class=\"token number\">5.2<\/span>, <span class=\"token number\">5.6<\/span><br \/>\nThreads: <span class=\"token number\">89<\/span> total, <span class=\"token number\">1<\/span> running, <span class=\"token number\">88<\/span> sleeping<br \/>\n%Cpu<span class=\"token punctuation\">(<\/span>s<span class=\"token punctuation\">)<\/span>: <span class=\"token number\">45.2<\/span> us, <span class=\"token number\">8.3<\/span> sy, <span class=\"token number\">0.0<\/span> ni, <span class=\"token number\">45.0<\/span> id, <span class=\"token number\">0.5<\/span> wa<\/p>\n<p>  PID <span class=\"token environment constant\">USER<\/span>      PR  NI    VIRT    RES    SHR  S %CPU %MEM  TIME&#043; COMMAND<br \/>\n<span class=\"token number\">28901<\/span> admin     <span class=\"token number\">20<\/span>   <span class=\"token number\">0<\/span> 4850m <span class=\"token number\">1<\/span>.2g   45m   S <span class=\"token number\">12.5<\/span> <span class=\"token number\">15.3<\/span> <span class=\"token number\">35<\/span>:20 <span class=\"token function\">java<\/span><br \/>\n<span class=\"token number\">28905<\/span> admin     <span class=\"token number\">20<\/span>   <span class=\"token number\">0<\/span> 4850m <span class=\"token number\">1<\/span>.2g   45m   S <span class=\"token number\">12.3<\/span> <span class=\"token number\">15.3<\/span> <span class=\"token number\">35<\/span>:18 <span class=\"token function\">java<\/span><br \/>\n<span class=\"token number\">28906<\/span> admin     <span class=\"token number\">20<\/span>   <span class=\"token number\">0<\/span> 4850m <span class=\"token number\">1<\/span>.2g   45m   S <span class=\"token number\">12.1<\/span> <span class=\"token number\">15.3<\/span> <span class=\"token number\">35<\/span>:15 <span class=\"token function\">java<\/span><\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u78c1\u76d8 I\/O \u7b49\u5f85<\/span><br \/>\n$ iostat <span class=\"token parameter variable\">-x<\/span> <span class=\"token number\">1<\/span> <span class=\"token number\">3<\/span><br \/>\nDevice   r\/s   w\/s   rkB\/s   wkB\/s  await  svctm  %util<br \/>\nvda    <span class=\"token number\">12.3<\/span>  <span class=\"token number\">45.6<\/span>   <span class=\"token number\">48.2<\/span>   <span class=\"token number\">182.4<\/span>   <span class=\"token number\">1.2<\/span>    <span class=\"token number\">0.8<\/span>    <span class=\"token number\">5.0<\/span><\/p>\n<p><span class=\"token comment\"># \u67e5\u770b GC \u9891\u7387<\/span><br \/>\n$ jstat <span class=\"token parameter variable\">-gcutil<\/span> <span class=\"token number\">28901<\/span> <span class=\"token number\">1000<\/span> <span class=\"token number\">5<\/span><br \/>\n S0     S1     E      O      M     YGC     YGCT    FGC    FGCT<br \/>\n<span class=\"token number\">31.25<\/span> <span class=\"token number\">42.50<\/span> <span class=\"token number\">38.20<\/span> <span class=\"token number\">35.80<\/span> <span class=\"token number\">92.34<\/span>  <span class=\"token number\">1,245<\/span>   <span class=\"token number\">31.23<\/span>     <span class=\"token number\">8<\/span>    <span class=\"token number\">2.45<\/span><\/p>\n<p>\u4e09\u9879\u6307\u6807\u5168\u90e8\u6b63\u5e38&#xff1a;CPU 45% idle\u3001\u78c1\u76d8 await &lt;2ms\u3001Young GC &lt;30ms\u3001\u65e0 Full GC\u3002<\/p>\n<p>OS \u5c42\u4e0d\u662f\u6839\u56e0\u2014\u2014\u6392\u9664\u3002\u628a\u6392\u67e5\u7cbe\u529b\u653e\u56de\u4e1a\u52a1\u4ee3\u7801\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260805012458-6a7290ea2d310.png\" alt=\"OS \u5c42\u6392\u67e5\uff1atop + iostat + jstat\" \/><\/p>\n<h4>Broker \u5c42&#xff1a;PUT \u8bf7\u6c42\u6392\u961f<\/h4>\n<p><span class=\"token comment\"># \u67e5\u770b Broker \u8bf7\u6c42\u961f\u5217<\/span><br \/>\n$ jmxterm <span class=\"token parameter variable\">-l<\/span> localhost:18925<br \/>\n$ get <span class=\"token parameter variable\">-d<\/span> org.apache.rocketmq <span class=\"token parameter variable\">-b<\/span> org.apache.rocketmq:type<span class=\"token operator\">&#061;<\/span>BrokerServerStats<br \/>\n<span class=\"token comment\"># requestQueueSize<\/span><br \/>\nrequestQueueSize <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">378<\/span><\/p>\n<p>Broker \u7684 PUT \u8bf7\u6c42\u6392\u961f 378 \u4e2a\u3002\u4e3a\u4ec0\u4e48 Broker \u5904\u7406\u4e0d\u8fc7\u6765&#xff1f;\u4e0d\u662f\u56e0\u4e3a Broker \u6162\u4e86&#xff0c;\u662f\u56e0\u4e3a\u6d88\u8d39\u7aef\u4e0d\u6d88\u8d39\u4e86\u2014\u2014Broker \u7684\u6d88\u8d39\u8fdb\u5ea6\u4e0d\u66f4\u65b0&#xff0c;\u6d88\u606f\u65e0\u6cd5\u5220\u9664&#xff0c;CommitLog \u5199\u5165\u8d8a\u6765\u8d8a\u6162\u3002<\/p>\n<p>\u4e2d\u95f4\u4ef6\u662f\u94fe\u5f0f\u7684&#xff0c;\u4e00\u7aef\u5361\u987f&#xff0c;\u5168\u94fe\u964d\u901f\u3002<\/p>\n<h4>\u6d88\u8d39\u8005\u5c42&#xff1a;\u6e90\u7801\u770b\u6d88\u8d39\u7ebf\u7a0b\u6a21\u578b<\/h4>\n<p>\u4ece\u76d1\u63a7\u6570\u636e\u6765\u770b&#xff0c;\u751f\u4ea7\u7aef\u548c Broker \u90fd\u4e0d\u662f\u6839\u56e0&#xff0c;\u5b83\u4eec\u662f\u88ab\u6d88\u8d39\u7aef\u62d6\u6162\u7684\u3002\u771f\u6b63\u7684\u95ee\u9898\u5728\u6d88\u8d39\u8005\u3002<\/p>\n<p>\u56db\u4e2a\u9ed8\u8ba4\u503c&#xff0c;\u6bcf\u4e2a\u90fd\u662f\u4e00\u9897\u5b9a\u65f6\u70b8\u5f39\u2014\u2014\u53d6\u51b3\u4e8e\u4f60\u7684\u4e1a\u52a1\u573a\u666f\u662f\u5426\u6ee1\u8db3 RocketMQ \u7684\u8bbe\u8ba1\u5047\u8bbe\u3002<\/p>\n<p>\u5f53 consumeThreadMin \u548c consumeThreadMax \u90fd\u662f 20 \u65f6&#xff0c;\u7ebf\u7a0b\u6c60\u662f\u56fa\u5b9a\u5927\u5c0f\u7684\u2014\u2014\u9ad8\u5cf0\u671f\u7528\u6ee1\u5c31\u662f 20 \u6761\u7ebf\u7a0b&#xff0c;\u591a\u51fa\u6765\u7684\u4efb\u52a1\u5728 LinkedBlockingQueue \u91cc\u6392\u961f\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260805012503-6a7290eff09f2.png\" alt=\"DefaultMQPushConsumer \u914d\u7f6e\u9ed8\u8ba4\u503c\" \/><\/p>\n<p>\u63a5\u7740\u770b\u6d88\u8d39\u4efb\u52a1\u600e\u4e48\u63d0\u4ea4\u5230\u7ebf\u7a0b\u6c60\u7684&#xff1a;<\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u63ed\u793a\u4e86\u4e24\u4e2a\u5173\u952e\u8bbe\u8ba1&#xff1a;<\/p>\n<li>consumeMessageBatchMaxSize&#061;1 \u2192 \u4e00\u6b21 ConsumeRequest \u53ea\u5904\u7406 1 \u6761\u6d88\u606f<\/li>\n<li>\u7ebf\u7a0b\u6c60\u6ee1\u65f6\u4e0d\u4f1a\u4e22\u5f03\u6d88\u606f&#xff0c;\u800c\u662f submitConsumeRequestLater&#xff08;\u5ef6\u8fdf 5s \u91cd\u8bd5&#xff09;\u2014\u2014\u4f46\u8fd9\u610f\u5473\u7740\u6d88\u8d39\u901f\u5ea6\u8fdb\u4e00\u6b65\u4e0b\u964d<\/li>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260805012508-6a7290f4aaddd.png\" alt=\"submitConsumeRequest \u7ebf\u7a0b\u6c60\u63d0\u4ea4\u6d41\u7a0b\" \/><\/p>\n<h4>\u6d88\u8d39\u7ebf\u7a0b\u5185\u90e8&#xff1a;ConsumeRequest.run()<\/h4>\n<p>\u6bcf\u4e2a ConsumeRequest \u6700\u7ec8\u4f1a\u8c03\u7528\u7528\u6237\u5b9a\u4e49\u7684 MessageListener&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ ConsumeMessageConcurrentlyService.ConsumeRequest.run() (\u7b80\u5316)<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">run<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>processQueue<span class=\"token punctuation\">.<\/span><span class=\"token function\">isDropped<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u8be5\u961f\u5217\u5df2\u56e0 rebalance \u88ab\u79fb\u9664&#xff0c;\u4e0d\u5904\u7406<\/span><br \/>\n        <span class=\"token keyword\">return<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ 1. \u6821\u9a8c\u6d88\u606f<\/span><br \/>\n    <span class=\"token comment\">\/\/ 2. \u8c03\u7528\u7528\u6237 MessageListener.consumeMessage()<\/span><br \/>\n    <span class=\"token class-name\">ConsumeConcurrentlyStatus<\/span> status <span class=\"token operator\">&#061;<\/span> messageListener<span class=\"token punctuation\">.<\/span><span class=\"token function\">consumeMessage<\/span><span class=\"token punctuation\">(<\/span>msgs<span class=\"token punctuation\">,<\/span> context<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ 3. \u5904\u7406\u6d88\u8d39\u7ed3\u679c&#xff08;\u6210\u529f\/\u5931\u8d25\/\u91cd\u8bd5&#xff09;<\/span><br \/>\n    <span class=\"token function\">processConsumeResult<\/span><span class=\"token punctuation\">(<\/span>status<span class=\"token punctuation\">,<\/span> context<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ processConsumeResult \u4e2d\u66f4\u65b0 offset<\/span><br \/>\n<span class=\"token keyword\">private<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">processConsumeResult<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u8ba1\u7b97 ackIndex<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u5982\u679c\u5168\u90e8\u6210\u529f&#xff1a;\u66f4\u65b0 offset<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u5982\u679c\u90e8\u5206\u5931\u8d25&#xff1a;\u53d1\u9001\u56de Broker \u91cd\u8bd5<\/span><br \/>\n    <span class=\"token keyword\">long<\/span> offset <span class=\"token operator\">&#061;<\/span> consumeRequest<span class=\"token punctuation\">.<\/span><span class=\"token function\">getProcessQueue<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token punctuation\">.<\/span><span class=\"token function\">removeMessage<\/span><span class=\"token punctuation\">(<\/span>consumeRequest<span class=\"token punctuation\">.<\/span><span class=\"token function\">getMsgs<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>offset <span class=\"token operator\">&gt;&#061;<\/span> <span class=\"token number\">0<\/span> <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token operator\">!<\/span>consumeRequest<span class=\"token punctuation\">.<\/span><span class=\"token function\">getProcessQueue<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">isDropped<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>defaultMQPushConsumerImpl<span class=\"token punctuation\">.<\/span><span class=\"token function\">getOffsetStore<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n            <span class=\"token punctuation\">.<\/span><span class=\"token function\">updateOffset<\/span><span class=\"token punctuation\">(<\/span>messageQueue<span class=\"token punctuation\">,<\/span> offset<span class=\"token punctuation\">,<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>offset \u66f4\u65b0\u53ea\u53d1\u751f\u5728 processConsumeResult \u4e2d\u2014\u2014\u5728\u6240\u6709\u6d88\u606f\u5904\u7406\u5b8c\u6210\u4e4b\u540e\u3002\u5982\u679c consumeMessage(msgs, context) \u4e00\u76f4\u4e0d\u8fd4\u56de&#xff08;\u56e0\u4e3a\u540c\u6b65 DB \u5199\u5165\u6162&#xff09;&#xff0c;offset \u5c31\u4e0d\u4f1a\u66f4\u65b0&#xff0c;lag \u53ea\u589e\u4e0d\u51cf\u3002<\/p>\n<h4>\u6d88\u8d39\u8005\u7684\u4e1a\u52a1\u4ee3\u7801&#xff1a;\u540c\u6b65 DB \u5199\u5165<\/h4>\n<p>\u7ffb\u5230\u6d88\u8d39\u8005\u7684\u4e1a\u52a1\u4ee3\u7801&#xff0c;\u6839\u56e0\u6d6e\u51fa\u6c34\u9762&#xff1a;<\/p>\n<p><span class=\"token annotation punctuation\">&#064;Component<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">OrderMessageConsumer<\/span> <span class=\"token keyword\">implements<\/span> <span class=\"token class-name\">MessageListenerConcurrently<\/span> <span class=\"token punctuation\">{<\/span><\/p>\n<p>    <span class=\"token annotation punctuation\">&#064;Autowired<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">OrderService<\/span> orderService<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token annotation punctuation\">&#064;Override<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token class-name\">ConsumeConcurrentlyStatus<\/span> <span class=\"token function\">consumeMessage<\/span><span class=\"token punctuation\">(<\/span><br \/>\n        <span class=\"token class-name\">List<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token class-name\">MessageExt<\/span><span class=\"token punctuation\">&gt;<\/span><\/span> msgs<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">ConsumeConcurrentlyContext<\/span> ctx<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u4e00\u6761\u6d88\u606f\u4e00\u4e2a\u8ba2\u5355<\/span><br \/>\n        <span class=\"token class-name\">MessageExt<\/span> msg <span class=\"token operator\">&#061;<\/span> msgs<span class=\"token punctuation\">.<\/span><span class=\"token function\">get<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token class-name\">OrderDTO<\/span> order <span class=\"token operator\">&#061;<\/span> <span class=\"token constant\">JSON<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">parseObject<\/span><span class=\"token punctuation\">(<\/span><br \/>\n            <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">String<\/span><span class=\"token punctuation\">(<\/span>msg<span class=\"token punctuation\">.<\/span><span class=\"token function\">getBody<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">OrderDTO<\/span><span class=\"token punctuation\">.<\/span><span class=\"token keyword\">class<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u2605 \u540c\u6b65 DB \u5199\u5165 \u2014 \u9ad8\u5cf0\u671f\u5e73\u5747\u8017\u65f6 3s<\/span><br \/>\n        <span class=\"token comment\">\/\/ DB \u8fde\u63a5\u6c60 20 \u4e2a\u8fde\u63a5&#xff0c;\u9ad8\u5cf0\u671f\u5168\u90e8\u88ab\u5360\u6ee1<\/span><br \/>\n        orderService<span class=\"token punctuation\">.<\/span><span class=\"token function\">save<\/span><span class=\"token punctuation\">(<\/span>order<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token keyword\">return<\/span> <span class=\"token class-name\">ConsumeConcurrentlyStatus<\/span><span class=\"token punctuation\">.<\/span><span class=\"token constant\">CONSUME_SUCCESS<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u6d88\u8d39\u903b\u8f91\u672c\u8eab\u662f\u540c\u6b65 DB \u5199\u5165\u2014\u2014\u9ad8\u5cf0\u671f DB \u8fde\u63a5\u6c60 20 \u4e2a\u8fde\u63a5\u5168\u5fd9&#xff0c;\u4e00\u6b21 save() \u4ece\u6b63\u5e38 200ms \u6da8\u5230 3-5s\u3002<\/p>\n<p>20 \u7ebf\u7a0b * 5s\/msg &#061; 100 msg\/min \u6781\u9650\u541e\u5410&#xff0c;\u800c\u751f\u4ea7\u8005 TPS \u662f 500&#xff08;\u6bcf\u5206\u949f 30,000 \u6761&#xff09;\u2014\u2014\u541e\u5410\u5dee\u8ddd 300 \u500d&#xff0c;\u5806\u79ef\u4e0d\u5947\u602a\u3002<\/p>\n<h4>Rebalance \u6b7b\u4ea1\u87ba\u65cb<\/h4>\n<p>\u5f53\u6d88\u8d39\u8005\u7ebf\u7a0b\u5168\u90e8\u5361\u4f4f\u65f6&#xff0c;\u4f1a\u53d1\u751f\u4ec0\u4e48&#xff1f;<\/p>\n<p>RocketMQ \u6d88\u8d39\u8005\u7ec4\u7684\u961f\u5217\u5206\u914d\u4e0d\u662f\u9759\u6001\u7684\u3002\u5f53\u6d88\u8d39\u8005\u7ec4\u5185\u6210\u5458\u6216\u8d1f\u8f7d\u53d8\u5316\u65f6&#xff0c;RocketMQ \u4f1a\u91cd\u65b0\u5206\u914d\u6bcf\u4e2a\u6d88\u8d39\u8005\u8d1f\u8d23\u7684\u961f\u5217\u2014\u2014\u8fd9\u4e2a\u8fc7\u7a0b\u79f0\u4e3a rebalance&#xff08;\u91cd\u5e73\u8861&#xff09;\u3002<\/p>\n<p>\u6d88\u8d39\u8005\u6709\u4e00\u4e2a\u5b9a\u65f6\u4efb\u52a1 cleanExpireMsg&#xff0c;\u8fd0\u884c\u5728 ConsumeMessageConcurrentlyService \u7684 cleanExpireMsgExecutors \u4e2d&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ ConsumeMessageConcurrentlyService \u521d\u59cb\u5316\u65f6<\/span><br \/>\n<span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>cleanExpireMsgExecutors<span class=\"token punctuation\">.<\/span><span class=\"token function\">scheduleAtFixedRate<\/span><span class=\"token punctuation\">(<\/span><br \/>\n    <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">Runnable<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token annotation punctuation\">&#064;Override<\/span><br \/>\n        <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">run<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token function\">cleanExpireMsg<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>defaultMQPushConsumer<span class=\"token punctuation\">.<\/span><span class=\"token function\">getConsumeTimeout<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span>  <span class=\"token comment\">\/\/ \u9ed8\u8ba4 15 \u5206\u949f<\/span><br \/>\n    <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>defaultMQPushConsumer<span class=\"token punctuation\">.<\/span><span class=\"token function\">getConsumeTimeout<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span>  <span class=\"token comment\">\/\/ \u6bcf 15 \u5206\u949f\u6267\u884c\u4e00\u6b21<\/span><br \/>\n    <span class=\"token class-name\">TimeUnit<\/span><span class=\"token punctuation\">.<\/span><span class=\"token constant\">MINUTES<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>cleanExpireMsg() \u68c0\u67e5 ProcessQueue \u4e2d\u7684\u6d88\u606f\u662f\u5426\u5df2\u7ecf\u5f85\u4e86\u8d85\u8fc7 consumeTimeout \u65f6\u95f4\u3002\u5982\u679c\u662f&#xff0c;\u8fd9\u4e9b\u6d88\u606f\u88ab\u89c6\u4e3a&#034;\u6d88\u8d39\u8d85\u65f6&#034;&#xff0c;\u4f1a\u88ab\u6e05\u9664\u5e76\u5141\u8bb8\u91cd\u65b0\u6295\u9012\u3002<\/p>\n<p>\u4e0e\u6b64\u540c\u65f6&#xff0c;\u6d88\u8d39\u8005\u7684 offset \u4e00\u76f4\u4e0d\u52a8\u3002\u6d88\u8d39\u8005\u7684 MQClientInstance \u4e2d\u6709\u4e00\u4e2a RebalanceService \u5b9a\u65f6\u4efb\u52a1&#xff0c;\u9ed8\u8ba4\u6bcf 10 \u79d2\u8fd0\u884c\u4e00\u6b21&#xff0c;\u68c0\u67e5\u5f53\u524d consumer group \u7684\u961f\u5217\u5206\u914d\u662f\u5426\u5747\u8861\u3002\u5f53\u8be5\u6d88\u8d39\u8005\u6d88\u8d39\u8fdb\u5ea6\u957f\u671f\u5361\u4f4f&#xff0c;\u5176\u4ed6\u6d88\u8d39\u8005\u7684\u961f\u5217\u8d1f\u8f7d\u51fa\u73b0\u660e\u663e\u4e0d\u5747\u8861\u65f6\u2014\u2014\u4f8b\u5982\u65b0\u5206\u533a\u5206\u914d\u7ed9\u8be5\u6d88\u8d39\u8005\u540e\u8fdb\u5ea6\u4e5f\u4e0d\u52a8\u2014\u2014rebalance \u5c31\u4f1a\u88ab\u89e6\u53d1\u3002<\/p>\n<p>rebalance \u53d1\u751f\u65f6&#xff0c;\u8be5\u6d88\u8d39\u8005\u53ef\u80fd\u5931\u53bb\u90e8\u5206\u5206\u533a\u2014\u2014\u4f46\u8fd9\u4e9b\u5206\u533a\u88ab\u5206\u914d\u7ed9\u540c\u7ec4\u7684\u5176\u4ed6\u6d88\u8d39\u8005&#xff0c;\u800c\u5176\u4ed6\u6d88\u8d39\u8005\u4e5f\u8dd1\u7740\u540c\u6837\u7684\u540c\u6b65 DB \u903b\u8f91\u2014\u2014\u540c\u6837\u6162\u3002\u66f4\u7cdf\u7684\u662f&#xff0c;rebalance \u671f\u95f4\u6240\u6709\u6d89\u53ca\u5230\u7684\u5206\u533a\u90fd\u4f1a\u6682\u505c\u6d88\u8d39&#xff0c;\u5806\u79ef\u8fdb\u4e00\u6b65\u52a0\u5267\u3002<\/p>\n<p>\u8fd9\u4e2a\u6b63\u53cd\u9988\u5faa\u73af\u2014\u2014\u6211\u79f0\u5b83\u4e3a Rebalance \u6b7b\u4ea1\u87ba\u65cb\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260805012514-6a7290faae326.png\" alt=\"Rebalance \u6b7b\u4ea1\u87ba\u65cb\u5faa\u73af\u56fe\" \/><\/p>\n<h4>\u4e09\u7cfb\u7edf\u65f6\u95f4\u7ebf\u5bf9\u9f50<\/h4>\n<p>\u4e0b\u9762\u8fd9\u5f20\u8868\u6574\u7406\u4e86\u540c\u4e00\u65f6\u95f4\u7a97\u53e3\u5185\u4e09\u4e2a\u7cfb\u7edf\u7684\u72b6\u6001&#xff1a;<\/p>\n<table>\n<tr>\u65f6\u95f4\u751f\u4ea7\u7aefBroker\u6d88\u8d39\u7aef<\/tr>\n<tbody>\n<tr>\n<td>10:00<\/td>\n<td>send OK, avg 42ms<\/td>\n<td>PUT queue: 12<\/td>\n<td>activeCount&#061;15\/20, avg 800ms\/msg<\/td>\n<\/tr>\n<tr>\n<td>10:05<\/td>\n<td>send OK, avg 156ms<\/td>\n<td>PUT queue: 89<\/td>\n<td>activeCount&#061;20\/20, avg 3.2s\/msg<\/td>\n<\/tr>\n<tr>\n<td>10:10<\/td>\n<td>send OK, avg 482ms<\/td>\n<td>PUT queue: 378<\/td>\n<td>activeCount&#061;20\/20, ProcessQueue 1000<\/td>\n<\/tr>\n<tr>\n<td>10:15<\/td>\n<td>send OK, avg 1.2s<\/td>\n<td>PUT queue: 892<\/td>\n<td>Rebalance \u89e6\u53d1, \u5931\u53bb 2 \u5206\u533a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u65f6\u95f4\u5df2\u7edf\u4e00\u5230 UTC&#043;8\u3002\u53ef\u89c1\u6d88\u8d39\u7aef\u4ece 10:00 \u5c31\u5f00\u59cb\u53d8\u6162&#xff0c;\u4f46\u771f\u6b63\u7684\u5806\u79ef\u4ece 10:05 \u7ebf\u7a0b\u6c60\u5168\u6ee1\u624d\u5f00\u59cb\u7206\u70b8\u3002\u751f\u4ea7\u7aef\u548c Broker \u662f\u88ab\u6d88\u8d39\u7aef\u62d6\u6162\u7684\u2014\u2014\u5b83\u4eec\u662f\u53d7\u5bb3\u8005&#xff0c;\u4e0d\u662f\u6839\u56e0\u3002<\/p>\n<h3>\u3010\u8def\u5f84\u3011&#x1f50d; \u6392\u67e5\u8def\u5f84<\/h3>\n<p>\u4e0b\u6b21\u4f60\u9047\u5230\u6d88\u606f\u5806\u79ef\u65f6&#xff0c;\u4e0d\u7528\u53bb\u731c\u2014\u2014\u8d70\u8fd9\u6761\u8def\u5f84&#xff1a;<\/p>\n<p>\u6d88\u8d39 Lag \u589e\u957f&#xff1f;<br \/>\n\u251c\u2500\u2500 Yes \u2192 \u67e5\u6d88\u8d39\u8005\u7ebf\u7a0b\u6c60 activeCount<br \/>\n\u2502   \u251c\u2500\u2500 \u6ee1 \u2192 \u67e5 ConsumeRequest \u5904\u7406\u8017\u65f6<br \/>\n\u2502   \u2502   \u251c\u2500\u2500 \u6162&#xff08;&gt;1s\/msg&#xff09;\u2192 jstack \u770b\u6bcf\u4e2a\u7ebf\u7a0b\u5361\u5728\u54ea<br \/>\n\u2502   \u2502   \u2502   \u251c\u2500\u2500 DB\/IO \u963b\u585e \u2192 \u4e1a\u52a1\u4ee3\u7801\u6709\u540c\u6b65\u963b\u585e\u64cd\u4f5c&#xff08;\u6839\u56e0&#xff09;<br \/>\n\u2502   \u2502   \u2502   \u2514\u2500\u2500 \u8ba1\u7b97\u5bc6\u96c6 \u2192 \u6539 consumeThreadMax<br \/>\n\u2502   \u2502   \u2514\u2500\u2500 \u5feb \u2192 \u67e5 consumeExecutor \u961f\u5217\u5927\u5c0f \u2192 \u4efb\u52a1\u6392\u961f<br \/>\n\u2502   \u2514\u2500\u2500 \u4e0d\u6ee1 \u2192 \u67e5\u7f51\u7edc\u5c42&#xff08;telnet 10911&#xff09;<br \/>\n\u251c\u2500\u2500 No \u2192 \u67e5\u751f\u4ea7\u7aef send \u8017\u65f6<br \/>\n\u2502   \u251c\u2500\u2500 \u6162 \u2192 \u67e5 Broker \u8bf7\u6c42\u961f\u5217<br \/>\n\u2502   \u2514\u2500\u2500 \u6b63\u5e38 \u2192 \u67e5 NameServer \u8def\u7531<br \/>\n\u2514\u2500\u2500 \u6392\u9664\u9879&#xff1a;<br \/>\n    &#8211; \u7f51\u7edc\u5c42&#xff08;telnet &#043; ping&#xff09;<br \/>\n    &#8211; OS \u5c42&#xff08;CPU \u4f7f\u7528\u7387\u3001GC \u9891\u7387\u3001\u78c1\u76d8 IO&#xff09;<br \/>\n    &#8211; Broker \u5c42&#xff08;\u8bf7\u6c42\u961f\u5217\u3001Page Cache \u547d\u4e2d\u7387&#xff09;<\/p>\n<p>\u5148\u6392\u7f51\u7edc&#xff0c;\u518d\u67e5\u751f\u4ea7\u7aef&#xff0c;\u7136\u540e Broker&#xff0c;\u6700\u540e\u6d88\u8d39\u8005\u3002\u6bcf\u4e00\u6b65\u90fd\u6709\u786e\u5b9a\u7684\u6307\u6807\u53ef\u770b&#xff0c;\u4e0d\u662f\u9760\u731c\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260805012521-6a729101dfc21.png\" alt=\"\u6d88\u606f\u5806\u79ef\u6392\u67e5\u51b3\u7b56\u6811\" \/><\/p>\n<h4>\u6d88\u8d39\u7aef\u6392\u67e5\u547d\u4ee4<\/h4>\n<p><span class=\"token comment\"># 1. \u67e5\u770b\u6d88\u8d39\u8005\u7ebf\u7a0b\u5806\u6808<\/span><br \/>\njstack <span class=\"token operator\">&lt;<\/span>consumer_pid<span class=\"token operator\">&gt;<\/span> <span class=\"token operator\">|<\/span> <span class=\"token function\">grep<\/span> <span class=\"token parameter variable\">-E<\/span> <span class=\"token string\">&#034;ConsumeMessageThread|consumeExecutor&#034;<\/span> <span class=\"token parameter variable\">-A<\/span> <span class=\"token number\">20<\/span><\/p>\n<p><span class=\"token comment\"># 2. \u67e5\u770b\u6d88\u8d39 lag&#xff08;Admin CLI&#xff09;<\/span><br \/>\nmqadmin consumerProgress <span class=\"token parameter variable\">-g<\/span> <span class=\"token operator\">&lt;<\/span>consumerGroup<span class=\"token operator\">&gt;<\/span><\/p>\n<p><span class=\"token comment\"># 3. \u67e5\u770b\u6d88\u8d39\u8005\u7ebf\u7a0b\u6c60 JMX \u6307\u6807<\/span><br \/>\n<span class=\"token comment\"># \u8fde\u63a5 JMX<\/span><br \/>\njconsole <span class=\"token operator\">&lt;<\/span>host<span class=\"token operator\">&gt;<\/span>:<span class=\"token operator\">&lt;<\/span>port<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token comment\"># \u6216\u547d\u4ee4\u884c<\/span><br \/>\njmxterm <span class=\"token parameter variable\">-l<\/span> <span class=\"token operator\">&lt;<\/span>host<span class=\"token operator\">&gt;<\/span>:<span class=\"token operator\">&lt;<\/span>port<span class=\"token operator\">&gt;<\/span><br \/>\nbean <span class=\"token parameter variable\">-d<\/span> org.apache.rocketmq <span class=\"token parameter variable\">-n<\/span> org.apache.rocketmq:type<span class=\"token operator\">&#061;<\/span>ConsumerStats<br \/>\nget consumeTps<br \/>\nget consumeMsgThroughtputIn<\/p>\n<hr \/>\n<p>\u505c\u4e00\u4e0b&#xff0c;\u53bb\u4f60\u7684\u9879\u76ee\u91cc\u641c\u641c&#xff1a;<\/p>\n<p>$ <span class=\"token function\">grep<\/span> <span class=\"token parameter variable\">-r<\/span> <span class=\"token string\">&#039;implements MessageListenerConcurrently&#039;<\/span> src\/ <span class=\"token parameter variable\">&#8211;include<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;*.java&#039;<\/span><br \/>\n$ <span class=\"token function\">grep<\/span> <span class=\"token parameter variable\">-r<\/span> <span class=\"token string\">&#039;implements MessageListenerOrderly&#039;<\/span> src\/ <span class=\"token parameter variable\">&#8211;include<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;*.java&#039;<\/span><\/p>\n<p>\u770b\u770b\u6709\u591a\u5c11\u6d88\u8d39\u8005\u3002\u6253\u5f00\u6bcf\u4e2a consumeMessage \u65b9\u6cd5&#xff0c;\u770b\u770b\u91cc\u9762\u6709\u6ca1\u6709\u540c\u6b65\u963b\u585e\u8c03\u7528\u2014\u2014DB \u5199\u5165\u3001RPC \u8c03\u7528\u3001\u6587\u4ef6 IO\u3002<\/p>\n<p>\u4e5f\u8bb8\u4f60\u4f1a\u53d1\u73b0\u4e0d\u6b62\u4e00\u4e2a\u8fd9\u6837\u7684\u6d88\u8d39\u8005\u3002<\/p>\n<hr \/>\n<h3>\u3010\u6536\u655b\u3011\u6839\u56e0&#xff1a;\u540c\u6b65 DB \u5199\u5165 &#043; Rebalance \u6b7b\u4ea1\u87ba\u65cb<\/h3>\n<h4>\u6392\u9664\u5176\u4ed6\u53ef\u80fd\u539f\u56e0<\/h4>\n<table>\n<tr>\u6392\u9664\u9879\u68c0\u67e5\u65b9\u6cd5\u7ed3\u8bba<\/tr>\n<tbody>\n<tr>\n<td>Broker \u78c1\u76d8 IO<\/td>\n<td>iostat -x 1 \u67e5\u770b await &lt;5ms<\/td>\n<td>\u6b63\u5e38&#xff0c;\u6392\u9664<\/td>\n<\/tr>\n<tr>\n<td>OS \u5c42\u8d44\u6e90\u7ade\u4e89<\/td>\n<td>CPU 50%\u3001GC Young GC &lt;200ms\u3001Context Switch \u6b63\u5e38<\/td>\n<td>\u6b63\u5e38&#xff0c;\u6392\u9664<\/td>\n<\/tr>\n<tr>\n<td>\u7f51\u7edc\u95ee\u9898<\/td>\n<td>telnet \u8fde\u901a\u3001ping \u5ef6\u8fdf &lt;1ms\u3001\u65e0\u4e22\u5305<\/td>\n<td>\u6b63\u5e38&#xff0c;\u6392\u9664<\/td>\n<\/tr>\n<tr>\n<td>\u751f\u4ea7\u7aef\u6162<\/td>\n<td>send OK\u3001TPS \u7a33\u5b9a 500\/s<\/td>\n<td>\u6b63\u5e38&#xff0c;\u6392\u9664<\/td>\n<\/tr>\n<tr>\n<td>consumeTimeout \u8fc7\u77ed<\/td>\n<td>\u9ed8\u8ba4 15min&#xff0c;\u4f46\u5355\u6761\u5904\u7406 3s&#xff0c;\u8fdc\u4f4e\u4e8e\u9608\u503c<\/td>\n<td>\u672a\u89e6\u53d1\u8d85\u65f6\u6dd8\u6c70&#xff0c;\u4f46\u5c5e\u4e8e\u95f4\u63a5\u56e0\u7d20<\/td>\n<\/tr>\n<tr>\n<td>\u7ebf\u7a0b\u6c60\u592a\u5c0f<\/td>\n<td>20 \u7ebf\u7a0b \u00d7 5s &#061; 100 msg\/min&#xff0c;\u751f\u4ea7 30,000\/min<\/td>\n<td>\u5339\u914d\u95ee\u9898&#xff0c;\u4f46\u4e0d\u662f\u6839\u56e0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6839\u56e0&#xff1a;\u6d88\u8d39\u8005\u4e1a\u52a1\u4ee3\u7801\u4e2d\u5d4c\u4e86\u540c\u6b65 DB \u5199\u5165\u3002\u9ad8\u5cf0\u671f DB \u8fde\u63a5\u6c60\u5168\u5fd9&#xff0c;\u5355\u6761\u6d88\u606f\u5904\u7406\u4ece 200ms \u6da8\u5230 3-5s\u300220 \u4e2a\u6d88\u8d39\u7ebf\u7a0b\u5168\u6ee1&#xff0c;ProcessQueue \u62c9\u53d6\u6d41\u63a7&#xff0c;offset \u4e0d\u66f4\u65b0&#xff0c;\u89e6\u53d1 rebalance \u6b7b\u4ea1\u87ba\u65cb\u3002\u5806\u79ef\u4e0d\u662f\u7ed3\u679c&#xff0c;\u662f\u56e0\u679c\u94fe\u7684\u4e00\u73af\u2014\u2014\u5b83\u65e2\u662f\u539f\u56e0\u4e5f\u662f\u7ed3\u679c\u3002<\/p>\n<h4>\u4fee\u590d\u65b9\u6848<\/h4>\n<p>\u957f\u671f\u4fee\u590d&#xff1a;\u6d88\u8d39\u8005\u4e2d DB \u64cd\u4f5c\u6539\u4e3a\u5f02\u6b65<\/p>\n<p><span class=\"token annotation punctuation\">&#064;Override<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token class-name\">ConsumeConcurrentlyStatus<\/span> <span class=\"token function\">consumeMessage<\/span><span class=\"token punctuation\">(<\/span><br \/>\n    <span class=\"token class-name\">List<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token class-name\">MessageExt<\/span><span class=\"token punctuation\">&gt;<\/span><\/span> msgs<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">ConsumeConcurrentlyContext<\/span> ctx<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><\/p>\n<p>    <span class=\"token class-name\">MessageExt<\/span> msg <span class=\"token operator\">&#061;<\/span> msgs<span class=\"token punctuation\">.<\/span><span class=\"token function\">get<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token class-name\">OrderDTO<\/span> order <span class=\"token operator\">&#061;<\/span> <span class=\"token constant\">JSON<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">parseObject<\/span><span class=\"token punctuation\">(<\/span><br \/>\n        <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">String<\/span><span class=\"token punctuation\">(<\/span>msg<span class=\"token punctuation\">.<\/span><span class=\"token function\">getBody<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">OrderDTO<\/span><span class=\"token punctuation\">.<\/span><span class=\"token keyword\">class<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u2705 \u6539\u4e3a\u5f02\u6b65\u5199\u5165 MQ&#xff0c;\u7531\u72ec\u7acb\u6d88\u8d39\u8005\u5904\u7406 DB \u5199\u5165<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u6d88\u8d39\u7ebf\u7a0b\u4e0d\u518d\u963b\u585e<\/span><br \/>\n    orderSaveProducer<span class=\"token punctuation\">.<\/span><span class=\"token function\">send<\/span><span class=\"token punctuation\">(<\/span>order<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span>sendResult<span class=\"token punctuation\">,<\/span> err<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">-&gt;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>err <span class=\"token operator\">!&#061;<\/span> <span class=\"token keyword\">null<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            log<span class=\"token punctuation\">.<\/span><span class=\"token function\">error<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;order save async failed&#034;<\/span><span class=\"token punctuation\">,<\/span> err<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u7acb\u5373\u8fd4\u56de SUCCESS&#xff0c;\u4e0d\u7b49\u5f85 DB \u5b8c\u6210<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token class-name\">ConsumeConcurrentlyStatus<\/span><span class=\"token punctuation\">.<\/span><span class=\"token constant\">CONSUME_SUCCESS<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u6d88\u8d39\u7ebf\u7a0b\u53ea\u505a\u6d88\u606f\u683c\u5f0f\u8f6c\u6362 &#043; \u5f02\u6b65\u6295\u9012&#xff0c;\u4e0d\u518d\u76f4\u63a5\u64cd\u4f5c DB\u3002\u8fd9\u6837\u53ef\u4ee5\u5927\u5e45\u964d\u4f4e\u6d88\u8d39\u8017\u65f6&#xff0c;\u8ba9\u7ebf\u7a0b\u6c60\u4e0d\u518d\u963b\u585e\u3002<\/p>\n<p>\u8fd9\u4e0d\u662f&#034;\u7528 MQ \u89e3\u51b3 MQ \u95ee\u9898&#034;\u2014\u2014\u6d88\u8d39\u7ebf\u7a0b\u7684\u74f6\u9888\u662f\u540c\u6b65\u963b\u585e&#xff08;\u7b49 DB \u8fd4\u56de&#xff09;&#xff0c;\u66ff\u6362\u4e3a\u975e\u963b\u585e\u6295\u9012&#xff08;\u53d1\u5b8c\u7acb\u5373\u8fd4\u56de&#xff09;\u540e&#xff0c;\u6d88\u8d39\u7ebf\u7a0b\u4ece&#034;\u963b\u585e\u7b49\u5f85 IO&#034;\u53d8\u6210&#034;\u5185\u5b58\u7ea7\u7684\u6d88\u606f\u8def\u7531&#034;\u3002DB \u5199\u5165\u88ab\u89e3\u8026\u5230\u4e13\u95e8\u7684\u6d88\u8d39\u8005\u5904\u7406&#xff0c;\u72ec\u7acb\u6269\u7f29\u5bb9\u3002<\/p>\n<p>\u77ed\u671f\u6b62\u8840&#xff1a;<\/p>\n<table>\n<tr>\u914d\u7f6e\u4fee\u6539\u524d\u4fee\u6539\u540e\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>consumeThreadMax<\/td>\n<td>20<\/td>\n<td>40<\/td>\n<td>\u63d0\u5347\u5e76\u884c\u5ea6&#xff0c;\u4f46\u53ea\u6cbb\u6807<\/td>\n<\/tr>\n<tr>\n<td>consumeThreadMin<\/td>\n<td>20<\/td>\n<td>20<\/td>\n<td>\u4fdd\u6301\u4e0e max \u4e00\u81f4<\/td>\n<\/tr>\n<tr>\n<td>consumeMessageBatchMaxSize<\/td>\n<td>1<\/td>\n<td>10<\/td>\n<td>\u4e00\u6279\u5904\u7406\u591a\u6761&#xff08;\u9700\u8981\u6ce8\u610f\u4e1a\u52a1\u5e42\u7b49&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>consumeTimeout<\/td>\n<td>15 min<\/td>\n<td>30 min<\/td>\n<td>\u7ed9\u6162\u64cd\u4f5c\u66f4\u591a\u7f13\u51b2&#xff0c;\u9632\u6b62 cleanExpireMsg \u8fc7\u65e9\u52a8\u4f5c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u9a8c\u8bc1\u4fee\u590d<\/h4>\n<p>\u4fee\u6539\u540e\u89c2\u5bdf 10 \u5206\u949f&#xff1a;<\/p>\n<ul>\n<li>\u6d88\u8d39\u7aef lag \u662f\u5426\u5f00\u59cb\u4e0b\u964d&#xff08;Grafana \u9762\u677f&#xff09;<\/li>\n<li>\u6d88\u8d39\u8005\u7ebf\u7a0b\u6c60 activeCount \u662f\u5426\u4f4e\u4e8e 20<\/li>\n<li>\u63a5\u53e3\u7aef\u5230\u7aef\u8017\u65f6\u662f\u5426\u4ece 5s \u964d\u56de 200ms<\/li>\n<\/ul>\n<h3>\u3010\u6807\u8bb0\u3011&#x1f4e1; \u544a\u8b66\u8bbe\u7f6e<\/h3>\n<h4>\u76d1\u63a7\u9879<\/h4>\n<p>\u5728 Grafana\/RocketMQ Dashboard \u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u544a\u8b66\u2014\u2014\u8bbe\u4e86\u5c31\u4e0d\u7528\u7b49\u4eba\u62a5&#xff1a;<\/p>\n<table>\n<tr>\u544a\u8b66\u9879\u6307\u6807\u9608\u503c\u7ea7\u522b<\/tr>\n<tbody>\n<tr>\n<td>\u6d88\u8d39 Lag \u6301\u7eed\u589e\u957f<\/td>\n<td>consumerLag<\/td>\n<td>&gt;10,000 \u6301\u7eed 5 \u5206\u949f<\/td>\n<td>P0<\/td>\n<\/tr>\n<tr>\n<td>Rebalance \u9891\u7e41<\/td>\n<td>rebalanceTimes<\/td>\n<td>&gt;5 \u6b21\/\u5206\u949f<\/td>\n<td>P1<\/td>\n<\/tr>\n<tr>\n<td>\u6d88\u8d39\u8005\u7ebf\u7a0b\u6c60\u6ee1<\/td>\n<td>activeCount<\/td>\n<td>&#061; consumeThreadMax \u6301\u7eed 30s<\/td>\n<td>P1<\/td>\n<\/tr>\n<tr>\n<td>\u6d88\u8d39\u5904\u7406\u8017\u65f6\u8fc7\u957f<\/td>\n<td>consumeAvgTime<\/td>\n<td>&gt;1s \u6301\u7eed 5 \u5206\u949f<\/td>\n<td>P2<\/td>\n<\/tr>\n<tr>\n<td>ProcessQueue \u5806\u79ef<\/td>\n<td>processQueueSize<\/td>\n<td>&gt;500<\/td>\n<td>P2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u914d\u7f6e\u68c0\u67e5\u6e05\u5355<\/h4>\n<p>\u25a1 consumeTimeout \u2265 \u671f\u671b\u6700\u5927\u5904\u7406\u65f6\u95f4\u7684 <span class=\"token number\">2<\/span> \u500d&#xff08;\u9ed8\u8ba4 15min&#xff09;<br \/>\n\u25a1 consumeThreadMin\/consumeThreadMax \u6839\u636e\u5206\u533a\u6570 \u00d7 <span class=\"token number\">2<\/span> \u4f30\u7b97<br \/>\n\u25a1 consumeMessageBatchMaxSize \u8bbe\u4e3a <span class=\"token operator\">&gt;<\/span><span class=\"token number\">1<\/span>&#xff08;\u9700\u4e1a\u52a1\u5e42\u7b49&#xff09;<br \/>\n\u25a1 \u7f51\u7edc\u5c42\u544a\u8b66&#xff08;telnet &#043; ping&#xff09;\u4e0e\u4e2d\u95f4\u4ef6\u544a\u8b66\u540c\u65f6\u90e8\u7f72<\/p>\n<h4>&#x1f511; \u6392\u67e5\u5fc3\u6cd5<\/h4>\n<p>\u6d88\u606f\u5806\u79ef\u50cf\u53d1\u70e7\u2014\u2014\u4f53\u6e29\u4e0d\u662f\u75c5&#xff0c;\u662f\u75c7\u72b6\u3002\u6392\u67e5\u5806\u79ef\u4e0d\u662f\u770b\u5806\u79ef\u672c\u8eab&#xff0c;\u662f\u770b\u6d88\u8d39\u8005\u7684\u7ebf\u7a0b\u6a21\u578b\u3002<\/p>\n<p>\u6392\u67e5\u6d88\u606f\u5806\u79ef\u7684\u4e09\u4e2a\u5fc3\u6cd5&#xff1a;<br \/>\n<span class=\"token number\">1<\/span>. \u5148\u770b\u7ebf\u7a0b\u6c60&#xff0c;\u518d\u770b Lag\u2014\u2014\u7ebf\u7a0b\u6c60\u7528\u5b8c\u662f\u75c5\u6839&#xff0c;Lag \u662f\u75c7\u72b6<br \/>\n<span class=\"token number\">2<\/span>. \u5148\u6392\u7f51\u7edc&#xff0c;\u518d\u6392\u4e1a\u52a1\u2014\u2014\u7f51\u7edc\u4e0d\u901a\u8c03\u534a\u5929\u914d\u7f6e\u662f\u6d6a\u8d39\u751f\u547d<br \/>\n<span class=\"token number\">3<\/span>. \u5148\u770b\u6d88\u8d39\u8005&#xff0c;\u518d\u6000\u7591\u751f\u4ea7\u8005\u2014\u2014\u5806\u79ef <span class=\"token number\">90<\/span>% \u5728\u6d88\u8d39\u7aef<\/p>\n<p>\u4e0b\u7bc7\u6211\u4eec\u804a\u987a\u5e8f\u6d88\u8d39\u961f\u5217\u53d8\u66f4\u5bfc\u81f4\u6d88\u606f\u4e71\u5e8f\u5206\u6790\u2014\u2014\u5f53\u4f60\u6362\u6210\u987a\u5e8f\u6d88\u8d39\u65f6&#xff0c;\u65b0\u7684\u5751\u53c8\u6765\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u573a\u666f&#xff1a;\u4e1a\u52a1\u7aef\u5230\u7aef\u8017\u65f6\u4ece 200ms \u6da8\u5230 5s&#xff0c;\u6d88\u606f\u5806\u79ef 50 \u4e07\u6761\u3002\u4e1a\u52a1\u65b9\u6000\u7591\u751f\u4ea7\u8005\u6162&#xff0c;\u94fe\u8def\u8ffd\u8e2a\u53d1\u73b0\u6d88\u8d39\u7aef\u624d\u662f\u6839\u56e0\u2014\u201420 \u4e2a\u6d88\u8d39\u8005\u7ebf\u7a0b\u5168\u90e8\u5361\u5728\u540c\u6b65 DB \u5199\u5165\u4e0a&#xff0c;\u5f62\u6210 rebalance \u6b7b\u4ea1\u87ba\u65cb \u8def\u5f84&#xff1a;\u6d88\u8d39 lag \u76d1\u63a7 \u2192 \u6d88\u8d39\u8005\u7ebf\u7a0b\u6c60 \u2192 \u6d88\u8d39\u8005\u6e90\u7801 \u2192 \u4e1a\u52a1\u4ee3\u7801 \u2192 \u4fee\u590d\u65b9\u6848\u4e0a\u7bc7\u8bb2\u4e86 10909 VIP \u7aef\u53e3\u963b\u585e\u5bfc\u81f4 RocketMQ \u6d88\u606f\u53d1\u9001\u7aef\u5927\u91cf\u8d85\u65f6&#xff0c;\u8fd9\u6b21\u6211\u4eec\u6765\u770b\u6d88\u8d39\u7aef\u6700\u7ecf\u5178\u7684<\/p>\n","protected":false},"author":2,"featured_media":90428,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9098,3294],"topic":[],"class_list":["post-90436","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-it","tag-rocketmq"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>RocketMQ \u6d88\u606f\u5806\u79ef\u600e\u4e48\u529e\uff1f\u7ebf\u7a0b\u6c60\u7528\u5b8c\u624d\u662f\u75c5\u6839 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/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.wsisp.com\/helps\/90436.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"RocketMQ \u6d88\u606f\u5806\u79ef\u600e\u4e48\u529e\uff1f\u7ebf\u7a0b\u6c60\u7528\u5b8c\u624d\u662f\u75c5\u6839 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u573a\u666f&#xff1a;\u4e1a\u52a1\u7aef\u5230\u7aef\u8017\u65f6\u4ece 200ms \u6da8\u5230 5s&#xff0c;\u6d88\u606f\u5806\u79ef 50 \u4e07\u6761\u3002\u4e1a\u52a1\u65b9\u6000\u7591\u751f\u4ea7\u8005\u6162&#xff0c;\u94fe\u8def\u8ffd\u8e2a\u53d1\u73b0\u6d88\u8d39\u7aef\u624d\u662f\u6839\u56e0\u2014\u201420 \u4e2a\u6d88\u8d39\u8005\u7ebf\u7a0b\u5168\u90e8\u5361\u5728\u540c\u6b65 DB \u5199\u5165\u4e0a&#xff0c;\u5f62\u6210 rebalance \u6b7b\u4ea1\u87ba\u65cb \u8def\u5f84&#xff1a;\u6d88\u8d39 lag \u76d1\u63a7 \u2192 \u6d88\u8d39\u8005\u7ebf\u7a0b\u6c60 \u2192 \u6d88\u8d39\u8005\u6e90\u7801 \u2192 \u4e1a\u52a1\u4ee3\u7801 \u2192 \u4fee\u590d\u65b9\u6848\u4e0a\u7bc7\u8bb2\u4e86 10909 VIP \u7aef\u53e3\u963b\u585e\u5bfc\u81f4 RocketMQ \u6d88\u606f\u53d1\u9001\u7aef\u5927\u91cf\u8d85\u65f6&#xff0c;\u8fd9\u6b21\u6211\u4eec\u6765\u770b\u6d88\u8d39\u7aef\u6700\u7ecf\u5178\u7684\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/90436.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-05T01:25:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260805012447-6a7290df96064.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/90436.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/90436.html\",\"name\":\"RocketMQ \u6d88\u606f\u5806\u79ef\u600e\u4e48\u529e\uff1f\u7ebf\u7a0b\u6c60\u7528\u5b8c\u624d\u662f\u75c5\u6839 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-05T01:25:28+00:00\",\"dateModified\":\"2026-08-05T01:25:28+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/90436.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/90436.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/90436.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"RocketMQ \u6d88\u606f\u5806\u79ef\u600e\u4e48\u529e\uff1f\u7ebf\u7a0b\u6c60\u7528\u5b8c\u624d\u662f\u75c5\u6839\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"RocketMQ \u6d88\u606f\u5806\u79ef\u600e\u4e48\u529e\uff1f\u7ebf\u7a0b\u6c60\u7528\u5b8c\u624d\u662f\u75c5\u6839 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","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.wsisp.com\/helps\/90436.html","og_locale":"zh_CN","og_type":"article","og_title":"RocketMQ \u6d88\u606f\u5806\u79ef\u600e\u4e48\u529e\uff1f\u7ebf\u7a0b\u6c60\u7528\u5b8c\u624d\u662f\u75c5\u6839 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u573a\u666f&#xff1a;\u4e1a\u52a1\u7aef\u5230\u7aef\u8017\u65f6\u4ece 200ms \u6da8\u5230 5s&#xff0c;\u6d88\u606f\u5806\u79ef 50 \u4e07\u6761\u3002\u4e1a\u52a1\u65b9\u6000\u7591\u751f\u4ea7\u8005\u6162&#xff0c;\u94fe\u8def\u8ffd\u8e2a\u53d1\u73b0\u6d88\u8d39\u7aef\u624d\u662f\u6839\u56e0\u2014\u201420 \u4e2a\u6d88\u8d39\u8005\u7ebf\u7a0b\u5168\u90e8\u5361\u5728\u540c\u6b65 DB \u5199\u5165\u4e0a&#xff0c;\u5f62\u6210 rebalance \u6b7b\u4ea1\u87ba\u65cb \u8def\u5f84&#xff1a;\u6d88\u8d39 lag \u76d1\u63a7 \u2192 \u6d88\u8d39\u8005\u7ebf\u7a0b\u6c60 \u2192 \u6d88\u8d39\u8005\u6e90\u7801 \u2192 \u4e1a\u52a1\u4ee3\u7801 \u2192 \u4fee\u590d\u65b9\u6848\u4e0a\u7bc7\u8bb2\u4e86 10909 VIP \u7aef\u53e3\u963b\u585e\u5bfc\u81f4 RocketMQ \u6d88\u606f\u53d1\u9001\u7aef\u5927\u91cf\u8d85\u65f6&#xff0c;\u8fd9\u6b21\u6211\u4eec\u6765\u770b\u6d88\u8d39\u7aef\u6700\u7ecf\u5178\u7684","og_url":"https:\/\/www.wsisp.com\/helps\/90436.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-05T01:25:28+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260805012447-6a7290df96064.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/90436.html","url":"https:\/\/www.wsisp.com\/helps\/90436.html","name":"RocketMQ \u6d88\u606f\u5806\u79ef\u600e\u4e48\u529e\uff1f\u7ebf\u7a0b\u6c60\u7528\u5b8c\u624d\u662f\u75c5\u6839 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-05T01:25:28+00:00","dateModified":"2026-08-05T01:25:28+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/90436.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/90436.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/90436.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"RocketMQ \u6d88\u606f\u5806\u79ef\u600e\u4e48\u529e\uff1f\u7ebf\u7a0b\u6c60\u7528\u5b8c\u624d\u662f\u75c5\u6839"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/90436","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=90436"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/90436\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/90428"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=90436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=90436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=90436"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=90436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}