AI Instructor Live Labs Included

Java Performance and Production Patterns

Optimize a Java order processing system through concurrency, async pipelines, connection pooling, caching, JMH benchmarking, and GC tuning. Gain 40x throughput improvement across 7 hands-on labs.

Advanced
18h 20m
14 Lessons
SMU-JAVA-PERF
Java Performance and Optimization Badge

View badge details

About This Course

Master the art of building high-throughput, production-ready Java applications. In this advanced course, you play the role of a senior Java engineer at FreightFlow a logistics company processing hundreds of thousands of shipment orders daily. You will profile and progressively optimize the Order Processing System through six performance transformations: concurrent thread pool execution, CompletableFuture async pipelines, HikariCP connection pooling with batch inserts, Caffeine in-memory caching, JMH microbenchmarking, and GC tuning with G1GC and ZGC. Each exercise lesson produces measurable throughput improvements, turning an 80 orders/sec sequential processor into a 3,500+ orders/sec production-grade system.

Course Curriculum

14 Lessons
01
AI Lesson
AI Lesson

JVM Internals & Garbage Collection

1h 0m

Learn the JVM memory model including heap regions (Eden, Survivor, Old Gen, Metaspace), object allocation lifecycle, minor vs major GC, GC pause vs throughput tradeoffs, G1GC vs ZGC vs Parallel GC, reading GC logs, and OutOfMemoryError diagnosis. This lesson sets the foundation for understanding why the FreightFlow Order Processor needs optimization.

02
Lab Exercise
Lab Exercise

GC & Profiling - Lab Exercises

2h 25m 5 Exercises

Replace the sequential order processing loop in the FreightFlow OrderProcessor with a ThreadPoolExecutor-based implementation that processes orders in parallel and collects Future results. Compare throughput before and after using the built-in BenchmarkRunner.

Examine the Sequential OrderProcessor and BenchmarkRunner Baseline ~20 min
Create a ThreadPoolExecutor with Available Processor Threads ~20 min
Submit Orders as Callable Tasks to the Executor ~20 min
Collect Future Results and Shut Down the Executor Cleanly ~20 min
Run BenchmarkRunner Before and After and Record Throughput Improvement ~20 min
03
AI Lesson
AI Lesson

Concurrency — Threads, ExecutorService

1h 0m

Learn Thread vs Runnable vs Callable, ExecutorService lifecycle, ThreadPoolExecutor constructor parameters, Future.get() blocking, thread safety with synchronized and AtomicLong, and deadlock diagnosis. Deep dive into concurrent programming patterns for high-throughput Java applications.

04
Lab Exercise
Lab Exercise

Concurrency - Lab Exercises

2h 5m 4 Exercises

Replace Future.get() blocking calls with CompletableFuture pipelines — supplyAsync, thenApply, exceptionally, and CompletableFuture.allOf — in the FreightFlow Order Processor. Compare throughput with the Future-based implementation.

Convert Callable Submissions to CompletableFuture.supplyAsync ~20 min
Chain thenApply to Add Processing Timestamp to Each Result ~20 min
Add exceptionally Handler for Non-Blocking Error Handling ~20 min
Combine All Futures with CompletableFuture.allOf and Verify Throughput ~20 min
05
AI Lesson
AI Lesson

CompletableFuture & Async Programming

1h 0m

Master CompletableFuture API including supplyAsync, thenApply, thenCompose, thenCombine, allOf, anyOf, exception handling with handle vs exceptionally, custom executors for async stages, and virtual threads in JDK 21 Project Loom.

06
Lab Exercise
Lab Exercise

Async - Lab Exercises

2h 5m 4 Exercises

Replace DriverManager.getConnection() with HikariCP DataSource, configure pool size and timeouts, and convert single-row INSERTs to batch inserts using addBatch()/executeBatch() in the FreightFlow Order Processor.

Add HikariCP Dependency and Configure Connection Pool Properties ~20 min
Replace DriverManager with HikariCP DataSource in OrderRepository ~20 min
Convert Single-Row INSERTs to Batch Insert with addBatch and executeBatch ~20 min
Run BenchmarkRunner and Record Database Performance Improvement ~20 min
07
AI Lesson
AI Lesson

Connection Pooling & Database Performance

1h 0m

Learn why DriverManager.getConnection() is catastrophically slow in production, HikariCP as the fastest Java connection pool, pool sizing with Little's Law, prepared statement caching, N+1 query problem, batch inserts vs individual inserts, and slow query analysis.

08
Lab Exercise
Lab Exercise

DB Performance - Lab Exercises

1h 15m 6 Exercises

Hands-on exercises implementing caching with Caffeine, measuring cache hit rates, and comparing latency with and without caching in the FreightFlow order processing system.

Add Caffeine and Spring Cache Dependencies ~10 min
Enable Spring Caching in the Application ~10 min
Configure the CaffeineCacheManager Bean ~15 min
Annotate getPrice() with @Cacheable ~10 min
Add Cache Statistics Logging to BenchmarkRunner ~10 min
Run the Benchmark and Observe Cache Hit Rate ~10 min
09
AI Lesson
AI Lesson

Caching Strategies

45m

AI-guided lesson on cache-aside vs write-through patterns, Caffeine eviction policies, Spring cache annotations (@Cacheable, @CacheEvict, @CachePut), cache stampede problem, and when not to cache in production Java applications.

10
Lab Exercise
Lab Exercise

Caching - Lab Exercises

1h 15m 6 Exercises

Hands-on exercises writing JMH microbenchmarks to measure the performance of the Caffeine-cached getPrice() method vs uncached, configuring JMH parameters, and running benchmarks with GC profiling.

Add JMH Dependencies to pom.xml ~10 min
Create the JMH Benchmark Class ~15 min
Write the processAllOrders() Benchmark Method ~15 min
Write the getPrice() Benchmark Without Cache ~15 min
Run the Benchmarks and Record Results ~15 min
Re-run with GC Profiler and Record Allocation Rate ~10 min
11
AI Lesson
AI Lesson

Profiling & Benchmarking with JMH

45m

AI-guided lesson on why System.nanoTime() benchmarks lie, JMH architecture and annotations (@Benchmark, @State, @Setup, @BenchmarkMode), throughput vs average time modes, GC profiler, async-profiler, and JVM flags for accurate profiling.

12
Lab Exercise
Lab Exercise

Profiling - Lab Exercises

1h 15m 5 Exercises

Hands-on exercises tuning JVM GC flags (G1GC, ZGC), analyzing GC logs, comparing throughput across GC algorithms, and running JMH benchmarks with GC profiler to validate the tuning impact on the FreightFlow processor.

Record Baseline GC Pause Times ~10 min
Tune G1GC Parameters ~15 min
Compare G1GC vs ZGC Performance ~15 min
Record Results in GcTuningReport ~10 min
Apply the Best GC Configuration ~10 min
13
AI Lesson
AI Lesson

Capstone Briefing

30m

AI-guided capstone briefing reviewing all FreightFlow optimizations (JVM GC, ThreadPoolExecutor, CompletableFuture, HikariCP, Caffeine, JMH) and introducing the capstone project: add async notification via CompletableFuture.runAsync() with circuit breaker and produce a final benchmark comparison report.

14
Lab Exercise
Lab Exercise

Capstone: FreightFlow Async Notification & Final Benchmark

2h 0m 7 Exercises

Capstone project: replace the remaining synchronous email notification bottleneck with CompletableFuture.runAsync() in a dedicated thread pool, add a circuit breaker pattern, and produce a final JMH benchmark comparison report documenting the complete ~18x performance improvement.

Identify the Synchronous Notification Bottleneck ~10 min
Create the Dedicated Notification Thread Pool ~15 min
Replace the Blocking Call with CompletableFuture.runAsync() ~20 min
Add Retry Logic and Circuit Breaker to NotificationService ~20 min
Add the Notifications Counter and Update the Benchmark ~15 min
Run the Final Benchmark and Complete the Performance Report ~20 min
Reflect: What You Optimized and Why It Mattered ~10 min

This course includes:

  • 24/7 AI Instructor Support
  • Live Lab Environments
  • 7 Hands-on Lessons
  • 6 Months Access
  • Completion Badge
  • Certificate of Completion
Java Performance and Optimization Badge

Earn Your Badge

Complete all lessons to unlock the Java Performance and Optimization achievement badge.

Category
Skill Level Advanced
Total Duration 18h 20m
Java Performance and Optimization Badge
Achievement Badge

Java Performance and Optimization

Awarded for completing the Java Performance course, demonstrating mastery of JVM tuning, profiling, concurrent programming, and performance optimization techniques.

Course Java Performance and Production Patterns
Criteria Complete all lessons and pass assessments in the Java Performance and Optimization course.
Valid For 730 days

Skills You'll Earn

JVM Tuning Performance Profiling Concurrency Memory Management Benchmarking Optimization Patterns

Complete all lessons in this course to earn this badge