We are load testing our Web Services application and one of the suggestions was to try and reduce suspension times in order to improve response time.
From my research, the best way to reduce suspension time is to minimize object lifetime, but information is pretty scarce on the topic. So I'd like to know two things:
Our current relevant JVM options are:
To improve the consistency of response time, you need to reduce the cause of your pauses. This could be the GC, waiting for network resources, use of locks resulting in poor scalability or a number of pauses.
If the main cause of your response time delay is GC pauses, then reducing the number and length of your GC pause times will improve response time. esp response time consistency.
If you are trying to reduce the typical response time, but you are not getting a GC on every request, most likely you want to tune your software to do less work, allocate less objects, use lower time complexity algorithms, avoid network and IO accesses on every request.
You shouldn't be writing code oriented to reduce the lifetime of objects, you just have to write well designed code. That said, I'd recommend using the Flyweight pattern when possible.
Reducing suspension time will reduce response times considerably when you have a request during a full GC pause. (The GC pause will increment the usual response time since the app will be stopped until the GC finishes)
You could focus on tweaking the JVM, more precisely setting the Heap size options (check Java HotSpot VM Options). The GC and their options may change based on your JDK version.