You might be thinking, why should a Java developer read a book on Performance tuning? When I first faced this question a long time back, I thought I will do it later, but I never got back to that for a long time. I realize my mistake of having a lack of knowledge on memory measurement, JVM tuning, and finding bottleneck only when I faced severe performance and scalability issues on our mission-critical, server-side financial application written in Java. It's true that when you really need it, you learn most, but those times are not the best time to learn fundamentals, in fact, those times are to apply and correct your misunderstanding.
This is why I am sharing these Java performance books to all Java programmers and suggesting them to take some time and go through at least one book in full. By the way, these books are in addition to my 5 must-read books for Java programmers, which deals with all other topics in Java. If you haven't read them yet, make sure you check them as well.
Given Java's ability to natively compile hot code using JIT (Just in time Compiler), it is almost on par with native applications written in C and C++, but a lot can be done by following best practices, avoiding common performance pitfalls and using latest tools and techniques.
In this article, I am going to introduce with five + one (bonus) books on Java performance, which will not only teach you what to measure, how to measure but also explains fundamentals and concept behind those issues.
You will not only learn about the Operating System and JVM on which your Java application run but also how to write faster coding using Java API. So what are we waiting for, let's begin our journey to a land of great books on Java performance tuning?
8 Java Performance Books for Experienced Developers
1. Java Performance: In-Depth Advice for Tuning and Programming Java 8, 11, and Beyond by Scott Oaks
It also has excellent chapters on explaining various garbage collection algorithms e.g., Concurrent Mark Sweep (CMS) and G1 Garbage collector. Developers and performance engineers alike will learn a variety of features, tools, and processes for improving the way the Java 8 and 11 LTS releases perform.
You will learn how each of them works in different conditions, how to monitor them, and how to tune them. It also includes a full chapter on heap analysis and optimization.
In short, This is one of the best books on Java Performance Tuning, but, If you like online courses, then you can combine this one with Pluralsight's Understanding the Java Virtual Machine: Memory Management course to get the best of both world.
This will teach you everyday things like how to take heap dumps and histograms in Java, and then introduces many ways to decrease your heap memory footprint.
It also has a chapter on JDBC and JPA performance. The critical point it teaches you that how choosing the proper JDBC / JPA methods may far outweigh the gains from the SQL queries tuning.
Similarly, it has a complete chapter explaining multi-threading issues, pitfalls, and impact on performance. It includes advanced topics like ForkJoinPool and Java 8 Streams.
It also touches base on the cost of synchronization and false sharing, tuning JVM threads e.g., thread stack size, configure biased locking, thread priorities, and thread spinning.
By the way, best is yet to be introduced, what I like most about this book is Chapter 12. This chapter presents some excellent core Java tuning tips and their impact. This includes buffered I/O, class loading, random number generation, JNI, exceptions, String performance, logging, Java Collections API, Java 8 lambdas vs. anonymous classes, and finally, Java 8 stream and multiple filter performance.
This was actually the first chapter I read, and I fall in love with its content and style. If you like to quickly gauge the book by yourself, I suggest starting with this chapter. It also touches base on Java EE performance, explaining possible issues with XML and JSON parsing, and object serialization.
2. Optimizing Java: Practical Techniques for Improving JVM Application Performance
3. Troubleshooting Java: Read, debug, and optimize JVM applications
I first come across this book on Twitter because I follow Laurentiu Splica after reading this book on Spring and I immediate bought it as troubleshooting and debugging is also a topic which is very close to my heart, and I must say I wasn't disappointed.This is one of the most up-to-date books on Java Performance tuning and writing code which execute faster in Java. This was the book that told me that the performance of Java application will be limited by three main factors CPU, Memory, and IO (both Disk and Network), and surprisingly many developers who know how to use profiler don't know this basic fact.
Though this book also introduces many profiling tools, I suggest the latest books like Java Performance The Definitive Guide By Scott Oaks and Java Performance By Binu John, Charlie Hunt has a more comprehensive list.
And, If you need a course, you can also combine this book with the Java Memory Management course on Udemy. This book especially focused on memory management in Java and you will learn about Stack, Heap and different JVM memory areas in depth.
This was my favorite Java performance book for a long time, until recently when I read Java Performance The Definitive Guide By Scott Oaks. This book is very much similar to the one which replaced it from the top.
It has chapters explaining how to take measurements of performance, demonstrating tools necessary to measure CPU, Memory, and IO. Chapters on explaining How Garbage collection works, different GC algorithms like Serial vs. Parallel Garbage collectors, Concurrent Mark Sweep collectors, etc.
Both Binu John and Charlie Hunt have done an excellent job on how to construct experiments that identify opportunities for optimization, interpret the results, and take effective action.
While, Binu John is a senior performance engineer at Ning, Inc., where he focuses on improving the performance and Scalability of the Ning platform to support millions of page views per month. Before that, he spent more than a decade working on Java-related performance issues at Sun Microsystems, where he served on Sun's Enterprise Java Performance team.
If you haven't read any book on Java performance tuning and want to build a good foundation for dealing with performance problems, this is the book to buy. It's worth every single penny spent.
Systems performance analysis is an essential skill for all computer users, whether you're trying to understand why your laptop is slow or optimizing the performance of a large-scale production environment.
It is the study of both operating Systems (kernel) and application performance, and this book will tell you all you need to know about Linux performance monitoring and tuning. The programmer starts with optimizing algorithms, data structure, JVM, Garbage collectors, but they eventually reach a point where System performances come into play.
You may want to know why disk operations were so quick on your development box, but became a significant issue on the production box, how CPU caching effect so much to your application, how can you leverage L1, L2, and L3 Cache, and Physical memory available on your machine.
In my opinion, this is the book for every programmer and not just for Java programmers. Knowing how your system work, how paging, swapping and virtual memory work, how CPU gets data from disk, how different kind of disk can make a profound impact on IO-bound Java applications is significant for any developer is genuinely interested in performance tuning.
I had often said, learn JVM, but I can now tell you must know your System well. Knowing operating system basics, system calls, memory, CPU, network, and disk IO, caches will undoubtedly go a long way and helps you to write a high-performance application in any programming language, including Java.
7. Java Performance and Scalability: A Quantitative Approach by Henry H. Liu
You can see this book a more specialized version of his earlier bestseller. As the name suggests, this book is focused on the performance and Scalability of Java application.
This book is suitable for Java developers, architects, and even managers. It is divided into two main parts, the first part deals with the basics of Java performance and Scalability, and the second part presents practices to improve performance and Scalability.
The basics part contains four chapters; each of them separately explores the Scalability of software programs, computer hardware, and Java Virtual Machine. The second part includes chapters exploring how going from 32-bit to 64-bit affects the performance and Scalability of Java application.
Chapter 6 is probably the most important chapter, which explains how to tune Java for the best possible performance and Scalability. It introduces methodologies, practices, tools, and tuning Java application keeping Scalability in mind.
Chapter 7 is another essential chapter that explains how design, algorithms, and implementations affect the performance and Scalability of any Java application. It also covers how to perform a bottleneck analysis. The good thing is that he explains all this with sample programs, so you can follow guidelines while reading.
Overall its an excellent and unique book for Java performance engineer, and if you love to read multiple books to gain insights, this is the one you can read along with Java Performance The Definitive Guide and System Performance: Enterprise and the Cloud.
This is the bonus book for my readers, I won't say this book only focuses on Java performance tuning, but I would say this is the book every modern Java developer should have on his shelf. Ben Evans and Martijn Verburg don't need any introduction.
They are well known Java experts and founders of jClarity, which promises to solve performance problems in cloud environments. They have many years of experience in Java, which reflects in their book The Well-Grounded Java Developer: Vital techniques of Java 7 and polyglot programming.
Adding new library extensions such as fork/join or syntactic sugar like switch-on-string is relatively easy, but adding a JVM instruction like invokedynamic is very costly. Probably the best thing about this book is that it doesn't stop at Java and go one step further to introduce modern-day JVM languages like Scala, Clojure, and Groovy.
It touches functional programming with new JVM languages and modern approaches to test, build, and contentious integration of Java applications.
That's all on this list of good Java performance tuning books. I have recommended Effective Java a lot of times, and as one must-have a book for Java developers, but the same time I have also found that you should have a publication dedicated to Java Performance Tuning.
After some years of work and experience in Java, you are bound to face performance challenges, and at this time, you should, at least, know fundamental, tools, and process of finding the bottleneck and improving the performance of Java application. So, if you haven't read any Java performance book, this is the time to read one.
Further Learning
- Understanding the Java Virtual Machine: Memory Management
- The Java Developer RoadMap
- Top 5 Courses to Learn Microservices in Java with Spring
- 10 All-time great books for Java Programmers
- 10 Books Java Developers Should Read
- 10 Algorithm Books Every Programmer Should Read
- 5 Spring Framework Books Experienced Dev Should Read
- 10 Things Java Developer Should Learn in depth
- 10 Tips to become a better Java Programmer
- Top 5 Courses to learn JVM Internals and GC in Java
Thanks for reading this article so far. If you like these Java Performance books, then please share it with your friends and colleagues. If you have any questions or feedback, then please drop a note.





No comments:
Post a Comment
Feel free to comment, ask questions if you have any doubt.