Java Performance Tuning
Java(TM) - see bottom of page
Our valued sponsors who help make this site possible
JProfiler: Get rid of your performance problems and memory leaks!
Training online: Concurrency, Threading, GC, Advanced Java and more ...
Tips June 2020
JProfiler
|
Get rid of your performance problems and memory leaks!
|
JProfiler
|
Get rid of your performance problems and memory leaks!
|
|
|
Back to newsletter 235 contents
https://www.youtube.com/watch?v=GwjK-cQPJOQ
Design and testing low latency microservices in Java (Page last updated May 2020, Added 2020-06-29, Author Peter Lawrey, Publisher Chronicle Software). Tips:
- To achieve 10-100 microseconds latency 99% of the time, you need to target 1% utilization of a core or less - 1% utilization of a core means 1% of the time that a new event comes in you're still dealing with the last event, so 1% of events are slowed
- For ultra-low latency you should aim for low enough garbage generation and a large enough Eden space to avoid having any garbage collections
- Your measuring needs to be lower overhead than what you're measuring, otherwise it skews the results, and you need to measure after JVM & application warmup is complete.
- Look at latency distribution not averages and deviations as the measures are skewed
- Minimize exceptions, log as little as possible after initialization. Logging is one of the most expensive overheads to a low latency system. Send logging of events and exceptions to another system to log using your low latency capabilities.
- Using string encoding into a long can make some string operations like comparison very efficient. Obviously this only works for strings that fit in that data size (eg 10 ascii chars in Base85).
- Using offheap and smaller on-heap spaces can be very efficient.
https://dzone.com/articles/delayedbatchexecutor-how-to-optimize-database-usag
DelayedBatchExecutor: How to Optimize Database Usage in Java Multi-Threaded Applications (Page last updated April 2020, Added 2020-06-29, Author Victor Porcar, Publisher DZone). Tips:
- If many queries that differ only in the value of a parameter are being executed close together, it's more efficient to convert those into a single query with multiple parameters - more efficient for the database, for network calls and for connection pool usage.
https://www.youtube.com/watch?v=lX6vVOLOLPM
Java Performance Analysis (Page last updated May 2020, Added 2020-06-29, Author Kirk Pepperdine, Monica Beckwith, Publisher Devnexus). Tips:
- Execution profiling is useful for seeing what application is doing - but not very useful to see what your application is blocked on or waiting for
- kernel time, user time and idle time are all important to determine where the issue is. If sys CPU > 10% utilization, then you should be profiling the system rather than the app. netstat, mpstat, iostat, ...; if the user CPU is not close to 100% utilization then look for thread starvation, why the threads are not progressing; otherwise the CPU utilization is close to 100%, check if your memory use is efficient (GC logs) - if it is, profile the application, if not, focus on memory efficiency (tune the JVM, the GC, application allocation etc)
- Objects > 50% size of the G1GC region go straight to the old generation in a humongous region; if larger than a region it needs contiguous regions. If there are many such allocations then one technique to reduce them is to increase the region size.
- Memory leaks can be seen with a Java flight recording including path to roots, or the generation count in VisualVM.
Jack Shirazi
Back to newsletter 235 contents
Last Updated: 2025-01-27
Copyright © 2000-2025 Fasterj.com. All Rights Reserved.
All trademarks and registered trademarks appearing on JavaPerformanceTuning.com are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries. JavaPerformanceTuning.com is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
URL: http://www.JavaPerformanceTuning.com/news/newtips235.shtml
RSS Feed: http://www.JavaPerformanceTuning.com/newsletters.rss
Trouble with this page? Please contact us