• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Tomcat Heap vs Physical Memory

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a rule of thumb for determining the required physical memory running a tomcat server based on the JVM heap allocated to Tomcat?  For instance, if I'm running Tomcat on Linux VM and have allocated 5G of heap to Tomcat, how much physical memory should I allocate to the Linux VM to ensure reliable performance?  I'd like to allocate only as much physical memory to the Linux VM as necessary without wasting any.
 
Saloon Keeper
Posts: 23409
159
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ideally ALL of your host memory will be non-virtual under normal operation, leaving virtual memory for the stress cases (note that this is different from a time-sharing system where you can over-commit and users won't notice).

That means that the entirety of the JVM and not just its heap should be allowed for.

Tomcat is actually quite frugal with its own memory. I prefer a heap minimum of 512M, can squeak by with 256M, and have heard reports of 128M. Mind, these are old statistics, but Tomcat doesn't pile on feature bloat like some systems do over time.

The real memory consumption, therefore is going to be from your webapps.So what I'd recommend is that you run some benchmarks and find out how much memory (heap and otherwise) Tomcat actually needs for your situation. You can then size physical RAM accordingly. Or, assuming the common case of Tomcat in a VM, size the VM RAM.
 
Warren Marble
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply. Here's what I'm seeing on my production servers that run a pretty memory intensive web app.  I'm allocating 10Gb of heap to Tomcat for the webapp, but according to top, the resident memory usage of Tomcat on all 3 servers is 11.6 Gb.  So Tomcat is using 1.6 Gb of additional memory above what I allocated for the heap.  Since I wouldn't expect Tomcat to use 1.6 Gb of additional memory if I allocated a much smaller heap, I assuming the additional memory Tomcat uses is somehow proportional to the size of the heap allocated.  Obviously just through observation I can determine how much total memory to allocate to my servers, but I was hoping someone might explain Tomcat's extra memory usage and how much memory it actually needs to run with a heap of X amount of memory.
 
Tim Holloway
Saloon Keeper
Posts: 23409
159
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are some tools to do heap analysis for JVMs that come with the JDK. They're pretty basic, but if your employer is cheap, like the ones around here are...

For the more well-budgeted, there are some commercial tools that can harvest that information and display in in ways that are easier and less labor--intensive to interpret.

The stock Oracle/Sun JVM has traditionally had 2 heap configuration options: an initial heap size and a maximum heap size, so that you would be assured enough RAM to minimally operate and a limit to how much extra the JVM would be allowed to grab before being denied expansion to infinity and beyond. Other options may exist depending on JVM vendor and version. You'd normally rune these parameters based on what you discovered about how your Tomcat instance - and its webapps - was operating.

Having said all that, any web application that's consuming of gigabytes of RAM deserves analysis. Is that much RAM really necessary? Where is it going - many user sessions? User sessions that have large amounts of session-scope objects? internal database caches (I inherited an app that loaded half the database on startup, which incidentally meant that every test launch took 20 minutes to become ready).

You might want to consider a ReST solition for future planning. Or perhaps even an elastic architecture if the workloads vary a lot. Or, you might have just one user who's doing complex analysis on massive sets of data and actually need all that RAM (although it's sometimes better to put that in a back-end). Just a few ideas.
 
He was expelled for perverse baking experiments. This tiny ad is a model student:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic