5 ms·
My understanding is that some people just restart the JVM periodically to avoid GC pauses. How does that compare for web applications?
by cshesse 15y ago
My understanding is that some people just restart the JVM periodically to avoid GC pauses. How does that compare for web applications?
- wolf550e 15y agoWhile the JVM is down because you have restarted it, presumably your load balancer is routing requests to another JVM/machine. Then the new JVM starts up and warms up until it's ready to receive requsts. A restart transformed a JVM with a fragmented old gen into a JVM with fresh old gen using X1 wall-clock seconds and Y1 cpu time/watts. A full GC transforms a JVM with a fragmented old gen into a JVM with fresh old gen using X2 wall-clock seconds and Y2 cpu time/watts. Have you ever compared X1,Y1 vs. X2,Y2?
- jbri 15y agoDoes the JVM finish up outstanding requests and ask the load balancer to please-don't-send-me-anything-for-a-bit before it does a full GC?
- nl 15y agoNo. I suppose in theory you could use JMX instrumentation and tie it to your load balancer, but I've never heard of it being done. (It's actually quite a good idea! hmm...)
- wolf550e 15y agoIf you trigger a full GC "from outside", the way you would trigger a restart, you'd perform whatever you do for a restart (stop accepting requests, finish accepted requests, be unavailable, start accepting requests). My point was that a full GC does not need to re-profile the code, re-JIT the code and warm data caches, like a newly restarted JVM does. Sending a user request to a JVM to be run in an interpreter with cold caches is not good for user satisfaction, so a newly restarted JVM needs to be given mock requests to warm it up (like a script for PGO static compilation). A JVM doing a full GC does not need all that to become fully ready, and if it has enough free RAM to defragment quickly, the process should be much more efficient.
- nl 15y agoI've never heard of people restarting the JVM to avoid GC pauses. Usually scheduled JVM restarts are to avoid "instability", which is usually a memory leak someone can't find or doesn't understand.
- tsotha 15y agoWe run JVM instances for months between releases. I don't think there's any reason to restart unless there's something wrong with the code.