Batch applications are used in enterprises to process large volumes of data in bulk for report generation, billing, data archiving, image processing, Machine Learning Model Training … Choosing the right GC strategy plays a key role in influencing the Batch application performance. In this modern world, where we are all used to 1-minute video shorts, we might not have the bandwidth to read the entire post. Thus, to keep the long story short, let me share the key takeaway of this post right here: Parallel GC algorithm is the first choice for Batch application, as they focus on achieving high throughput. G1 GC is the second-best choice, as it tries to strike balance between latency and throughput. ZGC is the third best choice if your heap size is quite large (like >64GB). You don’t have to continue to read further, unless you want to learn the rationale for my recommendation and more details.
If you are new to Java GC Concepts, we recommend you learn about Java Garbage Collection fundamentals from this post.
Video
In this video, our Architect Ram Lakshmanan has unpacked the different GC algorithms available in the JVM, explained their unique trade-offs, and provided valuable guidance on how to select the best fit for specific application workloads.
Performance Requirements of Batch Applications
Modern Batch applications are expected to have following performance characteristics:
- High throughput (i.e. ability to process a lot of transactions in a unit of time)
- Resilient (i.e. Fault Tolerant to withstand any component, environmental outages)
Here high throughput is the primary characteristics and it’s heavily influenced by the Garbage Collection behavior.
GC Algorithms in Open JDK
As of 2025, there are 7 GC algorithms in OpenJDK:
1. Serial GC
2. Parallel GC
3. CMS GC
4. G1 GC
5. ZGC
6. Shenandoah GC
7. Epsilon GC
Out of these 7 GC algorithms, 4 GC algorithms are not suitable for Batch applications for the following reasons:
1. Serial GC is the oldest GC algorithm. This algorithm incurs long pause time and affects the latency of the transaction. However, they add very minimal CPU and memory overhead. For Batch Applications, response times are important. Thus Serial GC is not a good fit.
2. CMS GC algorithm has been deprecated in JDK 9 and removed from JDK 14. Even if you are running on an older version of JDK, it’s not advisable to run on a GC algorithm which has been removed.
3. Shenandoah GC algorithm was originally developed by RedHat and now the generational version of this algorithm is developed by Amazon. Since it’s not officially supported by Oracle/JDK Team, I will shy away from using this algorithm, unless it provides phenomenal results (which you need to validate for your application).
4. Epsilon GC is basically a No-Op GC algorithm. It’s only used for academic or experimental purposes. Production applications can’t be run using this algorithm
Right choice for Batch Applications: Parallel GC, G1 GC and ZGC
There are only 3 good choices in OpenJDK for Batch applications:
a. Parallel GC has been the default GC algorithm till Java 8. Parallel GC algorithm is known as the throughput algorithm and known to produce good throughput. Since we expect the batch application to complete quicker, Parallel GC is a preferred choice for Batch applications. If you are looking to learn about Parallel GC tuning parameters, you may refer to this Parallel GC Tuning post.
b. G1 GC has been the default GC algorithm since Java 9. G1 GC algorithm strikes a good balance between GC Throughput and GC Pause Time. If your batch application’s heap size is less than 32BG, then consider using the G1 GC algorithm. If you are looking to learn about G1 GC tuning parameters, you may refer to this G1 GC Tuning post.
c. ZGC: If your application happens to be running on JDK 21 and your application needs more than 32GB of heap size, you should consider using the ZGC algorithm. The ZGC algorithm tends to give better performance when your heap size is very large. If you are looking to learn about ZGC tuning parameters, you may refer to this ZGC Tuning post.
If you are looking to improve GC throughput, I would like to recommend reading this post: How to achieve high GC Throughput. This post gives high level tips, tricks and best practices to improve GC throughput of the Batch applications.
GCeasy Tool to Study GC Performance
Note: Please conduct proper performance tests and make a decision on which GC algorithm to use. Don’t make your decision based on the information shared in this post.
You should do a GC study before switching to a different GC Settings. Thus we recommend you to study the GC Key Performance Indicators using tools like GCeasy. GCeasy provides necessary recommendations and GC settings to enhance your Batch application’s performance. There is this famous proverb: ‘Proof of the pudding is in the eating’. Similarly, you may refer the sample GC log analysis report generated by the GCeasy tool and experience its output first hand.
Conclusion
Tuning GC settings brings tremendous performance improvements to your Batch. Several major enterprises has understood the importance of GC tuning and achieved phenomenal performance gains, you can also bring a similar impact to your organization. If you found this post useful, and would like to learn more about GC tuning you, please check out ourmy online ‘JVM Performance Engineering & Troubleshooting Master Class’.


Share your thoughts!