{"id":270401,"date":"2021-01-11T10:29:43","date_gmt":"2021-01-11T02:29:43","guid":{"rendered":"http:\/\/4563.org\/?p=270401"},"modified":"2021-01-11T10:29:43","modified_gmt":"2021-01-11T02:29:43","slug":"k8s-%e5%ae%b9%e5%99%a8%e9%87%8c-java-%e4%b8%8d%e8%83%bd%e4%bd%bf%e7%94%a8%e6%89%80%e6%9c%89%e7%9a%84%e5%86%85%e5%ad%98%ef%bc%8c%e5%8f%aa%e7%94%a8%e4%ba%86-4-%e5%88%86%e4%b9%8b%e4%b8%80%ef%bc%8c","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=270401","title":{"rendered":"K8s \u5bb9\u5668\u91cc Java \u4e0d\u80fd\u4f7f\u7528\u6240\u6709\u7684\u5185\u5b58\uff0c\u53ea\u7528\u4e86 4 \u5206\u4e4b\u4e00\uff0c\u6c42\u89e3\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  K8s \u5bb9\u5668\u91cc Java \u4e0d\u80fd\u4f7f\u7528\u6240\u6709\u7684\u5185\u5b58\uff0c\u53ea\u7528\u4e86 4 \u5206\u4e4b\u4e00\uff0c\u6c42\u89e3\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zealinux <\/span>  <span><i><\/i> 6<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>k8s \u91cc\u8bbe\u7f6e pod limit 2Gi \u4f46\u5b9e\u9645\u53ea\u7528\u4e86 500M\uff0c\u5c31 Full GC \u4e86\u3002<\/p>\n<pre><code>java -version openjdk version \"1.8.0_212\" OpenJDK Runtime Environment (IcedTea 3.12.0) (Alpine 8.212.04-r0) OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)   \u542f\u52a8\u547d\u4ee4 java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap  -Dserver.port=18101 -Djava.security.egd=file:\/dev\/.\/urandom -jar \/u\/app\/advert-api.jar --spring.profiles.active=prd <\/code><\/pre>\n<p>\u6211\u52a0\u4e0a\u4e86<code>-XX:MaxRAMFraction=2<\/code>\u8fd8\u662f\u4e00\u6837\u53ea\u4f7f\u7528 500M<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>9<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4799815\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wysnylc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             jvm \u52a0\u5185\u5b58\u96be\u9053\u4e0d\u662f\u7528-Xmx??????<br \/>\u6ca1\u6709\u914d\u624d\u9ed8\u8ba4\u4f7f\u7528 1\/4 \u5185\u5b58                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4799816\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : tangweiwownb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u52a0\u4e0a-Xms -Xmx \u5440                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4799817\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zealic <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             -XX:MaxRAMPercentage=75.0                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4799818\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : WispZhan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5efa\u8bae\u5148\u5b66\u597d Java\uff0c\u518d\u5b66 K8s \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4799819\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : WispZhan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u9762\u8bd5\u6700\u5e38\u89c1\u7684\u95ee\u9898\uff0cJvm \u7684\u5185\u5b58\u6784\u6210\u662f\u5565\uff0c \u5982\u4f55\u8c03\u6574 JVM \u5185\u5b58\u53c2\u6570\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4799820\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yplove156 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u9047\u5230\u8fc7\u4e00\u4e2a\u7c7b\u4f3c\u7684\u95ee\u9898\uff0c\u4f60\u53ef\u4ee5\u53c2\u8003\u4e0b\uff0ck8s \u7684 limit \u9650\u5236\u5728 jdk8 \u4e0a\u6709\u4e00\u5b9a\u7684\u7f3a\u9677\uff0c\u652f\u6301\u4e0d\u662f\u5f88\u597d\uff0c\u6709\u51e0\u79cd\u89e3\u51b3\u65b9\u5f0f\uff0c\u5347\u7ea7 jdk \u5230 11\uff0c\u8fd8\u6709\u4e00\u79cd\u89e3\u51b3\u65b9\u5f0f\uff0climit \u7684\u9650\u5236\u5927\u5c0f\u5728\u4f1a\u5728\u5bb9\u5668\u91cc\u9762\u6709\u4e2a\u6587\u4ef6\u8bb0\u5f55\uff0c\u5177\u4f53\u4f4d\u7f6e\u5fd8\u4e86\uff0c\u53ef\u4ee5\u767e\u5ea6\u4e0b\uff0c\u5728\u6267\u884c java -jar \u4e4b\u524d\uff0c\u5148\u8bfb\u53d6\u8fd9\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u518d\u628a\u5185\u5bb9\u653e\u5230\u542f\u52a8\u53c2\u6570\uff08\u6700\u5927\u5185\u5b58\u53c2\u6570\uff09\u91cc\u9762\uff0c\u5c31\u53ef\u4ee5\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4799821\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : v2orz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u8fd9\u51e0\u4e2a jvm \u53c2\u6570\u5927\u6982\u7387\u662f\u767e\u5ea6-&gt;csdn \u8fd9\u6837\u6765\u7684<br \/>\u56de\u4e0a\u51e0\u4f4d\u5144\u5f1f\u7684\u56de\u7b54\uff0c\u5728\u5bb9\u5668\u91cc\u9762\u8bbe\u7f6e Xmx \u548c Xms \u662f\u4e00\u4e2a\u4e0d\u592a&#8221;\u6070\u5f53&#8221;\u7684\u4f7f\u7528\u65b9\u5f0f<\/p>\n<p>\u8bf7\u53c2\u8003\u4ee5\u4e0b\uff1a<br \/>&#8220;JDK 10 \u4e4b\u540e\u5f15\u5165\u4e86\u9ed8\u8ba4\u5f00\u542f\u7684\u53c2\u6570 `UseContainerSupport` \u540c\u65f6\u8fd9\u4e2a\u7279\u6027\u4e5f\u88ab backport \u5230 JDK1.8 \u7684 8u191 \u7248\u672c\u3002\u4e5f\u5c31\u662f\u8bf4 8u191 \u548c\u66f4\u540e\u9762\u7684 JDK \u90fd\u53ef\u4ee5\u901a\u8fc7\u5f00\u542f `UseContainerSupport` \u6765\u652f\u6301 cgroup \u770b\u5230 cgroup \u7684\u5185\u5b58\u9650\u5236\uff0c\u518d\u7ed3\u5408 MaxRAMPercentage \u6765\u52a8\u6001\u7b97\u4e00\u4e2a\u5806\u5185\u5b58\u4e0a\u9650\u5c31\u8db3\u591f\u4e86\uff0c\u8fd9\u4e2a\u503c\u5177\u4f53\u770b\u670d\u52a1\u7528\u5230\u7684\u5806\u5916\u5185\u5b58\u548c\u7ebf\u7a0b\u7684\u4f7f\u7528\u91cf\uff0c\u4e00\u822c\u65e0\u8111\u7ed9\u4e2a 75\/80 \u90fd\u6ca1\u95ee\u9898\u3002&#8221;<\/p>\n<p>\u4f5c\u8005\uff1a\u674e\u98d8\u67d4<br \/>\u94fe\u63a5\uff1a https:\/\/www.zhihu.com\/question\/315793102\/answer\/1639340828<br \/>\u6765\u6e90\uff1a\u77e5\u4e4e                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4799822\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rrzwxq <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u521a\u597d\u770b\u8fc7\u8fd9\u65b9\u9762\u7684\u8d44\u6599\uff0c\u56de\u7b54\u4e00\u4e0b<br \/>\u5728 191 \u7248\u672c\u540e\uff0c-XX:{Min|Max}RAMFraction \u88ab\u5f03\u7528\uff0c\u5f15\u5165\u4e86-XX:MaxRAMPercentage\uff0c\u5176\u503c\u4ecb\u4e8e 0.0 \u5230 100.0 \u4e4b\u95f4\uff0c\u9ed8\u8ba4\u503c\u4e3a 25.0\uff0c<br \/>\u6240\u4ee5\u4f60\u8bbe\u7f6e\u7684\u8fd9\u4e2a\u503c\u6ca1\u7528-XX:MaxRAMFraction=2\uff0c\u53ef\u4ee5\u5c1d\u8bd5-XX:MaxRAMPercentage<\/p>\n<p>\u9898\u5916\u8bdd\uff1a\u4e2d\u6587 IT \u8bba\u575b\u91cc\u9762\uff0c\u9047\u5230\u522b\u4eba\u63d0\u95ee\u7684\u5e16\u5b50\u65f6\uff0c\u7ecf\u5e38\u9047\u5230\u5927\u91cf\u5145\u6ee1\u623e\u6c14\u7684\u51b7\u5632\u70ed\u8bbd\u56de\u7b54\uff0c\u8fd9\u7c7b\u4eba\u4e0a\u6765\u4e0d\u662f\u5e2e\u52a9\u522b\u4eba\u89e3\u7b54\u95ee\u9898\uff0c\u800c\u662f\u4ece\u63d0\u95ee\u8005\u63d0\u95ee\u7684\u89d2\u5ea6\u5439\u6bdb\u6c42\u75b5\uff0c\u6307\u51fa\u63d0\u95ee\u8005\u5e94\u8be5\u8fd9\u6837\u53c8\u6216\u8005\u662f\u90a3\u6837\uff0c\u5148\u5b66\u5b66\u8fd9\u4e2a\uff0c\u5148\u5b66\u5b66\u90a3\u4e2a\uff0c\u53c8\u6216\u662f\u5efa\u8bae\u522b\u4eba\u5148\u767e\u5ea6\u6216\u8c37\u6b4c\uff0c\u8bdd\u91cc\u884c\u95f4\u900f\u9732\u51fa\u4e00\u79cd\u524d\u8f88\u7684\u4f18\u8d8a\u611f\uff0c\u95ee\u4e00\u4e0b\u4f60\u600e\u4e48\u77e5\u9053\u522b\u4eba\u6ca1\u641c\u7d22\u8fc7\uff1f<\/p>\n<p>\u6211\u5728\u82f1\u6587\u8bba\u575b\u91cc\u9762\u8fd9\u6837\u7684\u884c\u4e3a\u89c1\u5f97\u4e0d\u662f\u5f88\u591a\uff0c\u5982\u679c\u4e0d\u613f\u610f\u56de\u7b54\u522b\u4eba\uff0c\u89c9\u5f97\u95ee\u9898\u7b80\u5355\u5927\u53ef\u4e0d\u5fc5\u56de\u7b54\u5c31\u597d\uff0c\u4e3a\u4ec0\u4e48\u8981\u7528\u8fd9\u79cd\u9634\u9633\u602a\u6c14\u5f97\u8bdd\u6765\u56de\u7b54\u5462\uff1f\u8fd9\u6837\u6709\u52a9\u4e8e\u5e2e\u52a9\u89e3\u51b3\u4ec0\u4e48\u95ee\u9898\u5417\uff1f\u65e2\u7136\u8981\u522b\u4eba\u5148\u5b66\u4e60\u597d\u8fd9\u4e2a\uff0c\u5b66\u597d\u90a3\u4e2a\uff0c\u90a3\u522b\u4eba\u63d0\u8fd9\u4e2a\u95ee\u9898\u4e0d\u5c31\u662f\u6b63\u662f\u5b66\u4e60\u7684\u8fc7\u7a0b\u5417\uff1f<\/p>\n<p>\u6211\u89c9\u5f97\u6211\u4eec\u8fd8\u662f\u7f3a\u4e4f\u5305\u5bb9\u5fc3\uff0c\u540c\u7406\u5fc3\uff0c\u7f3a\u4e4f\u60f3\u8981\u521b\u9020\u4e00\u4e2a\u66f4\u597d\u7684\u793e\u533a\u7684\u613f\u671b                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4799823\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : YouLMAO <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u662f\u7f3a\u4e4f\u540c\u7406\u5fc3, \u800c\u662f\u91ce\u8def\u5b50\u57f9\u8bad\u73ed\u51e0\u5341\u4e07\u5e74\u85aa\u51fa\u8eab\u7684\u7a0b\u5e8f\u5458\u592a\u591a\u4e86, \u8981\u662f\u6e05\u534e\u672c\u79d1, MIT \u535a\u58eb\u4f1a\u4e71\u55b7\u4e48, \u76f4\u63a5\u6253\u51fa\u6807\u51c6\u7b54\u6848                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>K8s \u5bb9\u5668\u91cc Java \u4e0d\u80fd\u4f7f\u7528&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/270401"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=270401"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/270401\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=270401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=270401"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=270401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}