Boost Java App Performance with MyPerf4J: High‑Throughput, Low‑Latency Monitoring
MyPerf4J is a high‑performance, non‑intrusive Java Agent that records millions of method calls per second with nanosecond precision, offering real‑time metrics, low memory overhead, and comprehensive monitoring for both development and production environments.
Background
As the company grew, the vertical application architecture could no longer meet product development needs; dozens of engineers working on a single project reduced development efficiency.
The company therefore pushed a service‑oriented approach, improving efficiency but introducing new challenges such as unknown service QPS, latency distribution, load balancing, and root‑cause analysis of performance issues.
To address these pains, we introduce a high‑concurrency, low‑latency Java performance monitoring and statistics tool— MyPerf4J .
Use Cases
Quickly locate performance bottlenecks in Java applications during development.
Continuously monitor performance metrics of Java applications in production.
Features
High Performance: Single‑threaded support for 10 million records per second, each record costing only 73 ns.
Non‑Intrusive: Implemented via JavaAgent, requiring no code changes.
Low Memory: Uses object reuse to minimize temporary objects and avoid GC impact.
High Precision: Measures response time in nanoseconds.
Real‑Time: Supports second‑level monitoring, minimum interval 1 second.
Monitoring Metrics
MyPerf4J collects dozens of real‑time metrics for each application.
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 is integrated via JavaAgent, requiring no code changes.
Download
Download and unzip
MyPerf4J-ASM.zip.
Read the extracted
READMEfile.
Modify
MyPerf4J.propertiesto set
app_name,
metrics.log.xxx, and
filter.packages.include.
Download link: https://github.com/LinShunKang/Objects/blob/master/zips/CN/MyPerf4J-ASM-3.3.0-SNAPSHOT.zip?raw=true
Configuration
Add the following JVM startup parameters:
<code>-javaagent:/path/to/MyPerf4J-ASM.jar
-DMyPerf4JPropFile=/path/to/MyPerf4J.properties
</code>Run
Start the application; monitoring logs are written to
/path/to/log/method_metrics.log:
<code>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
</code>Uninstall
Remove the two JVM parameters and restart the application.
<code>-javaagent:/path/to/MyPerf4J-ASM.jar
-DMyPerf4JPropFile=/path/to/MyPerf4J.properties
</code>Project Repository
https://github.com/LinShunKang/MyPerf4Jmacrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.