Arno Arno - 2 months ago 20
Java Question

How to control the number of threads opened by Apache Tomcat

I have an app in tomcat which uses Selenium WebDriver. It uses post method to open an URL and get the net data. Every request opens a new Firefox window to do the "work" so I suppose, I need to limit the number opened to avoid server problems. I was thinking to do it via Filter for example, but I don't know how to. Any idea which approach will be the best?

Answer

I am not sure I understand the use case, but if you need to control tomcat HTTP threads, then you need to edit server.xml in /conf. Uncomment below section in this file and specify the number of threads you want

<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
    maxThreads="150" minSpareThreads="4"/>
-->