Optimizing Java: A Practical Guide to Java Application Performance Optimization
Optimizing Java: A Practical Guide to Java Application Performance Optimization
Summary:
Introduction
The book «Optimizing Java» (authors: Benjamin J. Evans, James Gough, Chris Newland, 2018, 450 pages) is not another language syntax reference, but a deep practical guide to extracting maximum performance from Java applications. In the era of microservices, high loads, and cloud computing, the ability to "squeeze" speed out of the JVM is becoming a critical skill for a senior developer. The authors — recognized experts in the field of JVM and performance — offer a systematic approach: from understanding how the virtual machine works to specific methods of profiling and code tuning.
What is this book about?
The book covers the full performance lifecycle: theory, tools, and practical techniques. It does not teach how to write "beautiful" code, but teaches how to write fast and predictable code, understanding what happens "under the hood" of the JVM.
Main topics:
- Hardware and OS: how the processor, cache memory, NUMA architecture, and operating system affect the performance of Java applications.
- JVM Internals: a detailed breakdown of the garbage collector (G1, ZGC, Shenandoah), JIT compiler (C1, C2, Graal), heap memory, and stack.
- Profiling and Benchmarking: practical use of JMH, VisualVM, Java Flight Recorder, async-profiler, and other tools.
- Code Optimization: working with collections, strings, exceptions, synchronization, I/O, and serialization.
- JVM Tuning: startup flags, GC selection, heap and metaspace sizes, configuration for containers (Docker).
- Advanced Topics: JIT observations, inline caches, deoptimization, working with native code via JNI and Panama.
Who is this book for?
The book is intended for experienced Java developers (middle/senior) who already write code confidently but want to understand why one application runs fast and another is slow, and how to fix it. Basic Java knowledge is required, but deep JVM experience is not — the authors explain complex concepts accessibly, with examples.
What will the reader learn?
- How JIT compilation works and how to "hint" the compiler in the right direction.
- How to choose and configure a garbage collector for a specific workload (latency vs throughput).
- How to write micro-benchmarks correctly using JMH to avoid false results.
- How to profile an application in production with minimal overhead (JFR, async-profiler).
- How to optimize memory usage: avoid leaks, reduce the number of objects, use off-heap.
- How to configure the JVM for containers (Docker, Kubernetes) considering CPU and memory limits.
- How to use modern Java features (modules, records, sealed classes) to improve performance.
Strengths of the book
- Practical focus: each chapter contains code examples, profiler screenshots, and specific recommendations.
- Relevance: despite being from 2018, the book covers Java 11 and newer versions (including ZGC), as well as modern tools.
- Depth: the authors are not afraid to delve into the intricacies of the JVM, but do so consistently, without excessive academicism.
- Structure: the material is logically arranged from simple to complex, allowing the book to be used both as a textbook and as a reference.
- Author experience: Evans, Gough, and Newland are well-known speakers at Java conferences; their advice is tested on real projects.
Who is recommended
The book will be useful to everyone who works with Java at the production level: backend developers, DevOps engineers, architects, team leads. If you have ever encountered performance issues (long GC pauses, slow startup, high memory consumption)