{"id":10008025,"date":"2023-07-03T10:58:37","date_gmt":"2023-07-03T02:58:37","guid":{"rendered":"https:\/\/ityet.com\/?p=10008025"},"modified":"2023-07-03T10:58:37","modified_gmt":"2023-07-03T02:58:37","slug":"%e7%8b%82%e6%94%b6-3k-star%ef%bc%81%e4%b8%80%e4%b8%aa%e9%ab%98%e6%80%a7%e8%83%bd%e3%80%81%e6%97%a0%e4%be%b5%e5%85%a5%e7%9a%84-java-%e6%80%a7%e8%83%bd%e7%9b%91%e6%8e%a7%e5%92%8c%e7%bb%9f%e8%ae%a1","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10008025","title":{"rendered":"\u72c2\u6536 3K Star\uff01\u4e00\u4e2a\u9ad8\u6027\u80fd\u3001\u65e0\u4fb5\u5165\u7684 Java \u6027\u80fd\u76d1\u63a7\u548c\u7edf\u8ba1\u5de5\u5177\uff0c\u5341\u5206\u5f3a\u608d\uff01"},"content":{"rendered":"<h2>\u80cc\u666f<\/h2>\n<p>\u968f\u7740\u6240\u5728\u516c\u53f8\u7684\u53d1\u5c55\uff0c\u5e94\u7528\u670d\u52a1\u7684\u89c4\u6a21\u4e0d\u65ad\u6269\u5927\uff0c\u539f\u6709\u7684\u5782\u76f4\u5e94\u7528\u67b6\u6784\u5df2\u65e0\u6cd5\u6ee1\u8db3\u4ea7\u54c1\u7684\u53d1\u5c55\uff0c\u51e0\u5341\u4e2a\u5de5\u7a0b\u5e08\u5728\u4e00\u4e2a\u9879\u76ee\u91cc\u5e76\u884c\u5f00\u53d1\u4e0d\u540c\u7684\u529f\u80fd\uff0c\u5f00\u53d1\u6548\u7387\u4e0d\u65ad\u964d\u4f4e\u3002<\/p>\n<p>\u4e8e\u662f\u516c\u53f8\u5f00\u59cb\u5168\u9762\u63a8\u8fdb\u670d\u52a1\u5316\u8fdb\u7a0b\uff0c\u628a\u56e2\u961f\u5185\u7684\u5927\u90e8\u5206\u5de5\u7a0b\u5e08\u4e3b\u8981\u7cbe\u529b\u5168\u90e8\u90fd\u96c6\u4e2d\u5230\u670d\u52a1\u5316\u4e2d\u3002\u670d\u52a1\u5316\u53ef\u4ee5\u8ba9\u6bcf\u4e2a\u5de5\u7a0b\u5e08\u4ec5\u5728\u81ea\u5df1\u8d1f\u8d23\u7684\u5b50\u9879\u76ee\u4e2d\u8fdb\u884c\u5f00\u53d1\uff0c\u63d0\u9ad8\u4e86\u5f00\u53d1\u7684\u6548\u7387\uff0c\u4f46\u662f\u670d\u52a1\u5316\u540c\u65f6\u4e5f\u5e26\u6765\u4e86\u5176\u4ed6\u95ee\u9898\uff1a<\/p>\n<ul>\n<li>\u65e0\u6cd5\u77e5\u9053\u6bcf\u4e2a\u670d\u52a1\u7684\u8fd0\u884c\u60c5\u51b5\uff0c\u4f8b\u5982\uff0c\u67d0\u4e00\u53f0\u670d\u52a1\u5b83\u76ee\u524d\u7684 QPS \u662f\u591a\u5c11\uff1f\u5b83\u7684\u5e73\u5747\u5ef6\u8fdf\u662f\u591a\u5c11\uff0c99% \u7684\u5ef6\u8fdf\u662f\u591a\u5c11\uff0c99.9% \u7684\u5ef6\u8fdf\u53c8\u662f\u591a\u5c11\uff1f<\/li>\n<li>\u67d0\u4e00\u4e2a\u63a5\u53e3\u54cd\u5e94\u65f6\u95f4\u6162\uff0c\u5982\u4f55\u5b9a\u4f4d\u662f\u54ea\u4e2a\u65b9\u6cd5\u5f15\u8d77\u7684\uff1f<\/li>\n<li>\u6bcf\u4e2a\u670d\u52a1\u7684\u8d1f\u8f7d\u662f\u5426\u5747\u8861\uff1f<\/li>\n<li>\u5f53\u670d\u52a1\u51fa\u73b0\u6296\u52a8\u65f6\uff0c\u5982\u4f55\u5224\u65ad\u662f DB\u3001Cache \u8fd8\u662f\u4e0b\u6e38\u670d\u52a1\u5f15\u8d77\u7684\uff1f<\/li>\n<li>DB \u548c Cache \u54cd\u5e94\u5ef6\u8fdf\u662f\u591a\u5c11\uff1f<\/li>\n<li>\u5982\u4f55\u8bc4\u4f30\u670d\u52a1\u7684\u5bb9\u91cf\uff0c\u968f\u7740\u670d\u52a1\u7684\u8c03\u7528\u91cf\u8d8a\u6765\u8d8a\u5927\uff0c\u8fd9\u4e2a\u670d\u52a1\u9700\u8981\u591a\u5c11\u673a\u5668\u6765\u652f\u6491\uff1f\u4ec0\u4e48\u65f6\u5019\u5e94\u8be5\u52a0\u673a\u5668\uff1f<\/li>\n<\/ul>\n<blockquote><p>\u9488\u5bf9\u4ee5\u4e0a\u5f00\u53d1\u4e2d\u7684\u70e6\u607c\uff0c\u4eca\u5929\u6211\u4eec\u4ecb\u7ecd\u4e00\u4e2a\u9488\u5bf9\u9ad8\u5e76\u53d1\u3001\u4f4e\u5ef6\u8fdf\u5e94\u7528\u8bbe\u8ba1\u7684\u9ad8\u6027\u80fd Java \u6027\u80fd\u76d1\u63a7\u548c\u7edf\u8ba1\u5de5\u5177\u2014\u2014<strong>MyPerf4J<\/strong> \u3002<\/p><\/blockquote>\n<p>\u63a8\u8350\u4e00\u4e2a\u5f00\u6e90\u514d\u8d39\u7684 Spring Boot \u5b9e\u6218\u9879\u76ee\uff1a<\/p>\n<blockquote><p><a href=\"https:\/\/link.segmentfault.com\/?enc=xs1EJqpUbbX2nCZF8l8SDg%3D%3D.SiQs0VIVG956yvziWwwuS1DhJI589JtDZnRq7DHm8U1v57f3cRCm6ehyP%2FHEw1%2BjUPmwKQUQtrvP3DrBvZQf%2Fg%3D%3D\" rel=\"nofollow\">https:\/\/github.com\/javastacks\/spring-boot-best-practice<\/a><\/p><\/blockquote>\n<h2>\u4f7f\u7528\u573a\u666f<\/h2>\n<ul>\n<li>\u5728\u5f00\u53d1\u73af\u5883\u4e2d\u5feb\u901f\u5b9a\u4f4d Java \u5e94\u7528\u7a0b\u5e8f\u7684\u6027\u80fd\u74f6\u9888<\/li>\n<li>\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u957f\u671f\u76d1\u63a7 Java \u5e94\u7528\u7a0b\u5e8f\u7684\u6027\u80fd\u6307\u6807<\/li>\n<\/ul>\n<h2>\u7279\u6027<\/h2>\n<ul>\n<li><strong>\u9ad8\u6027\u80fd:<\/strong> \u5355\u7ebf\u7a0b\u652f\u6301\u6bcf\u79d2 1000\u4e07\u6b21 \u54cd\u5e94\u65f6\u95f4\u7684\u8bb0\u5f55\uff0c\u6bcf\u6b21\u8bb0\u5f55\u53ea\u82b1\u8d39 73\u7eb3\u79d2<\/li>\n<li><strong>\u65e0\u4fb5\u5165:<\/strong> \u91c7\u7528 JavaAgent \u65b9\u5f0f\uff0c\u5bf9\u5e94\u7528\u7a0b\u5e8f\u5b8c\u5168\u65e0\u4fb5\u5165\uff0c\u65e0\u9700\u4fee\u6539\u5e94\u7528\u4ee3\u7801<\/li>\n<li><strong>\u4f4e\u5185\u5b58:<\/strong> \u91c7\u7528\u5185\u5b58\u590d\u7528\u7684\u65b9\u5f0f\uff0c\u6574\u4e2a\u751f\u547d\u5468\u671f\u53ea\u4ea7\u751f\u6781\u5c11\u7684\u4e34\u65f6\u5bf9\u8c61\uff0c\u4e0d\u5f71\u54cd\u5e94\u7528\u7a0b\u5e8f\u7684GC<\/li>\n<li><strong>\u9ad8\u7cbe\u5ea6:<\/strong> \u91c7\u7528\u7eb3\u79d2\u6765\u8ba1\u7b97\u54cd\u5e94\u65f6\u95f4<\/li>\n<li><strong>\u9ad8\u5b9e\u65f6:<\/strong> \u652f\u6301\u79d2\u7ea7\u76d1\u63a7\uff0c\u6700\u4f4e 1 \u79d2!<\/li>\n<\/ul>\n<h2>\u76d1\u63a7\u6307\u6807<\/h2>\n<p>MyPerf4J \u4e3a\u6bcf\u4e2a\u5e94\u7528\u6536\u96c6\u6570\u5341\u4e2a\u76d1\u63a7\u6307\u6807\uff0c\u6240\u6709\u7684\u76d1\u63a7\u6307\u6807\u90fd\u662f\u5b9e\u65f6\u91c7\u96c6\u548c\u5c55\u73b0\u7684\u3002<\/p>\n<p>\u4e0b\u9762\u662f MyPerf4J \u76ee\u524d\u652f\u6301\u7684\u76d1\u63a7\u6307\u6807\u5217\u8868:<\/p>\n<h4>Method<\/h4>\n<blockquote><p>RPS\uff0cCount\uff0cAvg\uff0cMin\uff0cMax\uff0cStdDev\uff0cTP50, TP90, TP95, TP99, TP999, TP9999, TP99999, TP100<\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc8CD6\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h4>Memory<\/h4>\n<blockquote><p>HeapInit\uff0cHeapUsed\uff0cHeapCommitted\uff0cHeapMax\uff0cNonHeapInit\uff0cNonHeapUsed\uff0cNonHeapCommitted\uff0cNonHeapMax<\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc8CD7\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h4>JVM GC<\/h4>\n<blockquote><p>CollectCount\uff0cCollectTime<\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc8CD8\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h4>JVM Class<\/h4>\n<blockquote><p>Total\uff0cLoaded\uff0cUnloaded<\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc8CEc\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h2>\u5feb\u901f\u542f\u52a8<\/h2>\n<p>MyPerf4J \u91c7\u7528 JavaAgent \u914d\u7f6e\u65b9\u5f0f\uff0c\u900f\u660e\u5316\u63a5\u5165\u5e94\u7528\uff0c\u5bf9\u5e94\u7528\u4ee3\u7801\u5b8c\u5168\u6ca1\u6709\u4fb5\u5165\u3002<\/p>\n<h4>\u4e0b\u8f7d<\/h4>\n<ul>\n<li>\u4e0b\u8f7d\u5e76\u89e3\u538b MyPerf4J-ASM.zip<\/li>\n<li>\u9605\u8bfb\u89e3\u538b\u51fa\u7684 README \u6587\u4ef6<\/li>\n<li>\u4fee\u6539\u89e3\u538b\u51fa\u7684 MyPerf4J.properties \u914d\u7f6e\u6587\u4ef6\u4e2d <code>app_name<\/code>\u3001<code>metrics.log.xxx<\/code> \u548c <code>filter.packages.include<\/code> \u7684\u914d\u7f6e\u503c<\/li>\n<\/ul>\n<blockquote><p>MyPerf4J-ASM.zip\u5305 \uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=r3dFh4YseNlrJAcSOikwqA%3D%3D.SpUGOOqwYDN6H6zbZxekisG4yKmFKbe5qwQSc%2F6uZvjWB2BOogOgUk0OnEFIwnRoC05ZDLiNckXO19KYVLN4VDn26TT%2Bk3Z2hq9RqlgTmkZXxiQpP%2BI%2FyHOq7uQLutGxqXBvqpM7iBPbjNUT28dtjA%3D%3D\" rel=\"nofollow\">https:\/\/github.com\/LinShunKang\/Objects\/blob\/master\/zips\/CN\/MyPerf4J-ASM-3.3.0-SNAPSHOT.zip?raw=true<\/a><\/p><\/blockquote>\n<h4>\u914d\u7f6e<\/h4>\n<p>\u5728 JVM \u542f\u52a8\u53c2\u6570\u91cc\u52a0\u4e0a\u4ee5\u4e0b\u4e24\u4e2a\u53c2\u6570<\/p>\n<pre><code>-javaagent:\/path\/to\/MyPerf4J-ASM.jar\n-DMyPerf4JPropFile=\/path\/to\/MyPerf4J.properties<\/code><\/pre>\n<h4>\u8fd0\u884c<\/h4>\n<p>\u542f\u52a8\u5e94\u7528\uff0c\u76d1\u63a7\u65e5\u5fd7\u8f93\u51fa\u5230 <code>\/path\/to\/log\/method_metrics.log<\/code>:<\/p>\n<pre><code>MyPerf4J Method Metrics [2020-01-01 12:49:57, 2020-01-01 12:49:58]\nMethod[6]                            Type        Level  TimePercent      RPS  Avg(ms)  Min(ms)  Max(ms)    StdDev    Count     TP50     TP90     TP95     TP99    TP999   TP9999\nDemoServiceImpl.getId2(long)      General      Service      322.50%     6524     0.49        0        1     0.50      6524        0        1        1        1        1        1\nDemoServiceImpl.getId3(long)      General      Service      296.10%     4350     0.68        0        1     0.47      4350        1        1        1        1        1        1\nDemoServiceImpl.getId4(long)      General      Service      164.60%     2176     0.76        0        1     0.43      2176        1        1        1        1        1        1\nDemoServiceImpl.getId1(long)      General      Service        0.00%     8704     0.00        0        0     0.00      8704        0        0        0        0        0        0\nDemoDAO.getId1(long)         DynamicProxy          DAO        0.00%     2176     0.00        0        0     0.00      2176        0        0        0        0        0        0\nDemoDAO.getId2()             DynamicProxy          DAO        0.00%     2176     0.00        0        0     0.00      2176        0        0        0        0        0        0<\/code><\/pre>\n<h4>\u5378\u8f7d<\/h4>\n<p>\u5728 JVM \u542f\u52a8\u53c2\u6570\u4e2d\u53bb\u6389\u4ee5\u4e0b\u4e24\u4e2a\u53c2\u6570\uff0c\u91cd\u542f\u5373\u53ef\u5378\u8f7d\u6b64\u5de5\u5177\u3002<\/p>\n<pre><code>-javaagent:\/path\/to\/MyPerf4J-ASM.jar\n-DMyPerf4JPropFile=\/path\/to\/MyPerf4J.properties<\/code><\/pre>\n<p>\u5f00\u6e90\u5730\u5740\uff1agithub.com\/LinShunKang\/MyPerf4J<\/p>\n<p><strong>\u8fd1\u671f\u70ed\u6587\u63a8\u8350\uff1a<\/strong><\/p>\n<p>1.<a href=\"https:\/\/link.segmentfault.com\/?enc=TgH7vajcc9t2NY0yvpKQ3A%3D%3D.nrkQqy7M5%2BrKfn4V8b8Bwzu0DKuAUfG9C%2Bc0ydahvUQ%3D\" rel=\"nofollow\">1,000+ \u9053 Java\u9762\u8bd5\u9898\u53ca\u7b54\u6848\u6574\u7406(2022\u6700\u65b0\u7248)<\/a><\/p>\n<p>2.<a href=\"https:\/\/link.segmentfault.com\/?enc=dExHt%2BFEDZwa2GN6kahbfA%3D%3D.mlYRdfitvnb3SwpnuDRZqk1x3sHFKZv5Xok4Tt%2BRjFRm7qw194Yi2cBrB70uNKd4rLtgECfgWPD%2Bx2fs5c98JQ%3D%3D\" rel=\"nofollow\">\u52b2\u7206\uff01Java \u534f\u7a0b\u8981\u6765\u4e86\u3002\u3002\u3002<\/a><\/p>\n<p>3.<a href=\"https:\/\/link.segmentfault.com\/?enc=u1s8OVBpy%2FMyPZheMw9wbw%3D%3D.31Io0KRLwkCmqvqaH9qF06OYzXVr%2F6BR7Dr8Qfhwu2j594hrOU32HEO1wcysjJcn\" rel=\"nofollow\">Spring Boot 2.x \u6559\u7a0b\uff0c\u592a\u5168\u4e86\uff01<\/a><\/p>\n<p>4.<a href=\"https:\/\/link.segmentfault.com\/?enc=SnTkemkTfKutwvTDCyAdRw%3D%3D.zg3KpV%2FMicrE%2F0uv7bY3aln5fw9HtURtPYE52GOhK2nVw2eurXPvTvEBvtFo0zjrLkmmEFsmSuTZWhJkqzze%2FQ%3D%3D\" rel=\"nofollow\">\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 href=\"https:\/\/link.segmentfault.com\/?enc=5I7KPc4bjWRArCJ9g%2FvjAw%3D%3D.lM43ATlCB5s7tGCQgo1IJynq95km5zZgM%2Ffyd7jav0XLM86eZoczPtKhyfbhnR9cPLW0vca%2Frdbw2s%2FbEAkD8y6mLm2AILoUbhpRYCttUIw%3D\" rel=\"nofollow\">\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\/1190000043961847\">https:\/\/segmentfault.com\/a\/1190000043961847<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u80cc\u666f \u968f\u7740\u6240\u5728\u516c\u53f8\u7684\u53d1\u5c55\uff0c\u5e94\u7528\u670d\u52a1\u7684\u89c4\u6a21\u4e0d\u65ad\u6269\u5927\uff0c\u539f\u6709\u7684\u5782\u76f4\u5e94\u7528\u67b6\u6784\u5df2\u65e0\u6cd5\u6ee1\u8db3\u4ea7\u54c1\u7684\u53d1\u5c55\uff0c\u51e0\u5341\u4e2a\u5de5\u7a0b\u5e08\u5728\u4e00\u4e2a\u9879 [&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-10008025","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\/10008025","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=10008025"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10008025\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10008025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10008025"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10008025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}