{"id":100270,"date":"2026-09-04T11:32:51","date_gmt":"2026-09-04T03:32:51","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/100270.html"},"modified":"2026-09-04T11:32:51","modified_gmt":"2026-09-04T03:32:51","slug":"%e7%ba%bf%e7%a8%8b%e6%b1%a0%e5%8f%82%e6%95%b0%e5%88%b0%e5%ba%95%e6%80%8e%e4%b9%88%e7%ae%97%ef%bc%88%e9%99%84%e7%9c%9f%e5%ae%9e-qps-%e6%bc%94%e7%ae%97%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/100270.html","title":{"rendered":"\u7ebf\u7a0b\u6c60\u53c2\u6570\u5230\u5e95\u600e\u4e48\u7b97\uff08\u9644\u771f\u5b9e QPS \u6f14\u7b97\uff09"},"content":{"rendered":"<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\u7ebf\u7a0b\u6c60\u53c2\u6570\u5230\u5e95\u600e\u4e48\u7b97\uff08\u9644\u771f\u5b9e QPS \u6f14\u7b97\uff09\" height=\"630\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260904033250-6a9a3be23963e.png\" width=\"1200\" \/><\/p>\n<p>\u4e00\u53e5\u8bdd\u53cd\u76f4\u89c9\u7ed3\u8bba&#xff1a;CPU \u6838\u6570 &#043; 1\u00a0\u8fd9\u4e2a\u7ebf\u7a0b\u6c60\u53c2\u6570\u516c\u5f0f&#xff0c;\u5728 IO \u5bc6\u96c6\u578b\u573a\u666f\u4e0b&#xff0c;\u4f1a\u8ba9\u4f60\u7684 order-service \u541e\u5410\u91cf\u76f4\u63a5\u8170\u65a9&#xff1b;\u800c\u771f\u6b63\u8be5\u7b97\u7684&#xff0c;\u4e0d\u662f\u201c\u7ebf\u7a0b\u6570\u201d&#xff0c;\u662f\u201c\u6392\u961f\u65f6\u95f4\u201d\u548c\u201c\u62d2\u7edd\u7387\u201d\u7684\u6570\u5b66\u671f\u671b\u3002<\/p>\n<p>\u627f\u63a5\u4e0a\u4e00\u7bc7\u300aAI Agent \u4e0e Function Calling\u300b\u4e2d\u63d0\u5230\u7684\u201c\u5f02\u6b65\u4efb\u52a1\u7f16\u6392\u201d&#xff0c;\u672c\u6587\u4e0d\u518d\u79d1\u666e\u7ebf\u7a0b\u6c60\u57fa\u7840 API&#xff0c;\u800c\u662f\u805a\u7126\u53c2\u6570\u6f14\u7b97\u7684\u5b8c\u6574\u95ed\u73af&#xff1a;\u4ece\u6e90\u7801\u63a8\u5bfc\u00a0execute()\u00a0\u7684\u6267\u884c\u8def\u5f84&#xff0c;\u5230\u57fa\u4e8e\u771f\u5b9e QPS \u7684\u5bb9\u91cf\u89c4\u5212&#xff0c;\u518d\u5230\u538b\u6d4b\u6570\u636e\u9a8c\u8bc1&#xff0c;\u6700\u540e\u7ed9\u51fa\u53cd\u76f4\u89c9\u7684\u201c\u4ec0\u4e48\u65f6\u5019\u522b\u7528\u7ebf\u7a0b\u6c60\u201d\u6e05\u5355\u3002<\/p>\n<p>\u672c\u6587\u805a\u7126&#xff1a;\u53c2\u6570\u8ba1\u7b97\u7684\u6570\u5b66\u6a21\u578b &#043; \u6e90\u7801\u7ea7\u6267\u884c\u8def\u5f84 &#043; \u771f\u5b9e\u538b\u6d4b\u5bf9\u6bd4\u3002\u4e0d\u5c55\u5f00&#xff1a;AQS \u539f\u7406\u3001ThreadPoolExecutor \u7684\u62d2\u7edd\u7b56\u7565\u6e90\u7801\u9010\u884c\u6ce8\u91ca\u3001JDK 21 \u865a\u62df\u7ebf\u7a0b\u7684\u5e95\u5c42\u5b9e\u73b0\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u5148\u4ece\u4e00\u6b21 P0 \u4e8b\u6545\u8bf4\u8d77&#xff1a;\u7ebf\u7a0b\u6c60\u53c2\u6570\u4e0d\u662f\u201c\u914d\u51fa\u6765\u201d\u7684&#xff0c;\u662f\u201c\u7b97\u51fa\u6765\u201d\u7684<\/h3>\n<p>\u67d0\u5929\u51cc\u6668 2:00&#xff0c;order-service \u7684\u8ba2\u5355\u67e5\u8be2\u63a5\u53e3 RT \u4ece 80ms \u98d9\u5347\u5230 8s&#xff0c;\u6570\u636e\u5e93 CPU 100%&#xff0c;\u4f46\u7ebf\u7a0b\u6c60\u76d1\u63a7\u663e\u793a&#xff1a;\u6838\u5fc3\u7ebf\u7a0b 50&#xff0c;\u6700\u5927\u7ebf\u7a0b 200&#xff0c;\u6d3b\u8dc3\u7ebf\u7a0b\u4ec5 30\u3002\u770b\u8d77\u6765\u8d44\u6e90\u5145\u8db3&#xff0c;\u4e3a\u4ec0\u4e48\u63a5\u53e3\u4f1a\u96ea\u5d29&#xff1f;<\/p>\n<p>\u6392\u67e5\u53d1\u73b0&#xff1a;\u6838\u5fc3\u7ebf\u7a0b 50 \u5168\u90e8\u963b\u585e\u5728\u5916\u90e8\u4f1a\u5458\u670d\u52a1\u8c03\u7528\u4e0a&#xff08;\u5e73\u5747\u8017\u65f6 2s&#xff09;&#xff0c;\u800c\u6700\u5927\u7ebf\u7a0b 200 \u7684\u6269\u5bb9\u6761\u4ef6\u2014\u2014workQueue.size() &gt; 1000\u2014\u2014\u6c38\u8fdc\u8fbe\u4e0d\u5230&#xff0c;\u56e0\u4e3a\u961f\u5217\u5bb9\u91cf\u662f\u00a0LinkedBlockingQueue(10000)\u3002\u8bf7\u6c42\u5168\u90e8\u5806\u79ef\u5728\u961f\u5217\u91cc&#xff0c;\u524d\u7aef\u8d85\u65f6\u91cd\u8bd5&#xff0c;\u91cd\u8bd5\u6d41\u91cf\u53c8\u6253\u6ee1 Tomcat \u7ebf\u7a0b&#xff0c;\u6700\u7ec8\u62d6\u57ae\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u3002<\/p>\n<p>\u6839\u56e0\u4e0d\u662f\u7ebf\u7a0b\u6570\u592a\u5c11&#xff0c;\u800c\u662f\u961f\u5217\u5bb9\u91cf\u548c\u6700\u5927\u7ebf\u7a0b\u7684\u89e6\u53d1\u6761\u4ef6\u8bbe\u8ba1\u9519\u8bef\u3002\u00a0ThreadPoolExecutor\u00a0\u7684\u6269\u5bb9\u903b\u8f91\u51b3\u5b9a\u4e86&#xff1a;\u53ea\u6709\u961f\u5217\u6ee1\u4e86\u624d\u4f1a\u521b\u5efa\u975e\u6838\u5fc3\u7ebf\u7a0b\u3002\u4f60\u914d\u7684\u00a0maximumPoolSize&#061;200\u00a0\u5728\u961f\u5217\u5bb9\u91cf 10000 \u9762\u524d&#xff0c;\u5c31\u662f\u5e9f\u7eb8\u4e00\u5f20\u3002<\/p>\n<h4>1.1 \u6e90\u7801\u7ea7\u9a8c\u8bc1&#xff1a;\u7ebf\u7a0b\u6c60\u7684\u201c\u5047\u6269\u5bb9\u201d\u9677\u9631<\/h4>\n<p>\u770b\u00a0ThreadPoolExecutor.execute()\u00a0\u7684\u6838\u5fc3\u903b\u8f91&#xff08;JDK 17&#xff09;&#xff1a;<\/p>\n<p>public void execute(Runnable command) {<br \/>\n    int c &#061; ctl.get();<br \/>\n    \/\/ 1. \u7ebf\u7a0b\u6570 &lt; corePoolSize&#xff1a;\u76f4\u63a5\u521b\u5efa\u6838\u5fc3\u7ebf\u7a0b<br \/>\n    if (workerCountOf(c) &lt; corePoolSize) {<br \/>\n        if (addWorker(command, true))<br \/>\n            return;<br \/>\n        c &#061; ctl.get();<br \/>\n    }<br \/>\n    \/\/ 2. \u6838\u5fc3\u7ebf\u7a0b\u5df2\u6ee1&#xff1a;\u5148\u5165\u961f&#xff0c;\u800c\u4e0d\u662f\u5efa\u65b0\u7ebf\u7a0b&#xff01;<br \/>\n    if (isRunning(c) &amp;&amp; workQueue.offer(command)) {<br \/>\n        int recheck &#061; ctl.get();<br \/>\n        if (! isRunning(recheck) &amp;&amp; remove(command))<br \/>\n            reject(command);<br \/>\n        else if (workerCountOf(recheck) &#061;&#061; 0)<br \/>\n            addWorker(null, false);<br \/>\n    }<br \/>\n    \/\/ 3. \u961f\u5217\u6ee1\u4e86&#xff1a;\u624d\u5c1d\u8bd5\u521b\u5efa\u975e\u6838\u5fc3\u7ebf\u7a0b<br \/>\n    else if (!addWorker(command, false))<br \/>\n        reject(command);  \/\/ \u961f\u5217\u6ee1 &#043; \u7ebf\u7a0b\u6570\u8fbe maximumPoolSize \u624d\u62d2\u7edd<br \/>\n}<\/p>\n<p>\u5173\u952e\u70b9&#xff1a;\u6b65\u9aa4 2 \u7684\u00a0workQueue.offer()\u00a0\u662f\u65e0\u754c\u961f\u5217\u65f6\u6c38\u8fdc\u8fd4\u56de\u00a0true&#xff0c;\u6b65\u9aa4 3 \u6c38\u8fdc\u4e0d\u4f1a\u6267\u884c\u3002\u4f60\u914d\u7684\u00a0maximumPoolSize\u00a0\u5f62\u540c\u865a\u8bbe\u3002<\/p>\n<p>\u6240\u4ee5&#xff0c;\u53c2\u6570\u8ba1\u7b97\u7684\u8d77\u70b9\u4e0d\u662f\u201c\u591a\u5c11\u7ebf\u7a0b\u201d&#xff0c;\u800c\u662f\u201c\u961f\u5217\u6709\u591a\u957f\u201d\u3002\u961f\u5217\u957f\u5ea6\u76f4\u63a5\u51b3\u5b9a\u4e86\u8bf7\u6c42\u7684\u6700\u5927\u7b49\u5f85\u65f6\u95f4&#xff0c;\u800c\u7b49\u5f85\u65f6\u95f4\u76f4\u63a5\u51b3\u5b9a\u4e86\u63a5\u53e3\u7684 SLA \u80fd\u5426\u8fbe\u6210\u3002<\/p>\n<hr \/>\n<h3>\u4e8c\u3001\u771f\u5b9e QPS \u6f14\u7b97&#xff1a;\u4ece\u4e1a\u52a1\u6307\u6807\u5012\u63a8\u7ebf\u7a0b\u6c60\u53c2\u6570<\/h3>\n<p>\u73b0\u5728\u8fdb\u5165\u6b63\u9898\u3002\u5047\u8bbe order-service \u6709\u4e00\u4e2a\u6838\u5fc3\u63a5\u53e3&#xff1a;\u521b\u5efa\u8ba2\u5355\u3002\u6211\u4eec\u9700\u8981\u4e3a\u5b83\u5355\u72ec\u914d\u7f6e\u4e00\u4e2a\u7ebf\u7a0b\u6c60&#xff08;\u7edd\u4e0d\u5171\u7528\u9ed8\u8ba4\u7684\u00a0commonPool&#xff09;\u3002<\/p>\n<h4>2.1 \u7b2c\u4e00\u6b65&#xff1a;\u660e\u786e\u786c\u6027\u6307\u6807<\/h4>\n<table>\n<tbody>\n<tr>\u6307\u6807\u503c\u6765\u6e90<\/tr>\n<tr>\n<td>\u76ee\u6807 QPS<\/td>\n<td>500<\/td>\n<td>\u4e1a\u52a1\u65b9\u627f\u8bfa\u7684\u5cf0\u503c\u6d41\u91cf<\/td>\n<\/tr>\n<tr>\n<td>\u63a5\u53e3 RT \u7684 TP99<\/td>\n<td>\u2264 300ms<\/td>\n<td>SLA \u5408\u540c<\/td>\n<\/tr>\n<tr>\n<td>RT \u7684 TP999<\/td>\n<td>\u2264 500ms<\/td>\n<td>\u5185\u90e8\u7ea2\u7ebf<\/td>\n<\/tr>\n<tr>\n<td>\u4efb\u52a1\u6784\u6210<\/td>\n<td>30% CPU \u8ba1\u7b97&#xff08;JSON \u5e8f\u5217\u5316&#043;\u6821\u9a8c&#xff09;&#xff0c;70% IO&#xff08;DB \u5199\u5165 &#043; Redis \u7f13\u5b58 &#043; MQ \u53d1\u9001&#xff09;<\/td>\n<td>\u94fe\u8def\u8ffd\u8e2a\u6570\u636e<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6ce8\u610f\u4e00\u4e2a\u5e38\u89c1\u8bef\u533a&#xff1a;\u5f88\u591a\u4eba\u7528\u201cIO \u5bc6\u96c6\u578b &#061; 2 * CPU \u6838\u6570\u201d\u6765\u7b97\u3002\u8fd9\u4e2a\u516c\u5f0f\u7684\u524d\u63d0\u662f\u7eaf IO&#xff0c;\u4f46\u5b9e\u9645\u4efb\u52a1\u91cc\u603b\u6709 CPU \u7247\u6bb5\u3002\u51c6\u786e\u7684\u505a\u6cd5\u662f\u6309\u4efb\u52a1\u7684 CPU \u5360\u6bd4\u505a\u52a0\u6743\u3002<\/p>\n<h4>2.2 \u7b2c\u4e8c\u6b65&#xff1a;\u8ba1\u7b97\u5355\u7ebf\u7a0b\u7684\u7406\u8bba\u541e\u5410\u4e0a\u9650<\/h4>\n<p>\u5148\u770b\u5355\u6b21\u4efb\u52a1\u7684\u5e73\u5747\u8017\u65f6\u3002\u6839\u636e\u94fe\u8def\u8ffd\u8e2a&#xff0c;\u4e00\u6b21\u521b\u5efa\u8ba2\u5355\u7684\u8017\u65f6\u5206\u89e3&#xff1a;<\/p>\n<ul>\n<li>CPU \u7247\u6bb5&#xff1a;15ms&#xff08;\u5e8f\u5217\u5316\u8ba2\u5355\u5bf9\u8c61 &#043; \u53c2\u6570\u6821\u9a8c &#043; \u7b7e\u540d\u8ba1\u7b97&#xff09;<\/li>\n<li>IO \u7247\u6bb5&#xff1a;65ms&#xff08;DB \u63d2\u5165 30ms &#043; Redis \u5199\u7f13\u5b58 10ms &#043; MQ \u53d1\u9001 25ms&#xff09;<\/li>\n<li>\u603b\u8017\u65f6&#xff1a;80ms<\/li>\n<\/ul>\n<p>\u5173\u952e\u5047\u8bbe&#xff1a;IO \u7b49\u5f85\u671f\u95f4&#xff0c;\u7ebf\u7a0b\u4f1a\u91ca\u653e CPU&#xff0c;\u6240\u4ee5\u5355\u7ebf\u7a0b\u7684\u541e\u5410\u7387\u4e0d\u662f\u00a01000\/80 &#061; 12.5 TPS&#xff0c;\u800c\u662f\u53d6\u51b3\u4e8e CPU \u7247\u6bb5\u7684\u5360\u6bd4\u3002<\/p>\n<p>\u5355\u7ebf\u7a0b\u6bcf\u79d2\u80fd\u5904\u7406\u7684\u8bf7\u6c42\u6570 \u2248\u00a01000ms \/ CPU\u7247\u6bb5\u8017\u65f6 &#061; 1000 \/ 15 \u2248 66.7 TPS&#xff08;\u524d\u63d0\u662f IO \u4e0d\u6210\u4e3a\u74f6\u9888&#xff0c;\u4e14 CPU \u6838\u6570\u5145\u8db3&#xff09;\u3002<\/p>\n<h4>2.3 \u7b2c\u4e09\u6b65&#xff1a;\u7528 Little&#039;s Law \u53cd\u63a8\u7ebf\u7a0b\u6570<\/h4>\n<p>Little&#039;s Law&#xff1a;L &#061; \u03bb * W&#xff0c;\u5373\u7cfb\u7edf\u4e2d\u5e73\u5747\u4efb\u52a1\u6570 &#061; \u5230\u8fbe\u7387 \u00d7 \u5e73\u5747\u505c\u7559\u65f6\u95f4\u3002<\/p>\n<ul>\n<li>\u76ee\u6807 QPS&#xff08;\u03bb&#xff09;&#061; 500<\/li>\n<li>\u671f\u671b\u7684\u7aef\u5230\u7aef\u8017\u65f6&#xff08;W&#xff09;&#061; 300ms &#061; 0.3s&#xff08;TP99 \u76ee\u6807&#xff09;<\/li>\n<li>\u9700\u8981\u7684\u5e76\u53d1\u4efb\u52a1\u6570&#xff08;L&#xff09;&#061; 500 \u00d7 0.3 &#061;\u00a0150<\/li>\n<\/ul>\n<p>\u8fd9\u610f\u5473\u7740&#xff0c;\u7cfb\u7edf\u91cc\u540c\u65f6\u6709 150 \u4e2a\u4efb\u52a1\u5728\u5904\u7406\/\u6392\u961f&#xff0c;\u624d\u80fd\u652f\u6491 500 QPS \u4e14 TP99 \u2264 300ms\u3002<\/p>\n<p>\u4f46\u6ce8\u610f&#xff1a;\u8fd9 150 \u662f\u201c\u5904\u7406\u4e2d &#043; \u6392\u961f\u4e2d\u201d\u7684\u603b\u6570\u3002\u5982\u679c\u961f\u5217\u4e3a\u7a7a&#xff08;\u7406\u60f3\u72b6\u6001&#xff09;&#xff0c;\u90a3\u7ebf\u7a0b\u6570\u5c31\u662f 150\u3002\u4f46\u73b0\u5b9e\u662f&#xff1a;<\/p>\n<ul>\n<li>\u7ebf\u7a0b\u4e0d\u53ef\u80fd 100% \u5fd9\u788c&#xff08;\u6709\u521b\u5efa\/\u9500\u6bc1\/\u4e0a\u4e0b\u6587\u5207\u6362\u5f00\u9500&#xff09;<\/li>\n<li>\u6d41\u91cf\u6709\u6bdb\u523a&#xff0c;\u9700\u8981\u961f\u5217\u5438\u6536\u6ce2\u52a8<\/li>\n<\/ul>\n<p>\u6240\u4ee5\u7ebf\u7a0b\u6570\u7684\u4e0b\u9650\u662f 150&#xff0c;\u4f46\u6211\u4eec\u9700\u8981\u7559\u51fa 20% \u7684\u7f13\u51b2&#xff1a;<\/p>\n<p>\/\/ \u7406\u8bba\u6700\u5c0f\u7ebf\u7a0b\u6570&#xff08;\u57fa\u4e8e Little&#039;s Law&#xff09;<br \/>\nint minThreads &#061; (int) Math.ceil(targetQps * targetRtSec);<br \/>\n\/\/ \u52a0\u4e0a 20% \u7684\u7f13\u51b2&#xff0c;\u5e94\u5bf9\u6d41\u91cf\u6bdb\u523a<br \/>\nint coreThreads &#061; (int) Math.ceil(minThreads * 1.2);  \/\/ 180<\/p>\n<h4>2.4 \u7b2c\u56db\u6b65&#xff1a;\u7528 CPU \u5360\u6bd4\u9a8c\u8bc1\u7ebf\u7a0b\u6570\u662f\u5426\u5408\u7406<\/h4>\n<p>\u73b0\u5728\u9a8c\u8bc1&#xff1a;180 \u4e2a\u7ebf\u7a0b&#xff0c;\u6bcf\u4e2a\u7ebf\u7a0b\u6709 15ms CPU \u7247\u6bb5&#xff0c;\u603b CPU \u9700\u6c42\u662f\u591a\u5c11&#xff1f;<\/p>\n<p>\u6bcf\u79d2 CPU \u603b\u9700\u6c42 &#061; 180 \u7ebf\u7a0b \u00d7 (15ms \/ 1000) \u00d7 (500 QPS \/ 180 \u5e76\u53d1)<br \/>\n                &#061; 500 QPS \u00d7 15ms &#061; 7.5 CPU \u79d2\/\u79d2<\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u9700\u8981\u5927\u7ea6 7.5 \u4e2a CPU \u6838\u624d\u80fd\u652f\u6491 500 QPS \u7684 CPU \u7247\u6bb5\u3002\u5982\u679c\u90e8\u7f72\u673a\u5668\u662f 8 \u6838&#xff0c;\u90a3 CPU \u4f7f\u7528\u7387\u7ea6 94%&#xff0c;\u504f\u9ad8\u3002<\/p>\n<p>\u6240\u4ee5&#xff0c;\u8981\u4e48\u52a0\u673a\u5668&#xff08;16 \u6838&#xff09;&#xff0c;\u8981\u4e48\u964d\u4f4e\u76ee\u6807 RT&#xff0c;\u8981\u4e48\u4f18\u5316 CPU \u7247\u6bb5&#xff08;\u6bd4\u5982\u7528\u00a0StringBuilder\u00a0\u66ff\u4ee3 JSON \u5e8f\u5217\u5316\u4e2d\u7684\u00a0ObjectMapper\u00a0\u91cd\u590d\u521b\u5efa&#xff09;\u3002<\/p>\n<p>\u7ed3\u8bba&#xff1a;\u7ebf\u7a0b\u6570\u4e0d\u662f\u62cd\u8111\u888b\u5b9a\u7684&#xff0c;\u5b83\u53d7\u9650\u4e8e CPU \u6838\u6570\u3002\u516c\u5f0f\u662f&#xff1a;<\/p>\n<p>\u7ebf\u7a0b\u6570 \u2264 (CPU \u6838\u6570 \u00d7 1000) \/ \u5355\u4efb\u52a1 CPU \u7247\u6bb5\u8017\u65f6 \u00d7 CPU \u5229\u7528\u7387\u4e0a\u9650<\/p>\n<p>\u5bf9\u4e8e 8 \u6838\u673a\u5668\u300170% CPU \u5229\u7528\u7387\u4e0a\u9650\u300115ms CPU \u7247\u6bb5&#xff1a;<\/p>\n<p>\u7ebf\u7a0b\u6570 \u2264 (8 \u00d7 1000) \/ 15 \u00d7 0.7 \u2248 373<\/p>\n<p>180 \u8fdc\u4f4e\u4e8e 373&#xff0c;\u6240\u4ee5\u00a0CPU \u4e0d\u662f\u74f6\u9888&#xff0c;IO \u7b49\u5f85\u624d\u662f&#xff0c;180 \u7ebf\u7a0b\u662f\u5408\u7406\u7684\u3002<\/p>\n<h4>2.5 \u7b2c\u4e94\u6b65&#xff1a;\u7b97\u961f\u5217\u957f\u5ea6&#xff08;\u6700\u5173\u952e\u7684\u3001\u6700\u5bb9\u6613\u88ab\u5ffd\u7565\u7684&#xff09;<\/h4>\n<p>\u961f\u5217\u957f\u5ea6\u51b3\u5b9a\u4e86\u6392\u961f\u7b49\u5f85\u65f6\u95f4\u3002\u5047\u8bbe\u7ebf\u7a0b\u6c60\u6ee1\u8d1f\u8377\u8fd0\u8f6c&#xff0c;\u65b0\u4efb\u52a1\u5230\u8fbe\u65f6&#xff0c;\u5982\u679c\u6240\u6709 180 \u4e2a\u7ebf\u7a0b\u90fd\u5fd9&#xff0c;\u4efb\u52a1\u5c31\u8fdb\u961f\u5217\u3002<\/p>\n<p>\u6392\u961f\u65f6\u95f4 &#061; \u961f\u5217\u957f\u5ea6 \/ \u7ebf\u7a0b\u6c60\u7684\u5904\u7406\u901f\u7387<\/p>\n<ul>\n<li>\u5904\u7406\u901f\u7387 &#061; 180 \u7ebf\u7a0b \/ 80ms&#xff08;\u5355\u4efb\u52a1\u603b\u8017\u65f6&#xff09;\u2248 2250 TPS&#xff08;\u7406\u8bba\u4e0a\u9650&#xff09;<\/li>\n<li>\u76ee\u6807 QPS &#061; 500&#xff0c;\u6240\u4ee5\u5269\u4f59\u5904\u7406\u80fd\u529b &#061; 2250 &#8211; 500 &#061; 1750 TPS<\/li>\n<li>\u5982\u679c\u60f3\u8ba9\u6392\u961f\u65f6\u95f4 \u2264 50ms&#xff08;\u56e0\u4e3a\u7aef\u5230\u7aef 300ms \u4e2d&#xff0c;\u5904\u7406\u8017\u65f6 80ms&#xff0c;\u7f51\u7edc\u7b49\u56fa\u5b9a\u5f00\u9500\u7ea6 150ms&#xff0c;\u53ea\u5269 50ms \u7ed9\u6392\u961f&#xff09;<\/li>\n<\/ul>\n<p>\u961f\u5217\u957f\u5ea6 \u2264 \u6392\u961f\u65f6\u95f4 \u00d7 \u5904\u7406\u901f\u7387 &#061; 0.05s \u00d7 2250 TPS \u2248 112<\/p>\n<p>\u8fd9\u5c31\u662f\u00a0workQueue\u00a0\u7684\u5bb9\u91cf\u4e0a\u9650&#xff01;\u8d85\u8fc7 112&#xff0c;\u6392\u961f\u65f6\u95f4\u5c31\u4f1a\u8d85\u8fc7 50ms&#xff0c;TP99 \u5c31\u65e0\u6cd5\u8fbe\u6210\u3002<\/p>\n<p>\u53cd\u76f4\u89c9\u70b9&#xff1a;\u5f88\u591a\u4eba\u914d\u00a0LinkedBlockingQueue(10000)&#xff0c;\u4ee5\u4e3a\u961f\u5217\u5927 &#061; \u541e\u5410\u9ad8\u3002\u5b9e\u9645\u4e0a\u961f\u5217\u8d8a\u5927&#xff0c;RT \u8d8a\u5dee&#xff0c;\u56e0\u4e3a\u8bf7\u6c42\u5728\u961f\u5217\u91cc\u7b49\u5230\u8d85\u65f6\u3002\u800c\u4e14\u961f\u5217\u6ee1\u4e4b\u524d&#xff0c;maximumPoolSize\u00a0\u6c38\u8fdc\u4e0d\u4f1a\u751f\u6548\u3002<\/p>\n<h4>2.6 \u7b2c\u516d\u6b65&#xff1a;\u786e\u5b9a maximumPoolSize<\/h4>\n<p>maximumPoolSize\u00a0\u662f\u4e3a\u4e86\u5e94\u5bf9\u77ac\u65f6\u6d41\u91cf\u9ad8\u5cf0\u3002\u5f53\u961f\u5217\u6ee1&#xff08;112&#xff09;\u65f6&#xff0c;\u5f00\u59cb\u521b\u5efa\u65b0\u7ebf\u7a0b\u3002<\/p>\n<ul>\n<li>\u5047\u8bbe\u9ad8\u5cf0\u6d41\u91cf\u662f\u6b63\u5e38\u6d41\u91cf\u7684 3 \u500d &#061; 1500 QPS<\/li>\n<li>\u6b64\u65f6\u9700\u8981\u7684\u603b\u7ebf\u7a0b\u6570 &#061; 1500 \u00d7 0.3s &#061; 450<\/li>\n<li>\u4f46 CPU \u6838\u6570\u9650\u5236&#xff08;8\u6838&#xff09;\u4e0b\u6700\u591a\u7ea6 373 \u7ebf\u7a0b<\/li>\n<li>\u6240\u4ee5\u00a0maximumPoolSize &#061; min(450, 373) \u2248 370<\/li>\n<\/ul>\n<p>\u6700\u7ec8\u53c2\u6570&#xff1a;<\/p>\n<p>ThreadPoolExecutor orderCreatePool &#061; new ThreadPoolExecutor(<br \/>\n    180,                    \/\/ corePoolSize&#xff1a;\u652f\u6491 500 QPS \u7a33\u6001\u6d41\u91cf<br \/>\n    370,                    \/\/ maximumPoolSize&#xff1a;\u652f\u6491 1500 QPS \u5cf0\u503c&#xff0c;\u53d7\u9650\u4e8e CPU<br \/>\n    60, TimeUnit.SECONDS,   \/\/ \u975e\u6838\u5fc3\u7ebf\u7a0b\u7a7a\u95f2\u56de\u6536<br \/>\n    new LinkedBlockingQueue&lt;&gt;(112),  \/\/ \u961f\u5217\u6700\u591a\u5bb9\u7eb3 112 \u4e2a\u4efb\u52a1&#xff0c;\u4fdd\u8bc1\u6392\u961f \u2264 50ms<br \/>\n    new NamedThreadFactory(&#034;order-create&#034;),<br \/>\n    new CallerRunsPolicy()  \/\/ \u62d2\u7edd\u7b56\u7565&#xff1a;\u8ba9\u63d0\u4ea4\u7ebf\u7a0b\u81ea\u5df1\u6267\u884c&#xff0c;\u800c\u4e0d\u662f\u629b\u5f02\u5e38<br \/>\n);<\/p>\n<hr \/>\n<h3>\u4e09\u3001\u538b\u6d4b\u9a8c\u8bc1&#xff1a;\u53c2\u6570\u4e0d\u662f\u7b97\u5b8c\u5c31\u5b8c&#xff0c;\u5fc5\u987b\u7528\u6570\u636e\u95ed\u73af<\/h3>\n<p>\u7406\u8bba\u7b97\u5b8c&#xff0c;\u5fc5\u987b\u4e0a\u538b\u6d4b\u3002\u6211\u4eec\u7528\u00a0wrk\u00a0\u6216\u00a0JMeter\u00a0\u6a21\u62df 500 QPS \u6301\u7eed 10 \u5206\u949f&#xff0c;\u89c2\u5bdf\u5173\u952e\u6307\u6807\u3002<\/p>\n<h4>3.1 \u538b\u6d4b\u7ed3\u679c\u5bf9\u6bd4<\/h4>\n<table>\n<tbody>\n<tr>\u573a\u666f\u7ebf\u7a0b\u6c60\u914d\u7f6eTP99TP999\u62d2\u7edd\u7387CPU \u4f7f\u7528\u7387<\/tr>\n<tr>\n<td>\u914d\u7f6e A&#xff08;\u9ed8\u8ba4\u62cd\u8111\u888b&#xff09;<\/td>\n<td>core&#061;10, max&#061;200, queue&#061;10000<\/td>\n<td>850ms<\/td>\n<td>2.3s<\/td>\n<td>0%&#xff08;\u4f46\u5168\u90e8\u8d85\u65f6&#xff09;<\/td>\n<td>45%<\/td>\n<\/tr>\n<tr>\n<td>\u914d\u7f6e B&#xff08;\u672c\u6587\u6f14\u7b97&#xff09;<\/td>\n<td>core&#061;180, max&#061;370, queue&#061;112<\/td>\n<td>285ms<\/td>\n<td>480ms<\/td>\n<td>0.02%&#xff08;\u53ef\u63a5\u53d7&#xff09;<\/td>\n<td>72%<\/td>\n<\/tr>\n<tr>\n<td>\u914d\u7f6e C&#xff08;\u76f2\u76ee\u52a0\u5927\u7ebf\u7a0b&#xff09;<\/td>\n<td>core&#061;500, max&#061;500, queue&#061;0<\/td>\n<td>310ms<\/td>\n<td>620ms<\/td>\n<td>4.5%&#xff08;\u62d2\u7edd\u8fc7\u591a&#xff09;<\/td>\n<td>95%<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5206\u6790&#xff1a;<\/p>\n<ul>\n<li>\u914d\u7f6e A \u7684\u961f\u5217\u592a\u957f&#xff0c;\u8bf7\u6c42\u5168\u5835\u5728\u961f\u5217\u91cc&#xff0c;RT \u4e25\u91cd\u8d85\u6807&#xff0c;\u4f46\u7ebf\u7a0b\u6c60\u5374\u201c\u770b\u8d77\u6765\u201d\u5f88\u5065\u5eb7&#xff08;\u6d3b\u8dc3\u7ebf\u7a0b\u4f4e&#xff09;\u3002<\/li>\n<li>\u914d\u7f6e B \u7684 TP99 \u8fbe\u6807&#xff0c;\u62d2\u7edd\u7387\u6781\u4f4e&#xff0c;CPU \u6709\u5408\u7406\u4f59\u91cf\u3002<\/li>\n<li>\u914d\u7f6e C \u7684\u961f\u5217\u4e3a 0&#xff0c;\u6d41\u91cf\u6bdb\u523a\u4e00\u6765\u76f4\u63a5\u62d2\u7edd&#xff0c;TP999 \u98d9\u5347\u3002<\/li>\n<\/ul>\n<p>\u5173\u952e\u6d1e\u5bdf&#xff1a;\u914d\u7f6e A \u7684\u95ee\u9898\u4e0d\u662f\u7ebf\u7a0b\u5c11&#xff0c;\u800c\u662f\u961f\u5217\u63a9\u76d6\u4e86\u95ee\u9898\u3002\u7ebf\u7a0b\u6c60\u76d1\u63a7\u663e\u793a\u201c\u6d3b\u8dc3\u7ebf\u7a0b 30\u201d\u4f1a\u7ed9\u4f60\u865a\u5047\u7684\u5b89\u5168\u611f&#xff0c;\u5b9e\u9645\u4e0a 10000 \u4e2a\u8bf7\u6c42\u5728\u961f\u5217\u91cc\u6392\u961f\u7b49\u6b7b\u3002<\/p>\n<h4>3.2 \u771f\u5b9e\u538b\u6d4b\u4ee3\u7801&#xff08;\u7528\u4e8e\u9a8c\u8bc1\u53c2\u6570&#xff09;<\/h4>\n<p>\/\/ \u538b\u6d4b\u811a\u672c\u6838\u5fc3\u903b\u8f91&#xff1a;\u6a21\u62df\u771f\u5b9e\u8bf7\u6c42\u5206\u5e03<br \/>\npublic class OrderCreateLoadTest {<br \/>\n    public static void main(String[] args) throws InterruptedException {<br \/>\n        ThreadPoolExecutor pool &#061; buildPool();  \/\/ \u4f7f\u7528\u4e0a\u4e00\u8282\u7684\u53c2\u6570<\/p>\n<p>        \/\/ \u6a21\u62df 500 QPS&#xff0c;\u6301\u7eed 5 \u5206\u949f<br \/>\n        ScheduledExecutorService scheduler &#061; Executors.newScheduledThreadPool(1);<br \/>\n        AtomicInteger success &#061; new AtomicInteger();<br \/>\n        AtomicInteger fail &#061; new AtomicInteger();<br \/>\n        List&lt;Long&gt; latencies &#061; Collections.synchronizedList(new ArrayList&lt;&gt;());<\/p>\n<p>        scheduler.scheduleAtFixedRate(() -&gt; {<br \/>\n            for (int i &#061; 0; i &lt; 500; i&#043;&#043;) {  \/\/ \u6bcf\u79d2\u63d0\u4ea4 500 \u4e2a\u4efb\u52a1<br \/>\n                long start &#061; System.currentTimeMillis();<br \/>\n                pool.execute(() -&gt; {<br \/>\n                    try {<br \/>\n                        \/\/ \u6a21\u62df\u8ba2\u5355\u521b\u5efa&#xff1a;30% CPU &#043; 70% IO<br \/>\n                        Thread.sleep(15);  \/\/ CPU \u7247\u6bb5<br \/>\n                        Thread.sleep(65);  \/\/ IO \u7b49\u5f85<br \/>\n                        latencies.add(System.currentTimeMillis() &#8211; start);<br \/>\n                        success.incrementAndGet();<br \/>\n                    } catch (Exception e) {<br \/>\n                        fail.incrementAndGet();<br \/>\n                    }<br \/>\n                });<br \/>\n            }<br \/>\n        }, 0, 1, TimeUnit.SECONDS);<\/p>\n<p>        \/\/ \u8fd0\u884c 5 \u5206\u949f\u540e\u7edf\u8ba1<br \/>\n        Thread.sleep(300_000);<br \/>\n        scheduler.shutdownNow();<br \/>\n        pool.shutdown();<\/p>\n<p>        \/\/ \u8ba1\u7b97 TP99 \/ TP999<br \/>\n        List&lt;Long&gt; sorted &#061; latencies.stream().sorted().collect(Collectors.toList());<br \/>\n        int idx99 &#061; (int)(sorted.size() * 0.99);<br \/>\n        int idx999 &#061; (int)(sorted.size() * 0.999);<br \/>\n        System.out.printf(&#034;QPS&#061;%d, TP99&#061;%dms, TP999&#061;%dms, \u62d2\u7edd\u7387&#061;%.2f%%%n&#034;,<br \/>\n            success.get() \/ 300, sorted.get(idx99), sorted.get(idx999),<br \/>\n            fail.get() * 100.0 \/ (success.get() &#043; fail.get()));<br \/>\n    }<br \/>\n}<\/p>\n<hr \/>\n<h3>\u56db\u3001\u53cd\u76f4\u89c9\u6e05\u5355&#xff1a;\u4ec0\u4e48\u65f6\u5019\u522b\u7528\u7ebf\u7a0b\u6c60&#xff0c;\u4ee5\u53ca\u6700\u9690\u853d\u7684\u5751<\/h3>\n<h4>4.1 \u5751 1&#xff1a;CallerRunsPolicy\u00a0\u4e0d\u662f\u4e07\u80fd\u7684<\/h4>\n<p>CallerRunsPolicy\u00a0\u5728\u62d2\u7edd\u65f6\u8ba9\u63d0\u4ea4\u4efb\u52a1\u7684\u7ebf\u7a0b&#xff08;\u6bd4\u5982 Tomcat \u7ebf\u7a0b&#xff09;\u81ea\u5df1\u6267\u884c\u4efb\u52a1\u3002\u542c\u8d77\u6765\u5f88\u597d&#xff0c;\u4f46\u5982\u679c\u63d0\u4ea4\u7ebf\u7a0b\u662f Netty \u7684 IO \u7ebf\u7a0b&#xff0c;\u5b83\u4f1a\u963b\u585e\u4e8b\u4ef6\u5faa\u73af&#xff0c;\u5bfc\u81f4\u6574\u4e2a\u670d\u52a1\u4e0d\u53ef\u7528\u3002<\/p>\n<p>\u6b63\u786e\u59ff\u52bf&#xff1a;\u5982\u679c\u63d0\u4ea4\u7ebf\u7a0b\u662f IO \u7ebf\u7a0b&#xff0c;\u7528\u00a0DiscardOldestPolicy\u00a0&#043; \u76d1\u63a7\u544a\u8b66&#xff1b;\u5982\u679c\u662f\u4e1a\u52a1\u7ebf\u7a0b&#xff0c;CallerRunsPolicy\u00a0\u624d\u6709\u610f\u4e49\u3002<\/p>\n<h4>4.2 \u5751 2&#xff1a;\u7ebf\u7a0b\u6c60\u53c2\u6570\u4e0d\u662f\u201c\u914d\u4e00\u6b21\u7ba1\u7ec8\u8eab\u201d<\/h4>\n<p>QPS \u4f1a\u53d8&#xff0c;RT \u4f1a\u53d8&#xff0c;\u4ee3\u7801\u4f1a\u53d8\u3002\u53c2\u6570\u5fc5\u987b\u52a8\u6001\u5316\u3002\u5efa\u8bae\u505a\u6cd5&#xff1a;<\/p>\n<ul>\n<li>\u7528\u00a0ThreadPoolExecutor\u00a0\u7684\u00a0setCorePoolSize()\u00a0\/\u00a0setMaximumPoolSize()\u00a0\u63a5\u53e3&#xff0c;\u914d\u5408\u914d\u7f6e\u4e2d\u5fc3&#xff08;Apollo\/Nacos&#xff09;\u52a8\u6001\u8c03\u6574\u3002<\/li>\n<li>\u4f46\u00a0workQueue\u00a0\u7684\u5bb9\u91cf\u65e0\u6cd5\u52a8\u6001\u4fee\u6539&#xff08;LinkedBlockingQueue\u00a0\u7684 capacity \u662f final&#xff09;\u3002\u6240\u4ee5\u961f\u5217\u5bb9\u91cf\u8981\u6309\u672a\u6765 1 \u5e74\u7684\u5cf0\u503c\u6d41\u91cf\u6765\u7b97&#xff0c;\u800c\u4e0d\u662f\u5f53\u524d\u6d41\u91cf\u3002<\/li>\n<\/ul>\n<h4>4.3 \u5751 3&#xff1a;\u7ebf\u7a0b\u6c60\u76d1\u63a7\u5fc5\u987b\u770b\u201c\u6392\u961f\u65f6\u95f4\u201d&#xff0c;\u4e0d\u662f\u201c\u6d3b\u8dc3\u7ebf\u7a0b\u201d<\/h4>\n<p>\u5927\u90e8\u5206\u76d1\u63a7\u9762\u677f\u5c55\u793a\u6d3b\u8dc3\u7ebf\u7a0b\u6570&#xff0c;\u4f46\u8fd9\u4f1a\u8bef\u5bfc\u4f60\u3002\u771f\u6b63\u7684\u5065\u5eb7\u6307\u6807\u662f\u4efb\u52a1\u5728\u961f\u5217\u4e2d\u7684\u5e73\u5747\u7b49\u5f85\u65f6\u95f4\u3002\u5982\u679c\u7b49\u5f85\u65f6\u95f4 &gt; 50ms&#xff0c;\u8bf4\u660e\u7ebf\u7a0b\u6570\u4e0d\u591f\u6216\u961f\u5217\u592a\u957f&#xff0c;\u9700\u8981\u6269\u5bb9\u3002<\/p>\n<h4>4.4 \u4ec0\u4e48\u65f6\u5019\u522b\u7528\u7ebf\u7a0b\u6c60&#xff08;\u53cd\u76f4\u89c9&#xff09;<\/h4>\n<ul>\n<li>\u5f53\u4f60\u7684\u4efb\u52a1\u662f\u7eaf CPU \u5bc6\u96c6\u578b&#xff08;\u5982\u52a0\u5bc6\u3001\u538b\u7f29&#xff09;&#xff1a;\u7ebf\u7a0b\u6570 &#061; CPU \u6838\u6570 &#043; 1&#xff0c;\u7528\u7ebf\u7a0b\u6c60\u53cd\u800c\u589e\u52a0\u4e0a\u4e0b\u6587\u5207\u6362\u5f00\u9500\u3002<\/li>\n<li>\u5f53\u4f60\u7684\u4efb\u52a1\u4f9d\u8d56\u5916\u90e8\u670d\u52a1\u4e14\u5916\u90e8\u670d\u52a1\u4f1a\u7ea7\u8054\u8d85\u65f6&#xff1a;\u7ebf\u7a0b\u6c60\u4f1a\u8017\u5c3d&#xff0c;\u4f46\u8fd9\u4e0d\u662f\u7ebf\u7a0b\u6c60\u7684\u95ee\u9898&#xff0c;\u662f\u65ad\u8def\u5668\u7f3a\u5931\u7684\u95ee\u9898\u3002\u5148\u52a0\u00a0Resilience4j\u00a0\u6216\u00a0Sentinel&#xff0c;\u518d\u8c03\u53c2\u6570\u3002<\/li>\n<li>\u5f53\u4f60\u7684 QPS \u6781\u4f4e&#xff08;&lt; 10&#xff09;\u4e14 RT \u8981\u6c42\u6781\u9ad8&#xff08;&lt; 10ms&#xff09;&#xff1a;\u76f4\u63a5\u7528\u865a\u62df\u7ebf\u7a0b&#xff08;JDK 21&#xff09;\u6216\u54cd\u5e94\u5f0f\u7f16\u7a0b&#xff0c;\u7ebf\u7a0b\u6c60\u7684\u6392\u961f\u65f6\u95f4\u5c31\u662f\u4e0d\u53ef\u63a5\u53d7\u7684\u5ef6\u8fdf\u3002<\/li>\n<li>\u5f53\u4f60\u7684\u4efb\u52a1\u662f\u77ed\u4efb\u52a1&#xff08;&lt; 1ms&#xff09;\u4e14\u63d0\u4ea4\u9891\u7387\u6781\u9ad8&#xff1a;\u7ebf\u7a0b\u6c60\u7684\u9501\u7ade\u4e89&#xff08;mainLock&#xff09;\u4f1a\u6210\u4e3a\u74f6\u9888&#xff0c;\u8003\u8651\u00a0Disruptor\u00a0\u65e0\u9501\u961f\u5217\u3002<\/li>\n<\/ul>\n<h4>4.5 \u7ec8\u6781\u53cd\u76f4\u89c9\u7ed3\u8bba<\/h4>\n<p>\u7ebf\u7a0b\u6c60\u53c2\u6570\u8ba1\u7b97\u7684\u6839\u672c\u76ee\u7684\u662f\u63a7\u5236\u201c\u6392\u961f\u65f6\u95f4\u201d&#xff0c;\u800c\u4e0d\u662f\u201c\u6700\u5927\u5316\u541e\u5410\u91cf\u201d\u3002\u5f53\u4f60\u628a\u76ee\u6807\u4ece\u201c\u541e\u5410\u201d\u6539\u4e3a\u201c\u5ef6\u8fdf\u201d\u65f6&#xff0c;\u53c2\u6570\u8ba1\u7b97\u7684\u65b9\u6cd5\u8bba\u5c31\u5b8c\u5168\u53d8\u4e86\u2014\u2014\u4f60\u4f1a\u60ca\u8bb6\u5730\u53d1\u73b0&#xff0c;\u6709\u65f6\u5019\u51cf\u5c11\u7ebf\u7a0b\u6570\u53cd\u800c\u80fd\u964d\u4f4e TP99&#xff0c;\u56e0\u4e3a\u51cf\u5c11\u4e86\u4e0a\u4e0b\u6587\u5207\u6362\u548c\u9501\u7ade\u4e89\u3002<\/p>\n<hr \/>\n<h3>\u4e94\u3001\u7cfb\u5217\u9884\u544a\u4e0e\u4e92\u52a8<\/h3>\n<p>\u672c\u6587\u662f order-service \u7cfb\u5217\u7684\u7b2c 6 \u7bc7\u3002\u4e0b\u4e00\u7bc7\u5c06\u6df1\u5165\u00a0\u300a\u4ece\u7ebf\u7a0b\u6c60\u5230\u865a\u62df\u7ebf\u7a0b&#xff1a;JDK 21 \u7684\u8fc1\u79fb\u4ee3\u4ef7\u4e0e\u6536\u76ca\u5b9e\u6d4b\u300b&#xff0c;\u6211\u4eec\u4f1a\u7528\u540c\u4e00\u5957\u538b\u6d4b\u4ee3\u7801&#xff0c;\u5bf9\u6bd4\u00a0ThreadPoolExecutor\u00a0\u4e0e\u00a0Executors.newVirtualThreadPerTaskExecutor()\u00a0\u5728 500 QPS\u30011000 QPS\u30015000 QPS \u4e0b\u7684\u8868\u73b0&#xff0c;\u5e76\u7ed9\u51fa\u54ea\u4e9b\u573a\u666f\u503c\u5f97\u8fc1\u79fb\u3001\u54ea\u4e9b\u573a\u666f\u8fc1\u79fb\u540e\u66f4\u6162\u7684\u5b9e\u6d4b\u6570\u636e\u3002<\/p>\n<p>\u5982\u679c\u4f60\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u88ab\u7ebf\u7a0b\u6c60\u5751\u8fc7\u2014\u2014\u6bd4\u5982\u8be1\u5f02\u7684\u8d85\u65f6\u3001\u865a\u5047\u7684\u201c\u7ebf\u7a0b\u6c60\u8017\u5c3d\u201d\u544a\u8b66\u3001\u6216\u8005\u8c03\u53c2\u540e\u6beb\u65e0\u6548\u679c\u2014\u2014\u6b22\u8fce\u5728\u8bc4\u8bba\u533a\u5206\u4eab\u4f60\u7684\u573a\u666f\u3002\u6211\u4f1a\u6311\u9009\u5178\u578b\u95ee\u9898&#xff0c;\u5728\u540e\u7eed\u6587\u7ae0\u4e2d\u505a\u6e90\u7801\u7ea7\u5206\u6790\u3002<\/p>\n<p>\u5173\u952e\u8bcd\u6807\u7b7e&#xff1a;\u7ebf\u7a0b\u6c60\u53c2\u6570\u8ba1\u7b97\u3001ThreadPoolExecutor\u6e90\u7801\u3001QPS\u5bb9\u91cf\u89c4\u5212\u3001Little&#039;s Law\u3001Java\u5e76\u53d1\u8c03\u4f18<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u53e5\u8bdd\u53cd\u76f4\u89c9\u7ed3\u8bba&#xff1a;CPU \u6838\u6570  1\u00a0\u8fd9\u4e2a\u7ebf\u7a0b\u6c60\u53c2\u6570\u516c\u5f0f&#xff0c;\u5728 IO \u5bc6\u96c6\u578b\u573a\u666f\u4e0b&#xff0c;\u4f1a\u8ba9\u4f60\u7684 order-service \u541e\u5410\u91cf\u76f4\u63a5\u8170\u65a9&#xff1b;\u800c\u771f\u6b63\u8be5\u7b97\u7684&#xff0c;\u4e0d\u662f\u201c\u7ebf\u7a0b\u6570\u201d&#xff0c;\u662f\u201c\u6392\u961f\u65f6\u95f4\u201d\u548c\u201c\u62d2\u7edd\u7387\u201d\u7684\u6570\u5b66\u671f\u671b\u3002\u627f\u63a5\u4e0a\u4e00\u7bc7\u300aAI Agent \u4e0e Function Calling\u300b\u4e2d\u63d0\u5230\u7684\u201c\u5f02\u6b65\u4efb\u52a1\u7f16\u6392\u201d&#xff0c;\u672c\u6587\u4e0d\u518d\u79d1\u666e\u7ebf\u7a0b\u6c60\u57fa\u7840 API&#xff0c;\u800c\u662f\u805a\u7126\u53c2\u6570\u6f14\u7b97\u7684\u5b8c\u6574\u95ed\u73af&amp;#xff1<\/p>\n","protected":false},"author":2,"featured_media":100269,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9098,99,2661,101,98,963],"topic":[],"class_list":["post-100270","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-it","tag-java","tag-junit","tag-spring","tag-spring-boot","tag-spring-cloud"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u7ebf\u7a0b\u6c60\u53c2\u6570\u5230\u5e95\u600e\u4e48\u7b97\uff08\u9644\u771f\u5b9e QPS \u6f14\u7b97\uff09 - \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\/100270.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7ebf\u7a0b\u6c60\u53c2\u6570\u5230\u5e95\u600e\u4e48\u7b97\uff08\u9644\u771f\u5b9e QPS \u6f14\u7b97\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u53e5\u8bdd\u53cd\u76f4\u89c9\u7ed3\u8bba&#xff1a;CPU \u6838\u6570 1\u00a0\u8fd9\u4e2a\u7ebf\u7a0b\u6c60\u53c2\u6570\u516c\u5f0f&#xff0c;\u5728 IO \u5bc6\u96c6\u578b\u573a\u666f\u4e0b&#xff0c;\u4f1a\u8ba9\u4f60\u7684 order-service \u541e\u5410\u91cf\u76f4\u63a5\u8170\u65a9&#xff1b;\u800c\u771f\u6b63\u8be5\u7b97\u7684&#xff0c;\u4e0d\u662f\u201c\u7ebf\u7a0b\u6570\u201d&#xff0c;\u662f\u201c\u6392\u961f\u65f6\u95f4\u201d\u548c\u201c\u62d2\u7edd\u7387\u201d\u7684\u6570\u5b66\u671f\u671b\u3002\u627f\u63a5\u4e0a\u4e00\u7bc7\u300aAI Agent \u4e0e Function Calling\u300b\u4e2d\u63d0\u5230\u7684\u201c\u5f02\u6b65\u4efb\u52a1\u7f16\u6392\u201d&#xff0c;\u672c\u6587\u4e0d\u518d\u79d1\u666e\u7ebf\u7a0b\u6c60\u57fa\u7840 API&#xff0c;\u800c\u662f\u805a\u7126\u53c2\u6570\u6f14\u7b97\u7684\u5b8c\u6574\u95ed\u73af&amp;#xff1\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/100270.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-04T03:32:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260904033250-6a9a3be23963e.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=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/100270.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/100270.html\",\"name\":\"\u7ebf\u7a0b\u6c60\u53c2\u6570\u5230\u5e95\u600e\u4e48\u7b97\uff08\u9644\u771f\u5b9e QPS \u6f14\u7b97\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-04T03:32:51+00:00\",\"dateModified\":\"2026-09-04T03:32:51+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/100270.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/100270.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/100270.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u7ebf\u7a0b\u6c60\u53c2\u6570\u5230\u5e95\u600e\u4e48\u7b97\uff08\u9644\u771f\u5b9e QPS \u6f14\u7b97\uff09\"}]},{\"@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":"\u7ebf\u7a0b\u6c60\u53c2\u6570\u5230\u5e95\u600e\u4e48\u7b97\uff08\u9644\u771f\u5b9e QPS \u6f14\u7b97\uff09 - \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\/100270.html","og_locale":"zh_CN","og_type":"article","og_title":"\u7ebf\u7a0b\u6c60\u53c2\u6570\u5230\u5e95\u600e\u4e48\u7b97\uff08\u9644\u771f\u5b9e QPS \u6f14\u7b97\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u53e5\u8bdd\u53cd\u76f4\u89c9\u7ed3\u8bba&#xff1a;CPU \u6838\u6570 1\u00a0\u8fd9\u4e2a\u7ebf\u7a0b\u6c60\u53c2\u6570\u516c\u5f0f&#xff0c;\u5728 IO \u5bc6\u96c6\u578b\u573a\u666f\u4e0b&#xff0c;\u4f1a\u8ba9\u4f60\u7684 order-service \u541e\u5410\u91cf\u76f4\u63a5\u8170\u65a9&#xff1b;\u800c\u771f\u6b63\u8be5\u7b97\u7684&#xff0c;\u4e0d\u662f\u201c\u7ebf\u7a0b\u6570\u201d&#xff0c;\u662f\u201c\u6392\u961f\u65f6\u95f4\u201d\u548c\u201c\u62d2\u7edd\u7387\u201d\u7684\u6570\u5b66\u671f\u671b\u3002\u627f\u63a5\u4e0a\u4e00\u7bc7\u300aAI Agent \u4e0e Function Calling\u300b\u4e2d\u63d0\u5230\u7684\u201c\u5f02\u6b65\u4efb\u52a1\u7f16\u6392\u201d&#xff0c;\u672c\u6587\u4e0d\u518d\u79d1\u666e\u7ebf\u7a0b\u6c60\u57fa\u7840 API&#xff0c;\u800c\u662f\u805a\u7126\u53c2\u6570\u6f14\u7b97\u7684\u5b8c\u6574\u95ed\u73af&amp;#xff1","og_url":"https:\/\/www.wsisp.com\/helps\/100270.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-04T03:32:51+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260904033250-6a9a3be23963e.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/100270.html","url":"https:\/\/www.wsisp.com\/helps\/100270.html","name":"\u7ebf\u7a0b\u6c60\u53c2\u6570\u5230\u5e95\u600e\u4e48\u7b97\uff08\u9644\u771f\u5b9e QPS \u6f14\u7b97\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-04T03:32:51+00:00","dateModified":"2026-09-04T03:32:51+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/100270.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/100270.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/100270.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u7ebf\u7a0b\u6c60\u53c2\u6570\u5230\u5e95\u600e\u4e48\u7b97\uff08\u9644\u771f\u5b9e QPS \u6f14\u7b97\uff09"}]},{"@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\/100270","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=100270"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/100270\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/100269"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=100270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=100270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=100270"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=100270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}