{"id":34631,"date":"2025-03-11T14:26:49","date_gmt":"2025-03-11T06:26:49","guid":{"rendered":"https:\/\/www.yunshan.net\/blog\/?p=34631"},"modified":"2025-03-11T14:26:49","modified_gmt":"2025-03-11T06:26:49","slug":"%e5%ba%94%e7%94%a8%e6%95%85%e9%9a%9c%e5%ae%9a%e4%bd%8d%e6%97%b6%e5%a6%82%e4%bd%95%e5%a4%84%e7%90%86%e7%ba%bf%e7%a8%8b%e9%98%bb%e5%a1%9e%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.yunshan.net\/blog\/archives\/34631.html","title":{"rendered":"\u5e94\u7528\u6545\u969c\u5b9a\u4f4d\u65f6\u5982\u4f55\u5904\u7406\u7ebf\u7a0b\u963b\u585e\uff1f"},"content":{"rendered":"<p style=\"text-align: center;\">\n<p><img decoding=\"async\" src=\"https:\/\/www.yunshan.net\/blog\/wp-content\/uploads\/2025\/03\/ws5sQ.jpg\" alt=\"\u5e94\u7528\u6545\u969c\u5b9a\u4f4d\u65f6\u5982\u4f55\u5904\u7406\u7ebf\u7a0b\u963b\u585e\uff1f\" ><\/p>\n<\/p>\n<p><strong>\u524d\u8a00\uff1a\u5f53\u7ebf\u4e0a\u670d\u52a1\u7a81\u7136\u54cd\u5e94\u8fdf\u7f13\uff0c\u7528\u6237\u6295\u8bc9\u5982\u6f6e\u6c34\u822c\u6d8c\u6765\u65f6\uff0c\u5f00\u53d1\u56e2\u961f\u6700\u6015\u542c\u5230\u7684\u56db\u4e2a\u5b57\u53ef\u80fd\u5c31\u662f\u201c\u7ebf\u7a0b\u963b\u585e\u201d<\/strong>\u3002\u8fd9\u4e2a\u6f5c\u4f0f\u5728\u4ee3\u7801\u6df1\u5904\u7684\u5e7d\u7075\uff0c\u80fd\u5728\u6beb\u79d2\u95f4\u8ba9\u541e\u5410\u91cf\u9aa4\u964d\u3001CPU\u5f02\u5e38\u6ce2\u52a8\uff0c\u751a\u81f3\u5f15\u53d1\u7ea7\u8054\u5f0f\u7cfb\u7edf\u5d29\u6e83\u3002\u636e\u7edf\u8ba1\uff0c\u7ea637%\u7684Java\u5e94\u7528\u6027\u80fd\u95ee\u9898\u4e0e\u7ebf\u7a0b\u7ba1\u7406\u76f4\u63a5\u76f8\u5173\uff0c\u800c\u5176\u4e2d\u8d85\u8fc760%\u7684\u6545\u969c\u5b9a\u4f4d\u8017\u65f6\u96c6\u4e2d\u5728*\u7ebf\u7a0b\u72b6\u6001\u5206\u6790*\u548c*\u8d44\u6e90\u7ade\u4e89\u6392\u67e5*\u4e0a\u3002\u672c\u6587\u5c06\u6df1\u5165\u5256\u6790\u7ebf\u7a0b\u963b\u585e\u7684\u5178\u578b\u573a\u666f\uff0c\u63d0\u4f9b\u4e00\u5957\u4ece\u9884\u8b66\u5230\u6839\u6cbb\u7684\u5b9e\u6218\u6307\u5357\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u50cf\u5916\u79d1\u624b\u672f\u822c\u7cbe\u51c6\u5b9a\u4f4d\u5e76\u5316\u89e3\u8fd9\u4e00\u9690\u853d\u6740\u624b\u3002<\/p>\n<hr>\n<h3 id=\"\u4e00-\u7ebf\u7a0b\u963b\u585e\u7684\u672c\u8d28\u4e0e\u5f71\u54cd\u5c42\u7ea7\"><strong>\u4e00\u3001\u7ebf\u7a0b\u963b\u585e\u7684\u672c\u8d28\u4e0e\u5f71\u54cd\u5c42\u7ea7<\/strong><\/h3>\n<p>\u7ebf\u7a0b\u963b\u585e\u5e76\u975e\u5355\u7eaf\u7684\u4ee3\u7801\u7f3a\u9677\uff0c\u800c\u662f<strong>\u7cfb\u7edf\u8d44\u6e90\u8c03\u5ea6\u3001\u4e1a\u52a1\u903b\u8f91\u8bbe\u8ba1\u3001\u57fa\u7840\u8bbe\u65bd\u627f\u8f7d\u529b\u7684\u7efc\u5408\u4ea7\u7269<\/strong>\u3002\u5f53\u7ebf\u7a0b\u56e0\u7b49\u5f85\u9501\u91ca\u653e\u3001I\/O\u5b8c\u6210\u6216\u5916\u90e8\u4f9d\u8d56\u54cd\u5e94\u800c\u8fdb\u5165<code>BLOCKED<\/code>\/<code>WAITING<\/code>\u72b6\u6001\u65f6\uff0c\u5176\u6301\u6709\u7684\u5185\u5b58\u3001\u8fde\u63a5\u7b49\u8d44\u6e90\u65e0\u6cd5\u91ca\u653e\uff0c\u8f7b\u5219\u5bfc\u81f4\u63a5\u53e3\u5ef6\u8fdf\u4e0a\u5347\uff0c\u91cd\u5219\u89e6\u53d1\u7ebf\u7a0b\u6c60\u6ee1\u8f7d\u540e\u7684\u670d\u52a1\u96ea\u5d29\u3002<\/p>\n<p>\u5178\u578b\u75c7\u72b6\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u63a5\u53e3TP99\u503c\u975e\u7ebf\u6027\u98d9\u5347<\/strong>\uff0c\u4f46CPU\u5229\u7528\u7387\u4e0d\u5347\u53cd\u964d\n<\/li>\n<li><code>jstack<\/code>\u65e5\u5fd7\u4e2d\u51fa\u73b0\u5927\u91cf<code>parking to wait for &lt;0x0000000713b4b8d8&gt;<\/code>\u72b6\u6001\n<\/li>\n<li>\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u6d3b\u8dc3\u8fde\u63a5\u6570\u7a81\u7834\u9608\u503c\uff0c\u4f34\u968f<code>ConnectionTimeoutException<\/code>\n<\/li>\n<\/ul>\n<hr>\n<h3 id=\"\u4e8c-\u56db\u7ef4\u8bca\u65ad\u6cd5-\u4ece\u73b0\u8c61\u5230\u6839\u56e0\u7684\u7cbe\u51c6\u5b9a\u4f4d\"><strong>\u4e8c\u3001\u56db\u7ef4\u8bca\u65ad\u6cd5\uff1a\u4ece\u73b0\u8c61\u5230\u6839\u56e0\u7684\u7cbe\u51c6\u5b9a\u4f4d<\/strong><\/h3>\n<h4 id=\"1-\u7ebf\u7a0b\u72b6\u6001\u5feb\u7167\u5206\u6790\"><strong>1. \u7ebf\u7a0b\u72b6\u6001\u5feb\u7167\u5206\u6790<\/strong><\/h4>\n<p>\u901a\u8fc7<code>jstack<\/code>\u6216<code>arthas thread -n 5<\/code>\u83b7\u53d6\u7ebf\u7a0b\u8f6c\u50a8\uff0c\u91cd\u70b9\u5173\u6ce8\uff1a<\/p>\n<ul>\n<li><strong>\u9501\u7ade\u4e89\u70ed\u70b9<\/strong>\uff1a\u7edf\u8ba1<code>BLOCKED<\/code>\u72b6\u6001\u7ebf\u7a0b\u7684\u9501\u6301\u6709\u8005\uff0c\u82e5\u67d0\u7ebf\u7a0b\u957f\u671f\u6301\u6709<code>ReentrantLock<\/code>\u6216<code>synchronized<\/code>\u76d1\u89c6\u5668\uff0c\u9700\u68c0\u67e5\u9501\u7c92\u5ea6\n<\/li>\n<li><strong>\u7b49\u5f85\u94fe\u95ed\u73af<\/strong>\uff1a\u8bc6\u522b<code>WAITING<\/code>\u72b6\u6001\u7684<code>FutureTask<\/code>\u6216<code>ThreadPoolExecutor$Worker<\/code>\uff0c\u786e\u8ba4\u662f\u5426\u5b58\u5728\u4efb\u52a1\u4f9d\u8d56\u6b7b\u9501\n<\/li>\n<li><strong>\u8d44\u6e90\u8017\u5c3d\u5f81\u5146<\/strong>\uff1a<code>TIMED_WAITING (on object monitor)<\/code>\u7ed3\u5408\u5806\u5185\u5b58\u5206\u6790\uff0c\u6392\u67e5\u5bf9\u8c61\u6c60\u6cc4\u6f0f\n<\/li>\n<\/ul>\n<pre><code class=\"language-java\">\/\/ \u793a\u4f8b\uff1aarthas\u5feb\u901f\u5b9a\u4f4d\u963b\u585e\u70b9  \r\nwatch java.lang.Thread getState '{params[0].name, returnObj}' -n 5  \r\n<\/code><\/pre>\n<h4 id=\"2-\u8fd0\u884c\u65f6\u8d44\u6e90\u753b\u50cf\"><strong>2. \u8fd0\u884c\u65f6\u8d44\u6e90\u753b\u50cf<\/strong><\/h4>\n<p>\u5229\u7528<code><a href=\"https:\/\/www.yunshan.net\/\"   target=\"_blank\" style=\"color:blue\">Prometheus<\/a>+Grafana<\/code>\u6784\u5efa\u76d1\u63a7\u77e9\u9635\uff1a<\/p>\n<ul>\n<li><strong>\u7ebf\u7a0b\u6c60\u6d3b\u8dc3\u5ea6<\/strong>\uff1a<code>thread_pool_active_threads<\/code>\u4e0e<code>queue_remaining_capacity<\/code>\u7684\u6bd4\u503c\u8d8570%\u5373\u4eae\u9ec4\u706f\n<\/li>\n<li><strong>\u9501\u6301\u6709\u65f6\u957f<\/strong>\uff1a\u901a\u8fc7<code>Java Flight Recorder<\/code>\u8bb0\u5f55<code>synchronized<\/code>\u6216<code>Lock<\/code>\u7684\u7b49\u5f85\u65f6\u95f4\u5206\u5e03\n<\/li>\n<li><strong>I\/O\u74f6\u9888\u5b9a\u4f4d<\/strong>\uff1a\u5f53<code>iostat<\/code>\u663e\u793a\u78c1\u76d8\u5229\u7528\u7387\u6301\u7eed&gt;90%\uff0c\u9700\u68c0\u67e5\u65e5\u5fd7\u6253\u5370\u7b56\u7565\u6216\u6587\u4ef6\u8bfb\u5199\u7f13\u51b2\u533a\n<\/li>\n<\/ul>\n<h4 id=\"3-\u4ee3\u7801\u7ea7\u53cd\u6a21\u5f0f\u8bc6\u522b\"><strong>3. \u4ee3\u7801\u7ea7\u53cd\u6a21\u5f0f\u8bc6\u522b<\/strong><\/h4>\n<ul>\n<li><strong>\u9501\u5d4c\u5957\u9677\u9631<\/strong>\uff1a\u5728\u540c\u4e00\u4e2a\u7ebf\u7a0b\u4e2d\u91cd\u590d\u83b7\u53d6\u4e0d\u53ef\u91cd\u5165\u9501\n<\/li>\n<li><strong>\u540c\u6b65\u5bb9\u5668\u6ee5\u7528<\/strong>\uff1a\u5728\u591a\u7ebf\u7a0b\u73af\u5883\u4e2d\u76f4\u63a5\u8c03\u7528<code>HashMap<\/code>\u7684<code>put<\/code>\u65b9\u6cd5\n<\/li>\n<li><strong>\u4f2a\u5171\u4eab\u5f15\u53d1\u7f13\u5b58\u884c\u7ade\u4e89<\/strong>\uff1a\u9ad8\u9891\u66f4\u65b0\u7684Volatile\u53d8\u91cf\u672a\u6309<code>@Contended<\/code>\u5bf9\u9f50\n<\/li>\n<\/ul>\n<pre><code class=\"language-java\">\/\/ \u9519\u8bef\u793a\u4f8b\uff1a\u5728\u5f02\u6b65\u56de\u8c03\u4e2d\u540c\u6b65\u4fee\u6539\u975e\u7ebf\u7a0b\u5b89\u5168\u96c6\u5408  \r\nexecutor.submit(() -&gt; {  \r\nsynchronized (list) {  \/\/ \u963b\u585e\u70b9\uff01  \r\nlist.add(data);  \r\n}  \r\n});  \r\n<\/code><\/pre>\n<h4 id=\"4-\u538b\u529b\u6d4b\u8bd5\u590d\u73b0\"><strong>4. \u538b\u529b\u6d4b\u8bd5\u590d\u73b0<\/strong><\/h4>\n<p>\u901a\u8fc7<code>JMeter<\/code>\u6a21\u62df\u5cf0\u503c\u6d41\u91cf\uff0c\u914d\u5408<code>Async Profiler<\/code>\u6293\u53d6\u706b\u7130\u56fe\uff1a<\/p>\n<ul>\n<li><strong>\u9636\u68af\u5f0f\u52a0\u538b<\/strong>\uff1a\u4ee550%\u6b65\u957f\u9010\u6b65\u63d0\u5347QPS\uff0c\u89c2\u5bdf\u7ebf\u7a0b\u6c60\u62d2\u7edd\u7b56\u7565\u89e6\u53d1\u70b9\n<\/li>\n<li><strong>\u963b\u585e\u5806\u6808\u805a\u5408<\/strong>\uff1a\u4f7f\u7528<code>jcmd &lt;pid&gt; Thread.print<\/code>\u5bfc\u51fa\u4e09\u6b21\u5feb\u7167\uff0c\u5bf9\u6bd4\u963b\u585e\u5806\u6808\u53d8\u5316\n<\/li>\n<li><strong>\u8d44\u6e90\u6cc4\u6f0f\u9a8c\u8bc1<\/strong>\uff1a\u5728\u8d1f\u8f7d\u56de\u843d\u540e\uff0c\u786e\u8ba4\u7ebf\u7a0b\u6570\u3001\u8fde\u63a5\u6570\u80fd\u5426\u6062\u590d\u5230\u57fa\u7ebf\u6c34\u5e73\n<\/li>\n<\/ul>\n<hr>\n<h3 id=\"\u4e09-\u516d\u5927\u7834\u5c40\u4e4b\u9053-\u4ece\u5e94\u6025\u6b62\u8840\u5230\u67b6\u6784\u514d\u75ab\"><strong>\u4e09\u3001\u516d\u5927\u7834\u5c40\u4e4b\u9053\uff1a\u4ece\u5e94\u6025\u6b62\u8840\u5230\u67b6\u6784\u514d\u75ab<\/strong><\/h3>\n<h4 id=\"1-\u975e\u963b\u585e\u5316\u6539\u9020\"><strong>1. \u975e\u963b\u585e\u5316\u6539\u9020<\/strong><\/h4>\n<ul>\n<li><strong>\u5f02\u6b65\u7f16\u6392<\/strong>\uff1a\u5c06\u540c\u6b65RPC\u8c03\u7528\u66ff\u6362\u4e3a<code>CompletableFuture<\/code>\u94fe\u5f0f\u8c03\u7528\n<\/li>\n<li><strong>\u4e8b\u4ef6\u9a71\u52a8<\/strong>\uff1a\u91c7\u7528<code>Reactor<\/code>\u6a21\u5f0f\u5904\u7406\u9ad8\u5e76\u53d1I\/O\uff0c\u5982Netty\u7684<code>ChannelFuture<\/code>\n<\/li>\n<li><strong>\u534f\u7a0b\u964d\u7ef4\u6253\u51fb<\/strong>\uff1a\u5728JVM\u751f\u6001\u4e2d\u5f15\u5165Kotlin\u534f\u7a0b\u6216Project Loom\u865a\u62df\u7ebf\u7a0b\n<\/li>\n<\/ul>\n<h4 id=\"2-\u9501\u4f18\u5316\u56db\u91cd\u594f\"><strong>2. \u9501\u4f18\u5316\u56db\u91cd\u594f<\/strong><\/h4>\n<ul>\n<li><strong>\u9501\u7c97\u5316<\/strong>\uff1a\u5408\u5e76\u76f8\u90bb\u7684\u540c\u6b65\u5757\u51cf\u5c11\u4e0a\u4e0b\u6587\u5207\u6362\n<\/li>\n<li><strong>\u8bfb\u5199\u5206\u79bb<\/strong>\uff1a\u7528<code>StampedLock<\/code>\u66ff\u4ee3<code>synchronized<\/code>\uff0c\u652f\u6301\u4e50\u89c2\u8bfb\n<\/li>\n<li><strong>\u65e0\u9501\u6570\u636e\u7ed3\u6784<\/strong>\uff1a\u4f18\u5148\u4f7f\u7528<code>ConcurrentHashMap<\/code>\u6216<code>LongAdder<\/code>\n<\/li>\n<li><strong>\u5206\u6bb5\u9501\u8bbe\u8ba1<\/strong>\uff1a\u53c2\u8003<code>ConcurrentHashMap<\/code>\u7684Segment\u601d\u60f3\u62c6\u5206\u70ed\u70b9\u8d44\u6e90\n<\/li>\n<\/ul>\n<h4 id=\"3-\u7ebf\u7a0b\u6c60\u53c2\u6570\u52a8\u6001\u5316\"><strong>3. \u7ebf\u7a0b\u6c60\u53c2\u6570\u52a8\u6001\u5316<\/strong><\/h4>\n<ul>\n<li><strong>\u6839\u636e\u4e1a\u52a1\u7c7b\u578b\u9009\u62e9\u961f\u5217<\/strong>\uff1aCPU\u5bc6\u96c6\u578b\u4efb\u52a1\u4f7f\u7528<code>SynchronousQueue<\/code>\uff0cIO\u5bc6\u96c6\u578b\u91c7\u7528<code>LinkedBlockingQueue<\/code>\n<\/li>\n<li><strong>\u62d2\u7edd\u7b56\u7565\u5347\u7ea7<\/strong>\uff1a\u7528<code>CallerRunsPolicy<\/code>\u66ff\u4ee3\u9ed8\u8ba4\u4e2d\u6b62\u7b56\u7565\uff0c\u907f\u514d\u6d41\u91cf\u6d2a\u5cf0\u65f6\u7ea7\u8054\u6545\u969c\n<\/li>\n<li><strong>\u8fd0\u884c\u65f6\u8c03\u53c2<\/strong>\uff1a\u901a\u8fc7<code>Tomcat<\/code>\u7684<code>ThreadPoolExecutor<\/code>\u6269\u5c55\u63a5\u53e3\u5b9e\u73b0\u52a8\u6001\u6700\u5927\u7ebf\u7a0b\u6570\u8c03\u6574\n<\/li>\n<\/ul>\n<h4 id=\"4-\u8d44\u6e90\u9694\u79bb\u4e0e\u7194\u65ad\"><strong>4. \u8d44\u6e90\u9694\u79bb\u4e0e\u7194\u65ad<\/strong><\/h4>\n<ul>\n<li><strong>Hystrix\u8231\u58c1\u6a21\u5f0f<\/strong>\uff1a\u4e3a\u4e0d\u540c\u4f18\u5148\u7ea7\u7684\u4efb\u52a1\u5206\u914d\u72ec\u7acb\u7ebf\u7a0b\u6c60\n<\/li>\n<li><strong>Sentinel\u70ed\u70b9\u89c4\u5219<\/strong>\uff1a\u5bf9\u9ad8\u9891\u8bbf\u95ee\u7684\u5171\u4eab\u8d44\u6e90\u5b9e\u65bd\u7ebf\u7a0b\u6570\u9650\u6d41\n<\/li>\n<li><strong>\u6570\u636e\u5e93\u8bbf\u95ee\u5206\u6cbb<\/strong>\uff1a\u5c06\u8bfb\u5199\u64cd\u4f5c\u8def\u7531\u5230\u4e0d\u540c\u7684\u8fde\u63a5\u6c60\uff0c\u9632\u6b62\u6162\u67e5\u8be2\u963b\u585e\u5199\u5165\n<\/li>\n<\/ul>\n<h4 id=\"5-\u53ef\u89c2\u6d4b\u6027\u589e\u5f3a\"><strong>5. \u53ef\u89c2\u6d4b\u6027\u589e\u5f3a<\/strong><\/h4>\n<ul>\n<li><strong>\u5206\u5e03\u5f0f\u94fe\u8def\u8ffd\u8e2a<\/strong>\uff1a\u5728<a href=\"https:\/\/www.yunshan.net\/\"   target=\"_blank\" style=\"color:blue\">SkyWalking<\/a>\u6216Zipkin\u4e2d\u6807\u8bb0\u7ebf\u7a0b\u963b\u585e\u8017\u65f6\n<\/li>\n<li><strong>\u667a\u80fd\u9884\u8b66\u89c4\u5219<\/strong>\uff1a\u8bbe\u7f6e\u7ebf\u7a0b\u6c60\u961f\u5217\u9971\u548c\u5ea6&gt;80%\u89e6\u53d1\u4f01\u4e1a\u5fae\u4fe1\u544a\u8b66\n<\/li>\n<li><strong>APM\u6df1\u5ea6\u96c6\u6210<\/strong>\uff1a\u901a\u8fc7Elastic APM\u81ea\u52a8\u6355\u83b7<code>BlockedThreadException<\/code>\n<\/li>\n<\/ul>\n<h4 id=\"6-\u67b6\u6784\u7ea7\u9632\u5fa1\"><strong>6. \u67b6\u6784\u7ea7\u9632\u5fa1<\/strong><\/h4>\n<ul>\n<li><strong>CQRS\u6a21\u5f0f\u89e3\u8026<\/strong>\uff1a\u547d\u4ee4\u67e5\u8be2\u804c\u8d23\u5206\u79bb\uff0c\u907f\u514d\u8bfb\u5199\u9501\u7ade\u4e89\n<\/li>\n<li><strong>\u53cd\u5e94\u5f0f\u7f16\u7a0b\u8303\u578b<\/strong>\uff1a\u91c7\u7528Akka\u6216Vert.x\u6784\u5efa\u54cd\u5e94\u5f0f\u7cfb\u7edf\n<\/li>\n<li><strong>\u670d\u52a1\u7f51\u683c\u8d4b\u80fd<\/strong>\uff1a\u901a\u8fc7Istio\u5b9e\u73b0\u5e94\u7528\u65e0\u611f\u77e5\u7684\u6d41\u91cf\u63a7\u5236\u4e0e\u7194\u65ad\n<\/li>\n<\/ul>\n<hr>\n<h3 id=\"\u56db-\u5de5\u5177\u94fe\u5168\u666f\u56fe\"><strong>\u56db\u3001\u5de5\u5177\u94fe\u5168\u666f\u56fe<\/strong><\/h3>\n<ul>\n<li><strong>\u8bca\u65ad\u5229\u5668<\/strong>\uff1a<code>Arthas<\/code>\uff08\u5728\u7ebf\u8bca\u65ad\uff09\u3001<code>YourKit<\/code>\uff08\u5185\u5b58\/\u9501\u5206\u6790\uff09\u3001<code>fastthread.io<\/code>\uff08\u7ebf\u7a0b\u8f6c\u50a8\u89e3\u6790\uff09\n<\/li>\n<li><strong>\u538b\u6d4b\u5e73\u53f0<\/strong>\uff1a<code>JMeter<\/code>\uff08\u573a\u666f\u6a21\u62df\uff09\u3001<code>Gatling<\/code>\uff08\u9ad8\u5e76\u53d1\u6d4b\u8bd5\uff09\u3001<code>Tcpcopy<\/code>\uff08\u6d41\u91cf\u56de\u653e\uff09\n<\/li>\n<li><strong>\u751f\u4ea7\u76d1\u63a7<\/strong>\uff1a<code>Micrometer<\/code>\uff08\u6307\u6807\u91c7\u96c6\uff09\u3001<code>Pinpoint<\/code>\uff08\u8c03\u7528\u94fe\u8ffd\u8e2a\uff09\u3001`Net<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00\uff1a\u5f53\u7ebf\u4e0a\u670d\u52a1\u7a81\u7136\u54cd\u5e94\u8fdf\u7f13\uff0c\u7528\u6237\u6295\u8bc9\u5982\u6f6e\u6c34\u822c\u6d8c\u6765\u65f6\uff0c\u5f00\u53d1\u56e2\u961f\u6700\u6015\u542c\u5230\u7684\u56db\u4e2a\u5b57\u53ef\u80fd\u5c31\u662f\u201c\u7ebf\u7a0b\u963b\u585e\u201d\u3002\u8fd9\u4e2a\u6f5c\u4f0f\u5728\u4ee3\u7801\u6df1\u5904\u7684\u5e7d\u7075\uff0c\u80fd\u5728\u6beb\u79d2\u95f4\u8ba9\u541e\u5410\u91cf\u9aa4\u964d\u3001CPU\u5f02\u5e38\u6ce2\u52a8\uff0c\u751a\u81f3\u5f15\u53d1\u7ea7\u8054\u5f0f\u7cfb\u7edf\u5d29\u6e83\u3002\u636e\u7edf\u8ba1\uff0c\u7ea637%\u7684Java\u5e94\u7528\u6027\u80fd\u95ee\u9898\u4e0e\u7ebf\u7a0b\u7ba1\u7406\u76f4\u63a5\u76f8\u5173\uff0c\u800c\u5176\u4e2d\u8d85\u8fc760%\u7684\u6545\u969c\u5b9a\u4f4d\u8017\u65f6\u96c6\u4e2d\u5728*\u7ebf\u7a0b\u72b6\u6001\u5206\u6790*\u548c*\u8d44\u6e90\u7ade\u4e89\u6392\u67e5*\u4e0a\u3002\u672c\u6587\u5c06\u6df1\u5165\u5256\u6790\u7ebf\u7a0b\u963b\u585e\u7684\u5178\u578b\u573a\u666f\uff0c\u63d0\u4f9b\u4e00\u5957\u4ece\u9884\u8b66\u5230\u6839\u6cbb\u7684\u5b9e\u6218\u6307\u5357\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u50cf\u5916\u79d1\u624b\u672f\u822c\u7cbe\u51c6\u5b9a\u4f4d\u5e76\u5316\u89e3\u8fd9\u4e00\u9690\u853d\u6740\u624b\u3002 \u4e00\u3001\u7ebf\u7a0b\u963b\u585e\u7684\u672c\u8d28\u4e0e\u5f71\u54cd\u5c42\u7ea7 \u7ebf\u7a0b\u963b\u585e\u5e76\u975e\u5355\u7eaf\u7684\u4ee3\u7801\u7f3a\u9677\uff0c\u800c\u662f\u7cfb\u7edf\u8d44\u6e90\u8c03\u5ea6\u3001\u4e1a\u52a1\u903b\u8f91\u8bbe\u8ba1\u3001\u57fa\u7840\u8bbe\u65bd\u627f\u8f7d\u529b\u7684\u7efc\u5408\u4ea7\u7269\u3002\u5f53\u7ebf\u7a0b\u56e0\u7b49\u5f85\u9501\u91ca\u653e\u3001I\/O\u5b8c\u6210\u6216\u5916\u90e8\u4f9d\u8d56\u54cd\u5e94\u800c\u8fdb\u5165BLOCKED\/WAITING\u72b6\u6001\u65f6\uff0c\u5176\u6301\u6709\u7684\u5185\u5b58\u3001\u8fde\u63a5\u7b49\u8d44\u6e90\u65e0\u6cd5\u91ca\u653e\uff0c\u8f7b\u5219\u5bfc\u81f4\u63a5\u53e3\u5ef6\u8fdf\u4e0a\u5347\uff0c\u91cd\u5219\u89e6\u53d1\u7ebf\u7a0b\u6c60\u6ee1\u8f7d\u540e\u7684\u670d\u52a1\u96ea\u5d29\u3002 \u5178\u578b\u75c7\u72b6\u5305\u62ec\uff1a \u63a5\u53e3TP99\u503c\u975e\u7ebf\u6027\u98d9\u5347\uff0c\u4f46CPU\u5229\u7528\u7387\u4e0d\u5347\u53cd\u964d jstack\u65e5\u5fd7\u4e2d\u51fa\u73b0\u5927\u91cfparking to wait for &lt;0x0000000713b4b8d8&gt;\u72b6\u6001 \u6570\u636e\u5e93\u8fde\u63a5\u6c60\u6d3b\u8dc3\u8fde\u63a5\u6570\u7a81\u7834\u9608\u503c\uff0c\u4f34\u968fConnectionTimeoutException \u4e8c\u3001\u56db\u7ef4\u8bca\u65ad\u6cd5\uff1a\u4ece\u73b0\u8c61\u5230\u6839\u56e0\u7684\u7cbe\u51c6\u5b9a\u4f4d 1. \u7ebf\u7a0b\u72b6\u6001\u5feb\u7167\u5206\u6790 \u901a\u8fc7jstack\u6216arthas thread -n 5\u83b7\u53d6\u7ebf\u7a0b\u8f6c\u50a8\uff0c\u91cd\u70b9\u5173\u6ce8\uff1a \u9501\u7ade\u4e89\u70ed\u70b9\uff1a\u7edf\u8ba1BLOCKED\u72b6\u6001\u7ebf\u7a0b\u7684\u9501\u6301\u6709\u8005\uff0c\u82e5\u67d0\u7ebf\u7a0b\u957f\u671f\u6301\u6709ReentrantLock\u6216synchronized\u76d1\u89c6\u5668\uff0c\u9700\u68c0\u67e5\u9501\u7c92\u5ea6 \u7b49\u5f85\u94fe\u95ed\u73af\uff1a\u8bc6\u522bWAITING\u72b6\u6001\u7684FutureTask\u6216ThreadPoolExecutor$Worker\uff0c\u786e\u8ba4\u662f\u5426\u5b58\u5728\u4efb\u52a1\u4f9d\u8d56\u6b7b\u9501 \u8d44\u6e90\u8017\u5c3d\u5f81\u5146\uff1aTIMED_WAITING (on object monitor)\u7ed3\u5408\u5806\u5185\u5b58\u5206\u6790\uff0c\u6392\u67e5\u5bf9\u8c61\u6c60\u6cc4\u6f0f \/\/ \u793a\u4f8b\uff1aarthas\u5feb\u901f\u5b9a\u4f4d\u963b\u585e\u70b9 watch java.lang.Thread getState &#8216;{params[0].name, returnObj}&#8217; -n 5 2. \u8fd0\u884c\u65f6\u8d44\u6e90\u753b\u50cf \u5229\u7528Prometheus+Grafana\u6784\u5efa\u76d1\u63a7\u77e9\u9635\uff1a \u7ebf\u7a0b\u6c60\u6d3b\u8dc3\u5ea6\uff1athread_pool_active_threads\u4e0equeue_remaining_capacity\u7684\u6bd4\u503c\u8d8570%\u5373\u4eae\u9ec4\u706f \u9501\u6301\u6709\u65f6\u957f\uff1a\u901a\u8fc7Java Flight Recorder\u8bb0\u5f55synchronized\u6216Lock\u7684\u7b49\u5f85\u65f6\u95f4\u5206\u5e03 I\/O\u74f6\u9888\u5b9a\u4f4d\uff1a\u5f53iostat\u663e\u793a\u78c1\u76d8\u5229\u7528\u7387\u6301\u7eed&gt;90%\uff0c\u9700\u68c0\u67e5\u65e5\u5fd7\u6253\u5370\u7b56\u7565\u6216\u6587\u4ef6\u8bfb\u5199\u7f13\u51b2\u533a 3. \u4ee3\u7801\u7ea7\u53cd\u6a21\u5f0f\u8bc6\u522b \u9501\u5d4c\u5957\u9677\u9631\uff1a\u5728\u540c\u4e00\u4e2a\u7ebf\u7a0b\u4e2d\u91cd\u590d\u83b7\u53d6\u4e0d\u53ef\u91cd\u5165\u9501 \u540c\u6b65\u5bb9\u5668\u6ee5\u7528\uff1a\u5728\u591a\u7ebf\u7a0b\u73af\u5883\u4e2d\u76f4\u63a5\u8c03\u7528HashMap\u7684put\u65b9\u6cd5 \u4f2a\u5171\u4eab\u5f15\u53d1\u7f13\u5b58\u884c\u7ade\u4e89\uff1a\u9ad8\u9891\u66f4\u65b0\u7684Volatile\u53d8\u91cf\u672a\u6309@Contended\u5bf9\u9f50 \/\/ \u9519\u8bef\u793a\u4f8b\uff1a\u5728\u5f02\u6b65\u56de\u8c03\u4e2d\u540c\u6b65\u4fee\u6539\u975e\u7ebf\u7a0b\u5b89\u5168\u96c6\u5408 executor.submit(() -&gt; { synchronized (list) { \/\/ [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":34632,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-34631","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-product-news"],"_links":{"self":[{"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/posts\/34631","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/comments?post=34631"}],"version-history":[{"count":1,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/posts\/34631\/revisions"}],"predecessor-version":[{"id":34633,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/posts\/34631\/revisions\/34633"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/media\/34632"}],"wp:attachment":[{"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/media?parent=34631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/categories?post=34631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/tags?post=34631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}