Hi all. I have a basic question i am getting a lot of spin on. Looking at this output from top it would seem obvious that this server is overloaded seeing how it has 0 cpu load and 95% memory usage. My admin told me its fine because it has quite a bit of cache.

Cpu(s): 0.0%us, 0.0%sy, 0.0%ni, 99.8%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 6105732k total, 5769024k used, 336708k free, 97040k buffers Swap: 2031608k total, 24744k used, 2006864k free, 1368728k cached

I can understand that the cache can be freed easily if needed but the basic poll I am trying to take is. Is this server ok or not and how best to reply to the "it has cache" answer if not.


asked 15 Jan '13, 16:09

FrDank's gravatar image

accept rate: 0%

edited 15 Jan '13, 16:20

cut & paste this and amend catalina.sh file:

JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1536m -Xmx1536m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC"

That will solve your problem.



answered 01 Feb '13, 12:32

ericorj's gravatar image

accept rate: 0%

thank you for your input. I really like the NewSize parameter and had not used before. If i understand it correctly it will shorten the space available for the first phase of collection so that new objects not needed anymore will likely be collected quicker resulting in quicker cleanup which of course would be desirable for an oltp app. I agree with all the other options mentioned while i would do my own math for the values based on number of deployed applications vs available space.

I am curiouos as to the reasoning for your recommendation on the file.encoding. This would seem to be a very reckless step to take as a change could have ill effects?

(16 Mar '13, 13:49) FrDank

At first sight, the server seems to be ok. Those numbers mean that 1368728k of the RAM (~1,4G) are used for cache and barely 24744k (24m) are swaped.

If those numbers are stable, and If you java aplication wont use any other resources (i.e. some CMS like liferay/alfresco make use of ImageMagick, OpenOffice, Xugler etc that can eat server's resources) the server will be fine most of the time (except for maybe some cron jobs)

But, actually, with only those numbers is not quite easy to guess a right answer. is Tomcat taking all the memory it has assigned? is there any other service in the machine, like apache or a db? If you have CPU at 0.0, it seems that you don't handle much traffic. The server could be ok now, and suffocate with the first uses of the app.

You can always lower your tomcat's memory use, and you'll gain stability, follow @ericorj 's answer to do so. For a production server, would be a nice idea to have more resources available.


answered 16 Mar '13, 09:50

wakaru44's gravatar image

accept rate: 0%

Thank you for your input. The fact that the cpu is at 0.0 and the memory usage is so high is kind of the point. This is while the server is essentially down because all traffic is cut off at the firewall at this moment.

I have a lpt of exp as a dev but not as an admin so I am looking for some basic levers. What i have determined since posting this is that i need to do some math around number of apps deployed with minand max memory allocation. To determine what is a proper sort of weight from that perspective? Does that make sense?

Then the real question is what is the right amount of allocation. This i guess would have to based on usage patterns * resource usage per request? or something like that. Seems like i can prolly get some of that data out of my mbeans.

(16 Mar '13, 13:49) FrDank

If you are deploying your own app (so you don't have any guidance or prior experiences to start from) the only way to really tune memory is to benchmark the apps. Behaviours differ even in same-kind-of apps (i have expertise with Liferay and Alfresco), so i won't tune jvm params like NewSize. Start by using JVM's own ergonomy, with "-server" should be enough. Then load test the app (i.e. JMeter), observe the garbage collector (visualvm/jvisualvm with visualgc plugin is great and simple) and then tune. Usually ConcMarkSweep gives good results for web apps.

While you are tuning, you can use profilers (JaMON, jvisualvm, jprofiler) to determine what's in memory, what's eating you CPU, etc.. accessing MBeans or trying to determine resources needed by each request could be a waste of time. You only need to analyze what can cause you performance problems.

(16 Mar '13, 14:15) wakaru44
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 15 Jan '13, 16:09

Seen: 2,981 times

Last updated: 16 Mar '13, 14:15

powered by OSQA