问题描述:

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:

  1. Is that correct to assume that reducing suspension time will reduce response time?
  2. Is there another way to reduce suspension time other than disposing of objects properly and quickly.

Our current relevant JVM options are:

-XX:+UseParNewGC

-XX:+UseConcMarkSweepGC

-XX:NewRatio=2

-XX:+UseTLAB

-XX:SurvivorRatio=2

-Dsun.reflect.noInflation=false

-Dsun.reflect.inflationThreshold=21474836

-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true

-XX:MaxMetaspaceSize=256m

-Xms3072m

-Xmx3072m

-XX:+CMSClassUnloadingEnabled

Thanks

网友答案:

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.

相关阅读:
Top