<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    paulwong

    !!21 MOST IMPORTANT JAVA 8 VM OPTIONS FOR SERVERS


      7 KOMMENTARE

    In this video I explain some 21 JVM parameters which are suited for most server applications. If you have any questions, you can read those links below for more information or just ask in the comments section.

    Java server flags video

    I run several Java enterprise server applications. I often wondered – what are the best „default“ JVM settings for a server application to start with in production? I read a lot on the web and tried several things myself and wanted to share what I found out, so far. Links containing more information about JVM optimization can be found here:

    http://blog.sokolenko.me/2014/11/javavm-options-production.html

    http://www.petefreitag.com/articles/gctuning/

    http://stas-blogspot.blogspot.de/2011/07/most-complete-list-of-xx-options-for.html

     

    So let’s start:

    -server

    Use „-server“: All 64-bit JVMs use the server VM as default anyway. This setting generally optimizes the JVM for long running server applications instead of startup time. The JVM will collect more data about the Java byte code during program execution and generate the most efficient machine code via JIT.

    -Xms=<heap size>[g|m|k] -Xmx=<heap size>[g|m|k]

    The „-Xmx/-Xms“ settings specify the maximum and minimum values for the JVM heap memory. For servers, both params should have the same value to avoid heap resizing during runtime. I’ve applications running with 16GB heap sizes without an issue.

    Depending on your application, you will have to try out how much memory will be best suited for your use case.

    -XX:MaxMetaspaceSize=<metaspace size>[g|m|k]

    Java 8 has no „Permanent Generation“ (PermGen) anymore but requires additional „Metaspace“ memory instead. This memory is used, in addition to the heap memory we specified before, for storing class meta data information.

    The default size will be unlimited – I tend to limit MaxMetaspaceSize with a somewhat high value. Just in case something goes wrong with the application, the JVM will not hog all the memory of the server.

    I suggest: Let your application run for a couple of days to get a feeling for how much Metaspace Size it uses normally. Upon next restart of the application set the limit to e.g. double the value.

    -XX:+CMSClassUnloadingEnabled

    Additionally, you might want to allow the JVM to unload classes which are held in memory but no code is pointing to them any more. If your application generates lots of dynamic classes, this is what you want.

    -XX:+UseConcMarkSweepGC

    This option makes the JVM use the ConcurrentMarkSweepGC – It can do much work in parallel to program execution but in some circumstances a „full GC“ with a „STW pause“ might still occur. I’ve read many articles and came to the conclusion that this GC is still the best one for server workloads.

    -XX:+CMSParallelRemarkEnabled

    The option CMSParallelRemarkEnabled means the remarking is done in parallel to program execution – which is what you want if your server has many cores (and most servers do).

     -XX:+UseCMSInitiatingOccupancyOnly  -XX:CMSInitiatingOccupancyFraction=<percent>

    Normally the GC will use heuristics to know when it’s time to clear memory. GC might kick in too late with default settings (causing full-Gcs).
    Some sources say it might be a good idea to disable heuristics altogether and just use generation occupancy to start a CMS collection cycle. Setting values around 70% worked fine for all of my applications and use cases.

    -XX:+ScavengeBeforeFullGC

    The first option tells the GC to first free memory by clearing out the „young generation“ or fairly new objects before doing a full GC.

    -XX:+CMSScavengeBeforeRemark

    CMSScavengeBeforeRemark does attempt a minor collection before the CMS remark phase – thus keeping the remark pause afterwards short.

    -XX:+CMSClassUnloadingEnabled

    The option „-XX:+CMSClassUnloadingEnabled“ here tells the JVM to unload classes, which are not needed any more by the running application. If you deploy war files to an application server like wildfly, tomcat or glassfish without restarting the server after the deployment, this flag is for you.

    -XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses

    The option „-XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses“ is especially important if your application uses RMI (remote method invocation). The usage of RMI will cause the JVM to do a FULL-GC EVERY HOUR! This might be a very bad idea for large heap sizes because the FULL-GC pause might take up to several seconds. It would be better to do a concurrent GC and try to unload unused classes to free up more memory – which is exactly what the second option does.

    -XX:+PrintGCDateStamps -verbose:gc -XX:+PrintGCDetails -Xloggc:"<path to log>"

    These options shown here will write out all GC related information to a specified log file. You can see how well your GC configuration works by looking into it.

    I personally prefer to use the „Visual GC“ plug in for the „Visual VM“ tool to monitor the general JVM and GC behavior.

    -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=<path to dump>`date`.hprof

    When your JVM runs out of memory, you will want to know why. Since the OOM error might be hard to reproduce and you want to get your production server up and running again – you should specify a path for a heap dump. When things have settled down, you can analyze the dump afterwards.

    -Djava.rmi.server.hostname=<external IP> -Dcom.sun.management.jmxremote.port=<port>

    These options will help you to specify an IP and port for JMX – you will need those ports open to connect remotely to a JVM running on a server for tools like VisualVM. You can gain deep insights over cpu and memory usage, gc behaviour, class loading, thread count and usage of your application this way.

    Visual VM
    Lastly, I would like to recommend to you the VisualVM tool which is bundled with the Java 8 JDK. You can use it to gain more insights about your specific application behaviour on the JVM – like cpu and memory usage, thread utilisation and much more.

    Visual GCVisualVM can be extended with a plug in called „Visual GC“. It will briefly show you VERY detailed information about the usage of the young and old generation object spaces. You can easily spot problems with garbage collection simply by analyzing these graphs during application runtime.

    Thank you very much for watching! If you liked the video you might consider giving it a „thumbs up“. If you have any questions – just put them in the comments section. I will reply as quickly as possible.

    -------------------------------------------------------

    -XX:+UseCompressedOops [If Max Heap allocation is less than 32GB]
    This can save a significant amount of memory and this option should already be enabled by default on recent java 8 versions. This option allowes object references to be stored as 32-bit values instead of 64-bit on 64-bit JVMs. This leads to before mentioned memory savings.

    -XX:+AggressiveOpts
    This option will enable performance options which are hoped to become enabled by default in upcoming released of the JVM. This option sets some performance settings but is marked as experimental! So you should only enable it, when you have to possibility to test your application thoroughly before enabling this flag on an production server.

    -XX:+UseStringDeduplication
    Since Java 8 update 20 you can use this option to reduce the memory usage of your application. The JVM will spot identical strings in memory, remove the duplicated and point all references to the remaining, single instance of the string.

    -XX:+UseG1GC
    Will tell the JVM to use the most recent G1 garbage collector. You are trading better application response times (due to shorter gc times with G1) against lower throughput (compared against good old ConcMarkSweepGC / CMS). If your application can deliver more value through short gc times, then G1 is definately better suited. Otherwise on Java 8, I’d recommend sticking with CMS.

    Concerning your Tomcat 8 question, I’d suggest you have a look into it with the „VisualVM“ tool. Look at memory usage, GC times (visual GC plugin), pull and analyse stack traces or thread dumps to find the weak spot. You might also consider attaching a debugger to tomcat to find the bug.



    https://www.maknesium.de/21-most-important-java-8-vm-options-for-servers

    posted on 2020-02-16 22:30 paulwong 閱讀(362) 評論(0)  編輯  收藏 所屬分類: 性能優化JVM

    主站蜘蛛池模板: 亚洲w码欧洲s码免费| 亚洲av永久无码精品秋霞电影秋| 精品久久亚洲中文无码| 免费播放在线日本感人片| 国产乱子影视频上线免费观看| 狠狠色香婷婷久久亚洲精品| 国产在线观看免费观看不卡| 在线观看免费大黄网站| 亚洲AⅤ视频一区二区三区| 亚洲欧洲中文日韩久久AV乱码 | 中文字幕免费观看| 亚洲第一成年网站大全亚洲| 1000部拍拍拍18勿入免费视频下载| 久久亚洲精品人成综合网| 97公开免费视频| 亚洲AV成人无码天堂| 成人免费午夜在线观看| 亚洲AV成人片无码网站| 亚洲国产精品第一区二区三区 | 国产精品免费AV片在线观看| 精品国产一区二区三区免费看| 亚洲精品无码专区在线播放| 亚洲A∨精品一区二区三区| 永久免费A∨片在线观看| 77777_亚洲午夜久久多人| 一本岛v免费不卡一二三区| 亚洲综合色婷婷七月丁香| 国产亚洲一卡2卡3卡4卡新区| 亚洲高清最新av网站| 午夜理伦剧场免费| 久久亚洲精品AB无码播放| 国产成人1024精品免费| 亚洲av成人无码久久精品| 最近中文字幕mv免费高清电影| 自怕偷自怕亚洲精品| 午夜影视在线免费观看| 二区久久国产乱子伦免费精品| 亚洲欧洲日韩综合| 亚洲av片一区二区三区| 免费91最新地址永久入口 | 国产一级一片免费播放|