This document provides setup instructions to profile the oscars-backend service as part of local development, and the CI/CD pipeline.
We leverage VisualVM to view real time profiling data of the oscars-backend service.
Please obtain VisualVM for your platform.
The local oscars-backend ocd-stack service is started with the appropriate Java arguments to enable remote JMX connections (without security enabled).
We are using OrbStack to run our docker compose services locally.
NOTE: Staging and production environments should always have HTTPS and security authentication configurations enabled.
- Right-click "Remote" in the Applications sidebar view, and click "Add Remote Host"

- In the "Add Remote Host" modal dialog, set the Host name to the
oscars-backenddomain. If using OrbStack, it should be oscars-backend.ocd-stack.orb.local. Click "OK" to save and close the modal dialog.
- There should now be an item in the "Remote" section of the Applications sidebar. Right-click the new entry, and click "Add JMX Connection".

- In the "Add JMX Connection" modal dialog, the "Connection" string should specify port 1099 (
hostname:portformat). For local development, ensure "Do not require SSL connection" is checked. Keep everything else as-is. Click "OK" to save and close the modal dialog.
- There should now be an item under "Remote > oscars-backend.ocd-stack.orb.local" named
org.springframework.boot.loader.launch.JarLauncher (pid 1). Right-click it and then click "Open".
- A new tab should have opened within VisualVM. This tab allows us to monitor multiple aspects of the
oscars-backendapplication stack using the "Monitor" sub-tab. We can also sample CPU and Memory using the Sampler sub-tab.
- Right click "Remote > oscars-backend.ocd-stack.orb.local > org.springframework.boot.loader.launch.JarLauncher (pid 1)". Click "Start JFR". The VisualVM status bar (lower-right side of the window) will show "Starting JFR Recording".

- Interact with the
oscars-backendservice as usual. - Use the "Dump JFR" option at any time during the JFR session. Please take note of where the JFR file is being saved within the
oscars-backendcontainer!

- When you are done, right click "org.springframework.boot.loader.launch.JarLauncher (pid 1)" and click "Stop JFR".

- Extract the JFR dump file from the
oscars-backendcontainer if you need it. Theoscars-backendcontainer is not currently set up to use volumes, so any saved file data will not persist when the service is relaunched!

- We have an
ocd-stackdocker compose service namedoscars-backend-profilethat launches a separate container. We can configure theoscars-backend-profileservice with the following environment variables:DELAY_MIN, specifies how long to wait before starting the JFR data recording. See thesleepcommand arguments (examples: 10 seconds as10s, 5 minutes as5m, etc.)DURATION_MIN, specifies how long to run the JFR data recording. See thesleepcommand arguments (examples: 10 seconds as10s, 5 minutes as5m, etc.)TARGET_HOST, specifies thehostname:portformatted value we establish a JMX connection with.
- Although not implemented as of the time of this writing, we could potentially run automated
oscars-backendinteraction simulations during the recording duration. - After the DURATION_MIN time has elapsed, the JFR data will be dumped to
/app/recording.jfrwithin theoscars-backendcontainer. - We can have the JFR recording extracted from the container for later viewing, using VisualVM or similar.