Reputation: 3199
Hi is there any cache or settings of the jvm to speed up methods call?
e.g: I do have a web service and when I call it once per 10minutes or so it's quite slow processing takes around 8-10s in comparison to calling it once per 20seconds-the result is roughly around 5s.
Nothing else except this is running on the server. Is there a way to speed it up? (I cannot cache any objects or so.)
I used JProfiler, I call it with the same parameters. It's doing exatly the same thing. The difference is between times when I call it. How long the server is idle. 1 or 30minutes is difference.
Thanks
EDIT: platform is: AIX java: IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 AIX ppc64-64 .. server: tomcat
Upvotes: 3
Views: 9596
Reputation: 31903
Apart from improving the code itself, make sure the JVM that runs the server is the server vm and not the client vm. Use the -server parameter.
client vm:
Java HotSpot(TM) Client VM (build 14.1-b02, mixed mode, sharing)
server vm:
Java HotSpot(TM) Server VM (build 14.0-b16, mixed mode)
To find out what you run on production you can programmatically do:
System.getProperty("java.vm.name");
which should give you something like: Java HotSpot(TM) 64-Bit Server VM
Otherwise (if you don't want to touch the code) you can do a thread dump and have a look at the top for something like: Full thread dump Java HotSpot(TM) Server VM (16.0-b13 mixed mode)
Upvotes: 2
Reputation: 38615
Factors which could explain such behavior:
-server
option is basically a preset configuration for the JVM.Investigating such kind of issue can be hard. I would suggest you try to correlated OS-level information with JVM-level information. A profiler is maybe not the best tool, try with JConsole
, mem
, etc.
Try also to identify the deviation between different typical scenario, e.g. first request after startup, request under heavily load, request under medium load, etc. Try to identify when the response time change.
Upvotes: 2
Reputation: 2447
do you have swap enabled on the machine? If so, have you tried turning it off? It seems a clear case of your memory being swapped out.
Upvotes: 0
Reputation: 1902
How much load is the server under? After 10 minutes a heavily loaded server has probably swapped out your service to disk or (depending on the server software) shut down the instance of your service that served the last request. This means spooling up the service for your new request is really slow.
A couple of ways you could solve this:
Upvotes: 0
Reputation: 75386
Slowness after an idle period is usually caused by the process being swapped out to disk. Modern systems are never idle, and systems like Windows aggressively swap background processes out (non-focus os enough) which frequently happened to Eclipse users.
Please edit your question with information about your platform.
Upvotes: 0
Reputation: 5958
Use a Profiler.
JProfiler would be a good choice.
Using a profiler you can identity hotspots in your code. Once you have indentified those hotspots you can think about various way to improve those hot spots in terms of space and time.
Upvotes: 2