Introducing MyPerf4J: A High‑Performance Java Monitoring and Statistics Tool
The article presents MyPerf4J, a Java‑agent based, low‑overhead performance monitoring library that provides real‑time metrics such as method latency, QPS, memory usage, GC statistics, and class loading, along with quick‑start instructions, configuration details, and open‑source links for Java backend services.
As companies scale their applications, traditional vertical architectures become insufficient, leading to service‑oriented development where engineers focus on individual services but encounter challenges such as unknown QPS, latency distribution, load balancing, and capacity planning.
To address these pain points, the article introduces MyPerf4J, a high‑performance Java performance monitoring and statistics tool designed for high‑concurrency, low‑latency applications.
Usage Scenarios
Quickly locate performance bottlenecks in development environments.
Continuously monitor performance indicators in production environments.
Key Features
High Performance: Single‑threaded support for up to 10 million records per second, each record costing only 73 ns.
Non‑intrusive: Integrated via JavaAgent, requiring no code changes.
Low Memory: Uses memory reuse to minimize temporary objects and avoid GC impact.
High Precision: Measures response time in nanoseconds.
Real‑time: Supports second‑level monitoring (minimum 1 s interval).
Monitoring Metrics
MyPerf4J collects dozens of real‑time metrics for each application, including:
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 a JavaAgent, making it completely non‑intrusive.
Download
Download and unzip MyPerf4J-ASM.zip .
Read the extracted README file.
Modify MyPerf4J.properties to set app_name , metrics.log.xxx , and filter.packages.include .
Configuration
Add the following JVM startup parameters:
-javaagent:/path/to/MyPerf4J-ASM.jar
-DMyPerf4JPropFile=/path/to/MyPerf4J.propertiesRun
Start the application; monitoring logs are written 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 1
...Uninstall
Remove the two JVM parameters shown above and restart the JVM to unload the tool.
Open‑Source Repository
The project is hosted on GitHub: https://github.com/LinShunKang/MyPerf4J
For further reading, the article lists many related resources on microservice architecture, monitoring, and DDD.
Architect
Professional architect sharing high‑quality architecture insights. Topics include high‑availability, high‑performance, high‑stability architectures, big data, machine learning, Java, system and distributed architecture, AI, and practical large‑scale architecture case studies. Open to ideas‑driven architects who enjoy sharing and learning.
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.