Performance monitoring
Java performance monitoring
Java applications usually slow down in three places: garbage collection, pools that run dry, and the database. Watch all three alongside request latency.
3 min read7 sectionsUpdated
On this page
| Metric | Why it matters | Worry when |
|---|---|---|
| Heap used after GC | The live data set; rising means a leak or growing caches | Climbs steadily across days |
| GC pause time and frequency | Pauses stop request threads | p99 pause above ~200 ms, or GC more than a few percent of time |
| Thread pool active / max | Requests wait when Tomcat or executor threads are all busy | Active near max for minutes |
| JDBC pool active / pending | Requests wait for a database connection | Any sustained pending count |
| CPU (against container limit) | Throttling looks like slowness | Above 80 to 90% of the limit |
| Class loading, threads count | Leaks of threads or classloaders after redeploys | Growing without bound |
Typical Java bottlenecks
- Connection pool starvation: a slow query holds connections, every request waits for HikariCP, and latency jumps across all endpoints at once.
- GC pressure: large allocations per request or a heap sized too close to the live set cause frequent collections and long pauses.
- Blocking calls in reactive code: a blocking JDBC call inside WebFlux stalls the event loop threads.
- N+1 queries from JPA/Hibernate lazy loading; traces show dozens of near-identical SELECT spans. See finding slow database queries.
- Synchronized hot paths and lock contention under load; thread dumps show many threads BLOCKED on the same monitor.
Instrumenting a Java service
The OpenTelemetry Java agent instruments Spring MVC, WebFlux, JDBC, Hibernate, Kafka and common HTTP clients at startup and also emits JVM runtime metrics (memory, GC, threads, CPU):
java -javaagent:./opentelemetry-javaagent.jar \
-Dotel.service.name=orders-service \
-Dotel.resource.attributes=service.version=5.2.0,deployment.environment.name=production \
-Dotel.exporter.otlp.endpoint=http://localhost:4318 \
-Dotel.exporter.otlp.protocol=http/protobuf \
-jar orders-service.jarPoint the agent at an OpenTelemetry Collector that forwards to VitalRix. The full walkthrough, including a Dockerfile and custom spans with @WithSpan, is in OpenTelemetry for Spring Boot.
Does the Java agent slow my application down?
Overhead is usually small. Startup takes a little longer, and very hot code paths can be excluded or sampled. Measure p95 before and after on a staging environment.
Which GC should I use?
G1 is the default and a good general choice. ZGC suits large heaps that need very short pauses. Measure pause times with your real workload before changing.
Check it now, free
- Response time checker: Measure TTFB with DNS, connect, TLS and server time.
Related reading
- PHP performance monitoring: Monitor PHP and Laravel apps: request latency, PHP-FPM worker saturation, OPcache hit rate, slow queries, external calls and errors.
- Python performance monitoring: Monitor Python web apps: request latency per route, worker saturation, the GIL and CPU-bound code, database time, Celery queues and memory.
- Best APM tools: Choose an APM tool in 2026: the criteria that matter, from OpenTelemetry support to pricing models, well-known options compared and how to run a fair trial.
- What is APM (application performance monitoring)?: APM explained: what application performance monitoring measures, how traces and spans work, why p95 beats averages, a worked example and how to start.
- IIS monitoring and IIS logs: Monitor Microsoft IIS: performance counters, request queues, application pool health and recycling, W3C log fields such as time-taken.
- OpenTelemetry for Flask: Instrument a Flask app with OpenTelemetry, in code or with zero code: trace routes, SQLAlchemy and outgoing calls, and export to VitalRix.
Watch your own site and services with VitalRix
Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.