background
With the development of the company, the scale of application services continues to expand, and the original vertical application architecture can no longer meet the product development. Dozens of engineers develop different functions in parallel in one project, and the development efficiency continues to decrease.
As a result, the company began to comprehensively promote the service-oriented process, and concentrated most of the engineers in the team on the service-oriented process. Servitization allows each engineer to develop only in the sub-projects he is responsible for, which improves the efficiency of development, but service-oriented also brings other problems:
- It is impossible to know the running status of each service. For example, what is the current QPS of a certain service? What is its average latency, what is its 99% latency, and what is its 99.9% latency?
- The response time of a certain interface is slow, how to locate which method is causing it?
- Is the load balanced for each service?
- When there is jitter in the service, how to judge whether it is caused by DB, Cache or downstream service?
- What is the DB and Cache response latency?
- How to evaluate the capacity of the service, as the service calls become larger and larger, how many machines does the service need to support? When should the machine be added?
To solve the troubles in the above development, today we introduce a high-performance Java performance monitoring and statistics tool designed for high-concurrency and low-latency applications— MyPerf4J .
scenes to be used
- Quickly locate performance bottlenecks in Java applications in a development environment
- Long-term monitoring of Java application performance metrics in a production environment
characteristic
- High performance: Single thread supports records of 10 million response times per second, and each record takes only 73 nanoseconds
- No intrusion: JavaAgent method is used, no intrusion to the application program, no need to modify the application code
- Low memory: Using memory multiplexing, only a few temporary objects are generated in the entire life cycle, which does not affect the GC of the application
- High precision: Response times are calculated in nanoseconds
- High real-time: Support second-level monitoring, minimum 1 second!
Monitoring indicators
MyPerf4J collects dozens of monitoring indicators for each application, and all monitoring indicators are collected and displayed in real time.
The following is a list of monitoring indicators currently supported by MyPerf4J:
Method
RPS,Count,Avg,Min,Max,StdDev,TP50, TP90, TP95, TP99, TP999, TP9999, TP99999, TP100
Memory
HeapInit,HeapUsed,HeapCommitted,HeapMax,NonHeapInit,NonHeapUsed,NonHeapCommitted,NonHeapMax
JVM GC
CollectCount,CollectTime
JVM Class
Total,Loaded,Unloaded
Quick Start
MyPerf4J uses the JavaAgent configuration method to transparently access the application without any intrusion into the application code.
download
- Download and unzip MyPerf4J-ASM.zip
- Read the extracted README file
- Modify the configuration values of app_name, metrics.log.xxx and filter.packages.include in the extracted MyPerf4J.properties configuration file
MyPerf4J-ASM.zip package: https://github.com/LinShunKang/Objects/blob/master/zips/CN/MyPerf4J-ASM-3.3.0-SNAPSHOT.zip?raw=true
configuration
Add the following two parameters to the JVM startup parameters
-javaagent:/path/to/MyPerf4J-ASM.jar-DMyPerf4JPropFile=/path/to/MyPerf4J.properties
run
Start the application and monitor the log output to /path/to/log/method_metrics.log:
MyPerf4J Method Metrics [2020-01-01 12:49:57, 2020-01-01 12:49:58]Method[6] Type Level TimePercent RPS Avg(ms) Min(ms) Max(ms) StdDev Count TP50 TP90 TP95 TP99 TP999 TP9999
DemoServiceImpl.getId2(long) General Service 322.50% 6524 0.49 0 1 0.50 6524 0 1 1 1 1 1
DemoServiceImpl.getId3(long) General Service 296.10% 4350 0.68 0 1 0.47 4350 1 1 1 1 1 1
DemoServiceImpl.getId4(long) General Service 164.60% 2176 0.76 0 1 0.43 2176 1 1 1 1 1 1
DemoServiceImpl.getId1(long) General Service 0.00% 8704 0.00 0 0 0.00 8704 0 0 0 0 0 0
DemoDAO.getId1(long) DynamicProxy DAO 0.00% 2176 0.00 0 0 0.00 2176 0 0 0 0 0 0
DemoDAO.getId2() DynamicProxy DAO 0.00% 2176 0.00 0 0 0.00 2176 0 0 0 0 0 0
uninstall
Remove the following two parameters in the JVM startup parameters, and restart to uninstall this tool.
-javaagent:/path/to/MyPerf4J-ASM.jar-DMyPerf4JPropFile=/path/to/MyPerf4J.properties
Open source address: github.com/LinShunKang/MyPerf4J