TomCat is using too much resources on a server
TomCat is a major consumer of resources on a server. This is why it is not recommended to create too many VDSs which use Tomcat on one server. The solution is to spread them on many servers.
However, there are two ways to reduce the amount of resources tomcat's java resources use:
- Limit the number of Java threads.
- Limit the maximum Java heap size.
The number of threads already reduced to 5 (maxProcessors prarameter in etc/tomcat4/server.xml file).
Maximum heap size can be set with -Xmx option of java (-Xmx64m for example). This can be done in tomcat4.conf file for example. The problem with this limit is that user's application can get 'out of memory' error in case it needs more memory, than this limit.
Another point that is important to know : When you are checking the memory usage for java processes - all process of a java tree uses the same memory block, this is why all threads have same amount of memory. For example, if a 'parent' java process uses 120 Mb RAM, then all his N threads show that they use 120M, but the total usage of them all is 120 Mb, and not 120*N.