{"id":10008220,"date":"2023-09-04T10:01:01","date_gmt":"2023-09-04T02:01:01","guid":{"rendered":"https:\/\/blog.itmax.cn\/?p=10008220"},"modified":"2023-09-04T10:01:01","modified_gmt":"2023-09-04T02:01:01","slug":"%e7%82%b9%e4%ba%86%e4%b8%8b%e8%af%a6%e6%83%85%e7%b3%bb%e7%bb%9f%ef%bc%8ccpu-100%ef%bc%85%e3%80%82%e3%80%82%e3%80%82","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10008220","title":{"rendered":"\u70b9\u4e86\u4e0b\u8be6\u60c5\u7cfb\u7edf\uff0cCPU 100\uff05\u3002\u3002\u3002"},"content":{"rendered":"<p>\u4f5c\u8005\uff1a\u739b\u5947\u739b \/<br \/>\u94fe\u63a5\uff1a<a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=jRbfxdXnG8WJs1SRmdZPSw%3D%3D.S8NVu9ZcXXNoM7BP0%2FLAfR1mE%2BOYBaNIJ1Z5C4ChvoP4c2NyE4MGOeqtjqzEGVKV\" rel=\"noopener noreferrer\">https:\/\/juejin.cn\/post\/7233307834456129593<\/a><\/p>\n<p>\u53c8\u662f\u4e00\u4e2a\u767e\u65e0\u804a\u8d56\u7684\u65e9\u6668\uff0c\u6211\u5728\u5feb\u4e50\u5730\u6478\u9c7c\uff0c\u5de5\u4f5c\u7fa4\u54cd\u4e86\uff1a\u79bb\u7ebf\u7cfb\u7edf\u767b\u5f55\u4e0d\u4e0a\u4e86\u3002\u6211\u7b2c\u4e00\u53cd\u5e94\u662f\u4e0d\u79d1\u5b66\u554a\uff0c\u7cfb\u7edf\u5df2\u7ecf\u5f88\u4e45\u6539\u52a8\u8fc7\u4e86&#8230;\u8d76\u7d27\u4e0a\u751f\u4ea7\u73af\u5883\u770b\u770b\uff0cCPU\u9ad8\u8fbe1200%\u3002\u63a5\u7740\u53c8\u662f\u719f\u7ec3\u5730\u6572\u51fa\u90a3\u51e0\u884c\u6392\u67e5CPU\u8fc7\u9ad8\u7684\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"css\">top -H -p  pid\u3000\u67e5\u770bjava\u5360\u7528\u7387\u6700\u9ad8\u7684\u51e0\u6761\u7ebf\u7a0b\njstack pid &gt;  xxx.txt   \u6253\u5370\u7ebf\u7a0b\u5feb\u7167\njmap -heap pid   \u67e5\u770b\u5806\u5185\u5b58\u60c5\u51b5<\/code><\/pre>\n<p>\u63a8\u8350\u4e00\u4e2a\u5f00\u6e90\u514d\u8d39\u7684 Spring Boot \u5b9e\u6218\u9879\u76ee\uff1a<\/p>\n<blockquote><p><a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=EtFeuRy1NDLQz9k6DSexgw%3D%3D.fWGTJ1vDJI5jLAedyDtfjQizHiNDt6%2BmatQzgjB3lsGM6PFUVZZzADv2ngqqM0siHPBPZBA8TFU0BDxUwKIoZA%3D%3D\" rel=\"noopener noreferrer\">https:\/\/github.com\/javastacks\/spring-boot-best-practice<\/a><\/p><\/blockquote>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"692\" height=\"435\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc9wQY\" alt=\"\" title=\"\"><\/p>\n<p><img decoding=\"async\" width=\"692\" height=\"328\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc9wQZ\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p><img decoding=\"async\" width=\"692\" height=\"701\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc9wQ0\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u770b\u8fd9\u73a9\u610f\u5565\u90fd\u770b\u4e0d\u51fa\u6765\uff0c\u611f\u89c9\u662f\u7cfb\u7edf\u5bf9\u8c61\u6ca1\u6709\u91ca\u653e\uff0c\u5728\u75af\u72c2GC\uff0c\u4f46\u662f\u56e0\u4e3aFULL GC\u7684\u65f6\u5019\u5df2\u7ecfSTW\u4e86\uff0c\u6240\u4ee5\u65e0\u6cd5\u67e5\u770b\u5230\u5e95\u662f\u54ea\u4e2a\u7ebf\u7a0b\u51fa\u4e86\u95ee\u9898\u3002\u7136\u540e\u8fc7\u4e8610\u5206\u949f\u7cfb\u7edf\u7a81\u7136\u53c8\u597d\u4e86&#8230;.\u5835\u585e\u7684\u64cd\u4f5c\u5df2\u7ecf\u5b8c\u6210\uff0cgc\u80fd\u6b63\u5e38\u56de\u6536\u4e86\u3002 \u7136\u540e\u8fc7\u4e86\u4e24\u5206\u949f\u53c8\u5361\u6b7b\u4e86\uff0c\u6211\u5148\u91cd\u542f\u4e86\u7cfb\u7edf\uff0c\u540e\u9762\u518d\u5206\u6790\u5206\u6790\u3002<\/p>\n<p>\u7b49\u7cfb\u7edf\u6ca1\u4ec0\u4e48\u4eba\u7528\u7684\u65f6\u5019\uff0c\u6211\u518d\u8bd5\u7740\u91cd\u73b0\u4e00\u4e0b\u95ee\u9898\uff0c\u6253\u5f00\u7cfb\u7edf\u4e00\u987f\u4e71\u70b9\uff0c\u7ed3\u679c\u662f\u70b9\u5f00\u67d0\u4e2a\u529f\u80fd\u7684\u8be6\u60c5\u65f6\u7cfb\u7edf\u5361\u4f4f\u4e86\uff0cCPU\u53c8\u98da\u4e0a\u53bb\u4e86\uff0c\u559c\u95fb\u4e50\u89c1~\u95ee\u9898\u5b9a\u4f4d\u5230\u4e86\uff0c\u518d\u5b9e\u9524\u4e00\u4e0b\u4e4b\u524d\u662f\u4e0d\u662f\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u770b\u4e86\u4e00\u4e0blocalhost_access_log\u65e5\u5fd7\u53d1\u73b0\uff0c\u786e\u5b9e\u662f\u8fd9\u4e2a\u63a5\u53e3\u5361\u4e86\u4e00\u5343\u591a\u79d2\u3002<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"279\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc9wQ1\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u56e0\u4e3a\u79bb\u7ebf\u6ca1\u4ec0\u4e48\u4eba\u4f7f\u7528\uff0c\u6240\u4ee5\u95ee\u9898\u8fc7\u4e86\u5f88\u4e45\u518d\u66b4\u9732\u51fa\u6765\uff0c\u770b\u4e86\u4e00\u4e0b\u4ee3\u7801\uff0c\u4e3b\u8981\u662f\u4e1a\u52a1\u903b\u8f91\u95ee\u9898\uff0c\u6709\u4e2a\u53c2\u6570\u6ca1\u4f20\u8fdb\u53bb\uff0c\u5bfc\u81f4sql\u8981\u67e5\u5f88\u4e45\uff0c\u67e5\u5230\u4e86\u51e0\u767e\u4e07\u7684\u6570\u636e\uff0cgc\u4e5f\u65e0\u6cd5\u56de\u6536\u3002<\/p>\n<h4>\u590d\u76d8<\/h4>\n<p>\u4e00\u5f00\u59cb\u6211\u4ee5\u4e3a\u662f\u67d0\u4e2a\u63a5\u53e3\u8c03\u4e86\u5f88\u591a\u6b21\u5e76\u53d1\u592a\u9ad8\u5bfc\u81f4\u7684\uff0c\u6ca1\u60f3\u5230\u70b9\u4e00\u4e0b\u8be6\u60c5\u7cfb\u7edf\u5c31\u6302\u4e86\u3002\u3002\u6211\u4eec\u53ef\u4ee5\u770b\u5230CPU\u5728GC\u56de\u6536\u7684\u65f6\u5019STW\uff0c\u662f\u6ca1\u6709\u7ebf\u7a0b\u80fd\u5360\u7528\u5230CPU\u7684\uff0c\u6240\u4ee5top -H -p  pid \u53ea\u80fd\u770b\u5230CPU\u5168\u88abGC\u7ebf\u7a0b\u5360\u7528\u4e86\u3002\u5982\u679c\u662f\u67d0\u4e2a\u63a5\u53e3\u5e76\u53d1\u592a\u9ad8\u5bfc\u81f4\u7684\uff0c\u6211\u4eec\u53ef\u4ee5\u770bjstack\u7ebf\u7a0b\u5feb\u7167\uff0c\u91cc\u9762\u662f\u4f1a\u6709\u8fd9\u4e2a\u63a5\u53e3\u5728\u6267\u884c\u7684\u8bb0\u5f55\u3002<\/p>\n<p>\u8fd8\u6709\u4e00\u4e2a\u95ee\u9898\u5c31\u662f\u8bf4\u7cfb\u7edfGC\u5361\u4e8610-20\u5206\u949f\uff0c\u5374\u6ca1\u6709\u62a5OOM\uff0c\u8fd8\u662f\u4e00\u76f4\u5728\u5835\u585e\u72b6\u6001\uff0c\u540e\u9762\u8fd8\u6b63\u5e38\u4e86\u4e00\u5c0f\u4f1a\uff0c\u8fd9\u4e2a\u662f\u9700\u8981\u770b\u5806\u5185\u5b58\u7684\u60c5\u51b5..\u56e0\u4e3a\u6bd4\u8f83\u96be\u6392\u67e5\u6240\u4ee5\u53ea\u662f\u901a\u8fc7\u73b0\u8c61\u77e5\u9053GC\u8fd8\u662f\u53ef\u4ee5\u56de\u6536\u4e00\u70b9\u70b9\u5783\u573e\u7684<\/p>\n<h4>\u603b\u7ed3<\/h4>\n<p>1\u3001CPU100%\u7684\u65f6\u5019\u53ef\u4ee5\u6253\u5370\u7ebf\u7a0b\u5feb\u7167jstack pid\uff0c\u67e5\u770b\u662f\u54ea\u4e2a\u7ebf\u7a0b\u5360\u7528\u4e86CPU\uff0c\u4e00\u822c\u90fd\u662f\u67d0\u4e2a\u4e1a\u52a1\u7ebf\u7a0b\u963b\u585e\u65e0\u6cd5\u8fdb\u884cGC\u56de\u6536\u5bfc\u81f4\u3002<\/p>\n<p>2\u3001\u53ef\u4ee5\u67e5\u770blocalhost_access_log\u67e5\u770b\u7cfb\u7edf\u63a5\u53e3\u7528\u65f6\uff0c\u4e00\u822c\u7528\u65f6\u5f88\u4e45\u7684\u90fd\u662f\u6709\u95ee\u9898\u7684\u63a5\u53e3\u3002<\/p>\n<p>3\u3001\u8bb0\u5f97\u770b\u4e1a\u52a1\u4ee3\u7801\u53c2\u6570\u6709\u6ca1\u6709\u6f0f\u4f20\uff0c\u5982\u679c\u6f0f\u4f20\u53c2\u6570\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5168\u8868\u626b\u63cf\u76f4\u63a5\u5361\u6b7b\u7cfb\u7edf\u3002<\/p>\n<p><strong>\u8fd1\u671f\u70ed\u6587\u63a8\u8350\uff1a<\/strong><\/p>\n<p>1.<a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=317xtjyzATFhBxHX3eQsQw%3D%3D.G8BI2JkAkr04GstlnOgoCrmC%2Fna0U7Cs0IthvwQ8Ydc%3D\" rel=\"noopener noreferrer\">1,000+ \u9053 Java\u9762\u8bd5\u9898\u53ca\u7b54\u6848\u6574\u7406(2022\u6700\u65b0\u7248)<\/a><\/p>\n<p>2.<a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=I0esv%2Fcl1ijJ9m4CPUeTqQ%3D%3D.fqJ866SPDPCCcl6q9b7iUc5HuVur8RFUic8NQp3H8VADZkfTP6bQN6sv1VFVTzpVYYMoUPpgxibZTKLLbONVSg%3D%3D\" rel=\"noopener noreferrer\">\u52b2\u7206\uff01Java \u534f\u7a0b\u8981\u6765\u4e86\u3002\u3002\u3002<\/a><\/p>\n<p>3.<a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=N45Mq0iDGRViUEyvqoAPkw%3D%3D.1xnE6CK%2B8UhoaY1%2FBDraSxlq2P65ivsXg9DLQhtRixUcph23PVyRnTgZbUpi1PFc\" rel=\"noopener noreferrer\">Spring Boot 2.x \u6559\u7a0b\uff0c\u592a\u5168\u4e86\uff01<\/a><\/p>\n<p>4.<a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=j4p6K5SR2i9SBawGSX9U5w%3D%3D.Xa%2FxMvtSCn%2FNLN6L3LubAx3yYB9C%2FjvS9TpUCkFoCZoVwtwXGsfFkEUoCIJ23iiHFHoNFIJDjdG1Q3krXOwBqg%3D%3D\" rel=\"noopener noreferrer\">\u522b\u518d\u5199\u6ee1\u5c4f\u7684\u7206\u7206\u7206\u70b8\u7c7b\u4e86\uff0c\u8bd5\u8bd5\u88c5\u9970\u5668\u6a21\u5f0f\uff0c\u8fd9\u624d\u662f\u4f18\u96c5\u7684\u65b9\u5f0f\uff01\uff01<\/a><\/p>\n<p>5.<a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=ZmIWO6WM8ThTmiz9NnExxQ%3D%3D.4Se5YHHi6BcVJqYjHMJu%2F7eiL7rRsZxKNK5JBNb3GsEj3P0WvGMuNgCOWOxLRApEg0qzsmUS0jH0Y8J6DhylQGOspdx%2BiUAFYN5E5Izm%2FVQ%3D\" rel=\"noopener noreferrer\">\u300aJava\u5f00\u53d1\u624b\u518c\uff08\u5d69\u5c71\u7248\uff09\u300b\u6700\u65b0\u53d1\u5e03\uff0c\u901f\u901f\u4e0b\u8f7d\uff01<\/a><\/p>\n<p>\u89c9\u5f97\u4e0d\u9519\uff0c\u522b\u5fd8\u4e86\u968f\u624b\u70b9\u8d5e+\u8f6c\u53d1\u54e6\uff01<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000044177906\">https:\/\/segmentfault.com\/a\/1190000044177906<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1a\u739b\u5947\u739b \/\u94fe\u63a5\uff1ahttps:\/\/juejin.cn\/post\/7233307834456129593 \u53c8 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10008220","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10008220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10008220"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10008220\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10008220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10008220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10008220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}