zoukankan      html  css  js  c++  java
  • JVM性能分析利器 JMC 和 JFR

    利用 JMC、JFR,可以实现jvm性能问题的准确定位。
    
    JMC:Java Mission Control
    
    Java Flight Recorder(JFR)之前是一个商业特性,现在可以直接使用
    类比飞机上的黑匣子
    
    
    开发环境中,可以使用VisualVM、JProfiler 图形化工具
    attach到jvm进程上, 采集大量数据 ,对应用性能影响很大,不适合在生产环境使用。 
    
    
    
    某Java应用性能压测,TPS 大致 12000 ,
    突然 TPS 掉到 6000 多 ,并周期性的在 6000 和 8000 之间波动
    经过一系列排查,原来是同事使用 jvisualvm 工具 导致的。
    在 高并发 高负载 的压测场景下 , 
    性能监控分析工具的影响比较大 ,尤其是一些可视化工具 ,耗资源
    java应用压测时可关闭jmx端口
    
    jfr不需要在现有应用上添加额外参数、重启进程等,直接在命令行执行即可实时生效,JVM自带功能,稳定可靠不影响线上应用运行。
    
    
    关于jfr的性能消耗
    Java Flight Recorder (JFR) is a tool for collecting diagnostic 
    and profiling data about a running Java application. 
    It is integrated into the Java Virtual Machine (JVM) and causes almost no performance overhead, 
    so it can be used even in heavily loaded production environments. 
    When default settings are used, both internal testing and customer feedback indicate 
    that performance impact is less than one percent. 
    For some applications, it can be significantly lower. 
    However, for short-running applications (which are not the kind of applications running in production environments), 
    relative startup and warmup times can be larger, 
    which might impact the performance by more than one percent. 
    JFR collects data about the JVM as well as the Java application running on it.   
    
    
    # 检查 标志位 
    jcmd $pid VM.check_commercial_features
    # 先解锁
    jcmd $pid VM.unlock_commercial_features 
    jcmd $pid JFR.start  delay=10s duration=1m filename=xxx.jfr
    
    # name=myrecord settings=my-setting
      
    # delay 延迟启动时间,duration 持续采集时间 1分钟
    # settings 使用指定的采集配置  
    # $JAVA_HOME/jre/lib/jfr  default.jfc profile.jfc
     
    # 
    jcmd $pid JFR.stop name=myrecord 
    
    jmc  打开指定的 jfr 文件
    
    主要包括7部分性能报告,分别是一般信息、内存、代码、线程、I/O、系统、事
    
    
    GC类型,暂停时间,最短暂停时间、平均暂停时间、最长暂停时间
    IO  文件读写 套接字读写
  • 相关阅读:
    20165227 结对编程项目-四则运算 第二周
    第八周学习总结
    20165227 结对编程项目-四则运算 第一周
    20165304第4次实验《Android程序设计》实验报告
    20165304《Java程序设计》第九周学习总结
    20165304实验三
    结对编程练习_四则运算(第二周)
    20165304 实验二 Java面向对象程序设计
    20165304 四则运算
    20165304《Java程序设计》第七周学习总结
  • 原文地址:https://www.cnblogs.com/daomeidan/p/11736539.html
Copyright © 2011-2022 走看看