views:

211

answers:

3

I recently learned about scenarios which require warming up an app (with high throughput requirement) before they start serving real requests. The logic behind this was to allow JIT to do its performance magic!

Is this a norm for Java apps or is this generally done for memory heavy (footprint) apps?

+8  A: 

If you are talking about a high traffic webapp/website then JIT is a very minor issue. The biggest problem is warming up (populating) all the cache layers you'll need to have. E.g ehcache regions which are being populated from hibernate. That's because IO related operations are orders of magnitude slower than anything that happens inside the CPU (that is unless you are calculating fractals :)

cherouvim
+1 for "unless you are calculating fractals".
z5h
Thanks for the pointer but I think I was referring to warm up code paths rather than "expensive" data. I was particularly wondering if it makes sense for large Java apps to be pre-warmed specially considering that JVMs today are smart enough to decide what code path is accessed a lot and hence to cache the JIT for them etc.Certainly there is a perf. hit when JITing for the first time and hence I wanted to know if in real life anyone has faced this issue that would have encouraged them to warm up their apps and if so then what perf. improvements have they seen.
Aayush Puri
@Aayush Puri: and my answer was that if you are talking about webapp then JIT warmup is 0.01% important so in real life (and in the context of webapps) everyone has larger problems to solve (warmup for database, caches etc)
cherouvim
BTW during some web search on a related topic I found out a small discussion on this very topic by a couple of folks in the IBM WebSphere eXtreme Scale team: http://www.youtube.com/watch?v=hrbTyK-1yrAThey didn't explain a lot about the application but I guess this type of scenario is pretty rare
Aayush Puri
+5  A: 

The question is, when would you want to go out of your way to do this?

If you roll out a webapp, and it is IMMEDIATELY live, then while you're "warming" it, you're adding extra load, which is counter-productive. Similar is true when a desktop app starts. No point in warming if the user is going to start immediately using it. Or worse, not allowing the user to interact while you are warming the app.

If you roll out a webapp, and you test the deployment before you point your load balancers to it, then you've already warmed it as a side result.

z5h
Personally, _I_ would go out of my way to do this when I do performance tests. Or when I have a cluster, and warming up a machine before plugging it into the cluster doesn't affect users.
Eli Acherkan
But if your production environment does not have the benefit of warming up, why would you want to skew your performance test results by warming up in the performance test environment?
zkarthik
I totally agree that it only makes sense to warm up an app before adding it to your load balancer.
Aayush Puri
+4  A: 

In addition to cherouvim's answer, I can think of a few other issues that require warm-up:

  • Objects instantiation (lazy loading, singletons etc.);
  • Heap allocation (if your Xms is smaller than your Xmx).

I imagine that the OS attunes itself to an application's behavior as well, so that OS calls may also be affected by a warm-up period.

Most of the above (cache population, object initialization) aren't specific to Java.

Eli Acherkan
+1: OS population of file caches can be a big factor.
erickson
> Heap allocation (if your Xms is smaller than your Xmx).Good point. And I believe that's why it is said to set Xmx=Xms
Aayush Puri