Skip to main content

Demo Lab: Scenario Catalog & Safety Guarantees

jfr-performance-demo-app (ShopSphere) is a Spring Boot e-commerce demo application engineered to generate realistic, isolated, and safe JVM performance anti-patterns on local developer machines.


The 10 Performance Anti-Patterns​

IDNameDominant JFR EventRoot Cause Summary
cpu-hotspotCPU Hotspotjdk.ExecutionSampleRedundant trigonometric polynomial discount calculations
thread-contentionThread Contentionjdk.JavaMonitorEnterCoarse synchronized monitor locking across unrelated inventory
allocation-and-gcAllocation Pressurejdk.ObjectAllocationSampleChurn of intermediate maps, DTOs, and string concatenation
allocation-and-gcGC Pressurejdk.GarbageCollectionBurst allocations triggering rapid Eden exhaustion and young GCs
thread-pool-starvationThread Pool Starvationjdk.ThreadPark2-worker executor queue starvation blocking caller threads
slow-ioSlow Downstream I/Ojdk.ThreadPark (Low CPU)Synchronous blocking downstream calls with near-zero CPU
exception-stormException Stormjdk.JavaExceptionThrowUsing thrown exceptions for routine validation control flow
serialization-overheadSerialization Overheadjdk.ExecutionSample / AllocMultiple Jackson JSON roundtrips during response assembly
other-scenariosLock Scope with I/Ojdk.JavaMonitorEnter + I/OHolding shared monitor lock across simulated network calls
other-scenariosJVM Sizing ComparisonMemory MXBean / GCMemory pool occupancy and GC behavior under varying heap sizes

Safety and Bounded Workload Guarantees​

To ensure scenarios never destabilize developer workstations, jfr-performance-demo-app implements four strict safety boundaries:

  1. Bounded Concurrency: Worker pools are hard-capped at a maximum of 50 threads. Default demo runs use 4–8 threads.
  2. Bounded Duration: Scenarios terminate automatically after a configured timeout (default 15–20s; maximum 120s). Workloads cannot run indefinitely in the background.
  3. Graceful Cancellation: Every scenario loop checks an atomic cancellation flag and handles thread interrupts immediately via scenario.stop() or POST /api/scenarios/{id}/stop.
  4. Heap Safety: Workloads generate memory churn but do not leak references into unbounded static collections. Memory is always reclaimable by garbage collection.
  5. Zero External Dependencies: Runs purely locally on developer machines without requiring PostgreSQL, Kafka, Redis, or cloud accounts.

Two Execution Modes​

Runs a complete faulty-versus-corrected benchmark with automatic JFR recordings and markdown report generation:

cd jfr-performance-demo-app
./scripts/run-demo.sh <scenario-id> [durationSeconds] [concurrency]

Mode B: Interactive Spring Boot HTTP Server​

Runs the application as an interactive REST microservice on port 8080:

java -jar target/jfr-performance-demo-app-1.0.0-SNAPSHOT.jar

Key REST API endpoints:

  • GET /api/scenarios: Lists all scenarios and current run status
  • POST /api/scenarios/{id}/start?mode=FAULTY&durationSeconds=20&concurrency=8: Starts a scenario
  • POST /api/scenarios/{id}/stop: Stops a running scenario immediately
  • GET /api/metrics/summary: Returns JVM memory usage and latency percentiles
  • POST /api/jfr/start?scenarioId=cpu-hotspot&mode=faulty: Starts in-process JFR recording
  • POST /api/jfr/stop: Flushes and saves the recording to recordings/