Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Sun JVM handle gigantic heap sizes without problems, and how?

I have heard several people claiming that you can not scale the JVM heap size up. I've heard claims of the practical limit being 4 gigabytes (I heard an IBM consultant say that), 10 gigabytes, 32 gigabytes, and so on... I simply can not believe any of those numbers and have been wondering about the issue now for a while.

So, I have three part question I would hope someone with experience could answer:

  1. Given the following case how would you tune the heap and GC settings?
  2. Would there be noticeable hickups (pauses of JVM etc) that would be noticed by the end users?
  3. Should this really still work? I think it should.

The case:

  • 64 bit platform
  • 64 cores
  • 64 gigabytes of memory
  • The application server is client facing (ie. Jboss/tomcat web application server) - complete pauses of JVM would probably be noticed by end users
  • Sun JVM, probably 1.5

To prove I am not asking you guys to do my homework this is what I came up with:

  1. -XX:+UseConcMarkSweepGC -XX:+AggressiveOpts -XX:+UnlockDiagnosticVMOptions -XX:-EliminateZeroing -Xmn768m -Xmx55000m
  2. CMS should reduce the amount of pauses, although it comes with overhead. The other settings for CMS seem to default automatically to the number of CPUs so they seem sane to me. The rest that I added are extras that might do good or bad generally for performance, and they should probably be tested.
  3. Definitely.
like image 803
utteputtes Avatar asked Nov 08 '09 10:11

utteputtes


2 Answers

I think it's going to be difficult for anybody to give you anything more than general advice, without having further knowledge of your application.

What I would suggest is that you use VisualGC (or the VisualGC plugin for VisualVM) to actually look at what the garbage collection is doing when your app is running. Once you have a greater understanding of how the GC is working alongside your application, it'll be far easier to tune it.

like image 149
Chris R Avatar answered Nov 06 '22 11:11

Chris R


#1. Given the following case how would you tune the heap and GC settings?

First, having 64 gigabytes of memory doesn't imply that you have to use them all for one JVM. Actually, it rather means you can run many of them. Then, it is impossible to answer your question without any access to your machine and application to measure and analyse things (knowing what your application is doing isn't enough). And no, I'm not asking to get access to your environment :)

#2. Would there be noticeable hickups (pauses of JVM etc) that would be noticed by the end users?

The goal of tuning is to find a good compromise between frequency and duration of (major) GCs. With a ~55g heap, GC won't be frequent but will take noticeable time, for sure (the bigger the heap, the longer the major GC). Using a Parallel or Concurrent garbage collector will help on multiprocessor systems but won't entirely solve this issue. Why do you need ~55g (this is mega ultra huge for a webapp IMO), that's my question. I'd rather run many clustered JVMs to handle load if required (at some point, the database will become the bottleneck anyway with a data oriented application).

#3. Should this really still work? I think it should.

Hmm... not sure I get the question. What is "this"? Instantiating a JVM with a big heap? Yes, it should. Is it equivalent to running several JVMs? No, certainly not.

PS: 4G is the maximum theoretical heap limit for the 32-bit JVM running on a 64-bit operating system (see Why can't I get a larger heap with the 32-bit JVM?)

PPS: On 64-bit VMs, you have 64 bits of addressability to work with resulting in a maximum Java heap size limited only by the amount of physical memory and swap space your system provides. (see How large a heap can I create using a 64-bit VM?)

like image 38
Pascal Thivent Avatar answered Nov 06 '22 10:11

Pascal Thivent