tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <>
Subject Re: How to set MaxThreads, MinSpareThreads on AJPconnector using Tomcat 5.5 API's
Date Wed, 02 Dec 2009 03:11:16 GMT

"Rajat Gupta05" <> wrote in message
>I am trying to create a AJP connector on Tomcat5.5 which is running in 
>Embedded mode by using following API's
>  Embedded em = new Embedded();
// create new engine
>StandardEngine engine = (StandardEngine) em.createEngine();
>String ajp13_address = "";
>String ajp13_protocol = "ajp13";
>org.apache.catalina.connector.Connector ajp13Connector = null;
>ajp13Connector = em.createConnector(ajp13_address, ajp13_port, 
>With Tomcat5.0 there were methods available in CoyotoConnector through 
>which we could set the MinProcessors and >MaxProcessers which are similar 
>to MinSpareThreads and MaxThreads in tomcat5.5.

You use the setProperty method on the Connector Object (the names are the 
same as in the Tomcat docs for setting it via server.xml).  So something 
    ajp13Connector.setProperty("maxThread", "200");
    ajp13Connector.setProperty("minSpareThreads", "25");

>In tomcat5.5 how do I set these values, Can you I use 
>ChannelSocket/ChannelNioSocket for the same? What is >difference between 
>these two?

ChannelSocket is the standard Java AJP/1.3 Channel for 5.5.x.  With this 
channel, the Threads will block after handling a request waiting for the 
next request on that particular Socket to come from Apache (or until it hits 
the connectionTimeout, which ever happens first).

ChannelNioSocket is the experimental (due to a lack of community interest) 
non-blocking Java Channel.  It works somewhat like the APR AJP/1.3 Connector 
in that Threads return to the pool after processing a request.  Then when 
another request comes in from Apache on a Socket, it gets a Thread from the 
pool, and uses it to process the request.  This means that the only active 
Tomcat Threads are those that are processing requests, so depending on your 
site's traffic pattern means that you can possibly handle a big pool of 
Socket connections between Apache and Tomcat with relatively few Threads. 
To use this one, you would specify an ajp13_port value of 0 in the 
createConnector call above, and use:
    ajp13Connector.setProperty("channelNioSocket.port","8009");  // required
    ajp13Connector.setProperty("channelNioSocket.maxThreads", "200");
Property name are generally the same as for ChannelSocket, but prefixed with 

>Please let me know if there is other alternative as well available.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message