k8s中tomcat項目jvm參數設置

k8s集羣方便了部署。可是也帶來了其餘問題,好比隨着服務不斷的增長,內存+cpu不斷的新增,成本也在增長。tomcat

早期的先後臺項目都採用的是tomcat8做爲服務器容器,對應的jvm配置以下:bash

kubectl get pod -n namespace podName -o yaml服務器

containers:
- env:
  - name: JAVA_OPTS
    value: -server -Xmx3550m -Xms3550m -Xmn2g -Xss256k -Duser.timezone=GMT+8 -XX:+DisableExplicitGC
        -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:LargePageSizeInBytes=128m
        -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70

對應在阿里雲控制檯查看yaml文件:jvm

containers:
  - env:
      - name: JAVA_OPTS
        value: >-
          -server -Xmx3550m -Xms3550m -Xmn2g -Xss256k
          -Duser.timezone=GMT+8 -XX:+DisableExplicitGC
          -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled
          -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods
          -XX:+UseCMSInitiatingOccupancyOnly
          -XX:CMSInitiatingOccupancyFraction=70

再好比更小的配置:阿里雲

kubectl get pod -n namespace2 podName2 -o yamlspa

containers:
- env:
  - name: JAVA_OPTS
    value: -server -Xmx2000m -Xms2000m -Xmn800m -Xss512k -Duser.timezone=GMT+8 -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70

對應阿里雲控制檯的yaml配置:code

containers:
  - env:
    - name: JAVA_OPTS
      value: >-
        -server -Xmx2000m -Xms2000m -Xmn800m -Xss512k
        -Duser.timezone=GMT+8 -XX:+DisableExplicitGC
        -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled
        -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods
        -XX:+UseCMSInitiatingOccupancyOnly
        -XX:CMSInitiatingOccupancyFraction=70

這裏涉及jvm調優。server

相關文章
相關標籤/搜索