You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Rajat Gupta05 <Ra...@infosys.com> on 2009/12/01 12:21:46 UTC
How to set MaxThreads, MinSpareThreads on AJPconnector using Tomcat
5.5 API's
Hi,
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();
engine.setName("Catalina");
engine.setDefaultHost("localhost");
String ajp13_address = "127.0.0.1";
String ajp13_protocol = "ajp13";
org.apache.catalina.connector.Connector ajp13Connector = null;
ajp13Connector = em.createConnector(ajp13_address, ajp13_port, ajp13_protocol);
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.
In tomcat5.5 how do I set these values, Can you I use ChannelSocket/ChannelNioSocket for the same? What is difference between these two?
Please let me know if there is other alternative as well available.
Thanks
Rajat
Re: How to set MaxThreads, MinSpareThreads on AJPconnector using Tomcat 5.5 API's
Posted by Bill Barker <bi...@verizon.net>.
"Rajat Gupta05" <Ra...@infosys.com> wrote in message
news:784AE6E0EC8C2343975B7FF4DAEAA34B0CE66386D2@BLRKECMBX06.ad.infosys.com...
>Hi,
>
>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();
>engine.setName("Catalina");
>engine.setDefaultHost("localhost");
>
>String ajp13_address = "127.0.0.1";
>String ajp13_protocol = "ajp13";
>org.apache.catalina.connector.Connector ajp13Connector = null;
>ajp13Connector = em.createConnector(ajp13_address, ajp13_port,
>ajp13_protocol);
>
>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
like:
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
channelNioSocket.<property>.
>Please let me know if there is other alternative as well available.
>
>Thanks
>Rajat
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org