一个针对高并发、低延迟应用设计的高性能且无侵入的实时Java性能监控和统计工具。
受 perf4j 和 TProfiler启发而来。
MyPerf4J具备如下几个特性:java
MyPerf4J为每一个应用收集数十个监控指标,全部的监控指标都是实时采集和展示的。git
下面是MyPerf4J目前支持的监控指标列表:github
RPS,Count,Avg,Min,Max,StdDev,TP50, TP90, TP95, TP99, TP999, TP9999, TP99999, TP100spring
TotalStarted,Runnable,Blocked,Waiting,TimedWaiting,Terminated,Active,Peak,Daemon,New并发
HeapInit,HeapUsed,HeapCommitted,HeapMax,NonHeapInit,NonHeapUsed,NonHeapCommitted,NonHeapMax高并发
CollectCount,CollectTime工具
Total,Loaded,Unloaded性能
> 想知道如何实现上述效果?请先按照[快速启动](https://github.com/ThinkpadNC5/MyPerf4J#%E5%BF%AB%E9%80%9F%E5%90%AF%E5%8A%A8)的描述启动应用,再按照[这里](https://github.com/ThinkpadNC5/MyPerf4J/wiki/InfluxDB_)的描述进行安装配置便可。
MyPerf4J采用JavaAgent配置方式,透明化接入应用,对应用代码彻底没有侵入。spa
在JVM启动参数里加上如下两个参数设计
-javaagent:/your/path/to/MyPerf4J-ASM-${MyPerf4J-version}.jar-DMyPerf4JPropFile=/your/path/to/myPerf4J.properties
其中,MyPerf4JPropFile
的配置以下:
#应用名称 AppName=MyPerf4JTest #配置MetricsProcessors,可不配置 #MethodMetricsProcessor=cn.myperf4j.ext.metric.processor.influxdb.InfluxDBMethodMetricsProcessor #ClassMetricsProcessor=cn.myperf4j.ext.metric.processor.influxdb.InfluxDBJvmClassMetricsProcessor #GCMetricsProcessor=cn.myperf4j.ext.metric.processor.influxdb.InfluxDBJvmGCMetricsProcessor #MemMetricsProcessor=cn.myperf4j.ext.metric.processor.influxdb.InfluxDBJvmMemoryMetricsProcessor #ThreadMetricsProcessor=cn.myperf4j.ext.metric.processor.influxdb.InfluxDBJvmThreadMetricsProcessor #配置备份Recorders的数量,默认为1,最小为1,最大为8,当须要在较小MillTimeSlice内统计大量方法性能数据时可配置大一些 BackupRecordersCount=1 #配置Record模式,可配置为accurate/rough RecorderMode=accurate #配置时间片,单位为ms,最小1s,最大600s MillTimeSlice=10000 #须要监控的package,可配置多个,用英文';'分隔 IncludePackages=cn.perf4j.demo #不须要监控的package,可配置多个,用英文';'分隔 ExcludePackages=org.spring; #可配置多个方法名,用英文';'分隔 ExcludeMethods=equals;hash #是否排除私有方法,true/false ExcludePrivateMethod=true #通用的方法执行时间阈值,单位为ms ProfilingTimeThreshold=1000 #在一个时间片内,超过方法执行时间阈值的次数,仅在RecorderMode=accurate时有效 ProfilingOutThresholdCount=10
想了解更多的配置?请看 这里
输出结果,默认输出到stdout.log:
MyPerf4J Performance Statistics [2018-07-01 23:40:23, 2018-07-01 23:40:24] Api[2/3] RPS Avg(ms) Min(ms) Max(ms) StdDev Count TP50 TP90 TP95 TP99 TP999 TP9999 TP99999 TP100 DemoServiceImpl.getId1 7454181 0.00 0 0 0.00 7454181 0 0 0 0 0 0 0 0 DemoServiceImpl.getId2 7454180 0.00 0 0 0.00 7454180 0 0 0 0 0 0 0 0
在JVM启动参数中去掉如下两个参数,重启便可卸载此工具。
-javaagent:/your/path/to/MyPerf4J-ASM.jar-DMyPerf4JPropFile=/your/path/to/myPerf4J.properties
若是您遇到任何问题或有疑问,请您坚决果断的 提交Issue : )
想更深刻的了解MyPerf4J?请看 https://github.com/ThinkpadNC5/MyPerf4J/wiki/Chinese-Doc。