I am developing a messaging system with Java that requires low latency processing (under 1 second). However, JVM takes warm-up time to process the first input data that causes latency increase (about 2~3 seconds). The main reason of the latency increase was class loading. I know the simplest solution is to use dummy messages to invoke methods in advance. However, I cannot use dummy messages to warm-up JVMs because of the system requirement. So I want to know the method to preload all the used classes when the JVM starts.
I tried the properties to force-load methods by
-XX:CompileThreshold=0 -XX:TieredCompilation
However, it doesn't seem to be working well. The JVM still loads classes when they are called.
I also read other threads, but no one specified the method to preload classes when a JVM starts.