This repository holds the example code for the article: Analyzing Performance in a JVM Server at Scale by Self-Measurement
It performs some "busy work" of finding primes as a way to demonstrate a few performance tracing and self-measurement techniques possible with the standard JVM.
The ResourceUsageCounter and ConcurrentResourceUsageCounter are the key classes.
Gradle and Java 8 (or higher) are required to build.
To build run:
$ gradle war
The build output is located at 'build/libs'. For example:
$ ls build/libs
JvmResourceInstrumentServer-1.0-SNAPSHOT.war
Java 8+ and a Servlet API 3.1 compatible servlet container are required to run.
Tomcat 8 or higher is a good choice, but any Servlet API 3.1 container should work. If using Tomcat, you can deploy by using the 'manger' app, or by copying the WAR package to '$CATALINA_HOME/webapps'
Unless one changes the context when deploying, the initial portion of the URL will match the WAR package name. The ExampleServlet is configured to handle 'urlPatterns = "/example/*"'. This means that by default one should use a URL similar to:
$ wget -q -O - http://localhost:8080/JvmResourceInstrumentServer-1.0-SNAPSHOT/example