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.
View badge details
About This Course
Course Curriculum
14 Lessons
JVM Internals & Garbage Collection
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.
GC & Profiling - Lab 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.
Concurrency — Threads, ExecutorService
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.
Concurrency - Lab 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.
CompletableFuture & Async Programming
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.
Async - Lab 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.
Connection Pooling & Database Performance
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.
DB Performance - Lab 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.
Caching Strategies
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.
Caching - Lab 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.
Profiling & Benchmarking with JMH
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.
Profiling - Lab 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.
Capstone Briefing
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.
Capstone: FreightFlow Async Notification & Final Benchmark
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.