I have a Java web application that works a lot with file conventions.
I am using Tomcat 6 as my servlet container. When many requests are submitted, Tomcat becomes very memory hungry. I wonder how I can fine-tune tomcat to reduce the memory consumption.
I am also considering changing my servlet container.
What do you suggest?
I have a Java web application that works a lot with file conventions. I
Share
You can limit the accepted/operational connection numbers in the
conf/server.xmlconfiguration.Have
and
or
in the config file and this should brake you.
Edit: Based on your comment you could move the processing into dedicated thread pool sized according to your CPU count (
Runtime.getRuntime().availableProcessors()) (see ExecutorService and Executors.) Then you could apply a bounded LinkedBlockingQueue to throttle the number of pending tasks (don’t forget to specify a RejectedExecutionHandler to do the blocking add when the queue gets full).Edit 2: Added links to the classes. There you find some samples.
Edit 3: A sample method I used in a project.
And you could use it this way:
And in your servlet