Introducing MyPerf4J: A High‑Performance Java Monitoring and Statistics Tool
MyPerf4J is a Java‑agent based, low‑overhead performance monitoring library that provides real‑time method, memory, GC and class metrics for high‑concurrency, low‑latency applications, offering quick start, configurable properties, and detailed statistical reports for both development and production environments.
In response to growing service scale and the limitations of vertical architectures, a company adopted a service‑oriented approach and needed a way to observe each service’s runtime characteristics such as QPS, latency percentiles, load balance, and resource usage.
Background
The shift to micro‑services introduced challenges: unknown per‑service QPS, latency distribution, bottleneck identification, load balancing, and capacity planning.
Use Cases
Rapidly locate performance bottlenecks in a Java application during development.
Continuously monitor performance indicators of Java applications in production.
Key Features
High Performance: Single‑threaded recording supports up to 10 million records per second, each taking only 73 ns.
Non‑Intrusive: Integrated via a JavaAgent, requiring no code changes.
Low Memory Footprint: Uses object reuse to minimize temporary allocations and GC impact.
High Precision: Measures response time in nanoseconds.
Real‑Time: Provides second‑level monitoring (minimum 1 s interval).
Monitoring Metrics
MyPerf4J collects dozens of metrics in real time, grouped by category:
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 delivered as a JavaAgent JAR. To begin:
Download and unzip MyPerf4J-ASM.zip .
Read the extracted README file.
Edit MyPerf4J.properties to set app_name , metrics.log.xxx and filter.packages.include .
Configuration
Add the following JVM arguments:
-javaagent:/path/to/MyPerf4J-ASM.jar
-DMyPerf4JPropFile=/path/to/MyPerf4J.propertiesRun
Start the application; metrics are written to /path/to/log/method_metrics.log in a CSV‑like format, e.g.:
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 arguments and restart the JVM.
Open‑Source Repository
The project is hosted at https://github.com/LinShunKang/MyPerf4J .
For further discussion, readers are invited to join the “Top Architect” community via the provided QR codes.
Top Architect
Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.
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.