Operations 7 min read

Boost Java Service Performance with MyPerf4J: A High‑Throughput Monitoring Tool

This article introduces MyPerf4J, a Java‑agent based, low‑overhead performance monitoring tool that provides real‑time metrics such as RPS, latency percentiles, memory usage and GC statistics, and explains how to install, configure, run and uninstall it in development and production environments.

Java Backend Technology
Java Backend Technology
Java Backend Technology
Boost Java Service Performance with MyPerf4J: A High‑Throughput Monitoring Tool

Background and Challenges

When a company scales, a monolithic vertical architecture becomes inefficient; many engineers work on a single project, leading to difficulty monitoring runtime data (QPS, latency percentiles), locating slow methods, assessing load balance, and diagnosing jitter sources (DB, cache, downstream services) for capacity planning.

Usage Scenarios

Rapidly locate performance bottlenecks in Java applications during development.

Continuously monitor Java application performance indicators in production.

Key Features

High Performance : Single‑thread recording up to 10 million records per second, each record costs ~73 ns.

Non‑Intrusive : Implemented via a JavaAgent, no code changes required.

Low Memory Footprint : Object reuse minimizes temporary allocations and GC impact.

High Precision : Measures response time in nanoseconds.

Real‑Time : Supports second‑level monitoring (minimum interval 1 s).

Monitoring Metrics

MyPerf4J collects dozens of real‑time metrics per application.

Method metrics : RPS, Count, Avg, Min, Max, StdDev, TP50, TP90, TP95, TP99, TP999, TP9999, TP99999, TP100.

Memory metrics : HeapInit, HeapUsed, HeapCommitted, HeapMax, NonHeapInit, NonHeapUsed, NonHeapCommitted, NonHeapMax.

JVM GC metrics : CollectCount, CollectTime.

JVM Class metrics : Total, Loaded, Unloaded.

Quick Start

Download and unzip MyPerf4J-ASM.zip (e.g.,

https://github.com/LinShunKang/Objects/blob/master/zips/CN/MyPerf4J-ASM-3.3.0-SNAPSHOT.zip?raw=true

).

Read the extracted README file.

Edit MyPerf4J.properties to set app_name, metrics.log.xxx and filter.packages.include as needed.

Configuration

Add the following JVM arguments when starting the application:

-javaagent:/path/to/MyPerf4J-ASM.jar
-DMyPerf4JPropFile=/path/to/MyPerf4J.properties
MyPerf4J dashboard screenshot
MyPerf4J dashboard screenshot

Running

Start the application; performance logs are written to the file configured by /path/to/log/method_metrics.log. Example output:

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   General   Service   322.50%   6524   0.49   0   1   0.50   6524   0   1   1   1   1   1   1
DemoServiceImpl.getId3   General   Service   296.10%   4350   0.68   0   1   0.47   4350   1   1   1   1   1   1   1
...

Uninstall

Remove the two JVM arguments ( -javaagent:/path/to/MyPerf4J-ASM.jar and -DMyPerf4JPropFile=/path/to/MyPerf4J.properties) and restart the application.

Open‑Source Repository

GitHub:

https://github.com/LinShunKang/MyPerf4J
backendJavaMetricsPerformance MonitoringJavaAgentMyPerf4J
Java Backend Technology
Written by

Java Backend Technology

Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.