Reputation: 86687
If a tomcat
webserver is running multiple *.war
applications, and one of those apps cause a OutOfMemory
exception, this will take down the whole tomcat server.
Question: is it possible to prevent this? Eg assign a maximum memory limit to each war file, so that only this application will be shut down (or restartet)?
Upvotes: 0
Views: 231
Reputation: 16615
No.
Tomcat runs in a single JVM and web applications share memory as well as all other resources including CPU, thread-pools, network I/O etc.
The simplest solution to manage memory per web application is to run separate Tomcat instances. The memory overhead of doing this is a few 10s of MB assuming you reduce other resource allocations accordingly. For example, if you have a single Tomcat instance with 200 threads in the thread pool and you split that into 4 Tomcat instances if you allocate a total of more than 200 threads across all four instances you will need more memory for the extra threads.
Also keep in mind that you will be using resources less efficiently. In a single instance if one web application experiences a spike in use it can take advantage of resources (e.g. threads) the other web applications aren't using. If each web application has its own instance, that can't happen. This is the price you pay for isolating web applications.
Upvotes: 2