You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Hermes Flying <fl...@yahoo.com> on 2013/01/16 17:01:30 UTC

Can not understand how maxThreads of Connectors works

Hi,
I am trying to understand how the maxThreads attribute of Connectors works. I did some tests in order to configure Tomcat to limit the number of concurrent client requests(as asked in my previous mail).
Did the following trivial configuration. 

maxThreads=1 and acceptCount=1
Then I send 2 concurrent requests from 2 clients and both were served!I was expecting that one would get a network failure!
I even tried maxThreads=0 and still the clients were served! How is this possible?

Thank you

Re: Can not understand how maxThreads of Connectors works

Posted by Hermes Flying <fl...@yahoo.com>.
I apologize, You asked precise versions. Will let you know asap (don't remember them by heart)




________________________________
 From: Hermes Flying <fl...@yahoo.com>
To: Tomcat Users List <us...@tomcat.apache.org>; Tomcat Users List <us...@tomcat.apache.org>; "aw@ice-sa.com" <aw...@ice-sa.com> 
Sent: Wednesday, January 16, 2013 6:29 PM
Subject: Re: Can not understand how maxThreads of Connectors works
 
Hi,
I am using Tomcat 6 (I think it is version 33 but will double check)
And JVM is Java 6 from IBM
Do you need exact versions?




________________________________
From: André Warnier <aw...@ice-sa.com>
To: Tomcat Users List <us...@tomcat.apache.org> 
Sent: Wednesday, January 16, 2013 6:18 PM
Subject: Re: Can not understand how maxThreads of Connectors works

Hermes Flying wrote:
> Hi,
> I am trying to understand how the maxThreads attribute of Connectors works. I did some tests in order to configure Tomcat to limit the number of concurrent client requests(as asked in my previous mail).
> Did the following trivial configuration. 
> maxThreads=1 and acceptCount=1
> Then I send 2 concurrent requests from 2 clients and both were served!I was expecting that one would get a network failure!
> I even tried maxThreads=0 and still the clients were served! How is this possible?
> 

Can you tell us which precise version of Tomcat you are using, with which precise JVM version, and also paste here a copy of your "server.xml" (any confidential information and comments removed) ?



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

Re: Can not understand how maxThreads of Connectors works

Posted by Hermes Flying <fl...@yahoo.com>.
Hi,
I am using Tomcat 6 (I think it is version 33 but will double check)
And JVM is Java 6 from IBM
Do you need exact versions?




________________________________
 From: André Warnier <aw...@ice-sa.com>
To: Tomcat Users List <us...@tomcat.apache.org> 
Sent: Wednesday, January 16, 2013 6:18 PM
Subject: Re: Can not understand how maxThreads of Connectors works
 
Hermes Flying wrote:
> Hi,
> I am trying to understand how the maxThreads attribute of Connectors works. I did some tests in order to configure Tomcat to limit the number of concurrent client requests(as asked in my previous mail).
> Did the following trivial configuration. 
> maxThreads=1 and acceptCount=1
> Then I send 2 concurrent requests from 2 clients and both were served!I was expecting that one would get a network failure!
> I even tried maxThreads=0 and still the clients were served! How is this possible?
> 

Can you tell us which precise version of Tomcat you are using, with which precise JVM version, and also paste here a copy of your "server.xml" (any confidential information and comments removed) ?



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

Re: Can not understand how maxThreads of Connectors works

Posted by André Warnier <aw...@ice-sa.com>.
Hermes Flying wrote:
> Hi,
> I am trying to understand how the maxThreads attribute of Connectors works. I did some tests in order to configure Tomcat to limit the number of concurrent client requests(as asked in my previous mail).
> Did the following trivial configuration. 
> 
> maxThreads=1 and acceptCount=1
> Then I send 2 concurrent requests from 2 clients and both were served!I was expecting that one would get a network failure!
> I even tried maxThreads=0 and still the clients were served! How is this possible?
> 

Can you tell us which precise version of Tomcat you are using, with which precise JVM 
version, and also paste here a copy of your "server.xml" (any confidential information and 
comments removed) ?



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Can not understand how maxThreads of Connectors works

Posted by Hermes Flying <fl...@yahoo.com>.
Hi,
This is the server.xml. Sorry for not replying promptly but I am "multitasking" in a lot of things :(

<Server port="18085" shutdown="SHUTDOWN">
  <!-- Comment these entries out to disable JMX MBeans support used for the 
       administration web application 
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
    -->
  <GlobalNamingResources>
   <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
       description="User database that can be updated and saved"
           factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
          pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>
  <Service name="Catalina">

   
    <Connector port="8443" maxThreads="5000" acceptCount="20000" enableLookups="false" connectionTimeout="150000" maxPostSize="1048576" 
        redirectPort="-1" scheme="https" sslProtocol="TLS" clientAuth="false" 
        keystoreType="PKCS12" truststoreType="PKCS12" protocols="TLSv1"
        SSLImplementation="com.ssl.SSL_Implementation"
    /> 
 
    
    <Connector port="8444" maxThreads="5000" acceptCount="20000" enableLookups="false" connectionTimeout="150000" maxPostSize="1048576" 
        redirectPort="-1" scheme="https" sslProtocol="TLS" clientAuth="want" 
        keystoreType="PKCS12" truststoreType="PKCS12" protocols="TLSv1"
        SSLImplementation="com.ssl.SSL_Implementation_2"
    /> 
 
    
 <Engine name="Catalina" defaultHost="localhost">
       <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>
      <Host name="localhost" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
       </Host>
    </Engine>
  </Service>
</Server>




________________________________
 From: Christopher Schultz <ch...@christopherschultz.net>
To: Tomcat Users List <us...@tomcat.apache.org> 
Sent: Thursday, January 17, 2013 6:57 PM
Subject: Re: Can not understand how maxThreads of Connectors works
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

André,

On 1/17/13 3:32 AM, André Warnier wrote:
> Quite a few messages ago, I asked the OP if he could copy/paste
> his server.xml.

Yes. Getting information from the OP seems to be difficult.

> The reason was that if his config uses an Executor, then I believe
> the Threads settings in the Connectors don't really matter, do they
> ?

Correct: setting executor="someExecutor" means that any
executor-related settings on the <Connector> will be ignored in favor
of those set in the <Connector>.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlD4LX4ACgkQ9CaO5/Lv0PAzegCgtxrX5Yx2V0UlEiDI1hK/vK+H
u20AmwWQz6+LToA3uPSSb8V1+kdPMY3N
=9fQb
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

Re: Fw: Can not understand how maxThreads of Connectors works

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hermes,

On 1/21/13 11:17 AM, Hermes Flying wrote:
> The web application works.I can not see any issue. What does this
> mean?

My guess is that Tomcat isn't using the configuration file you are
modifying.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlD+p6sACgkQ9CaO5/Lv0PDy/gCfSagY1K29u8OpugO4plJ84s/y
7nsAn1IQSsFeH7F0mnaEnRMATmNkoKLD
=Ioar
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Fw: Can not understand how maxThreads of Connectors works

Posted by Hermes Flying <fl...@yahoo.com>.
Hi,

I am sure that this server.xml is the one used, since there is no other present.
Also as mentioned my plan is to cut network access after a threshold. I used such small values e.g. 0,1,2 to see what happens. 
Also note that I am not using SUN JVM but IBM. Not sure if this makes a difference




________________________________
 From: André Warnier <aw...@ice-sa.com>
To: Tomcat Users List <us...@tomcat.apache.org> 
Sent: Thursday, January 24, 2013 7:14 PM
Subject: Re: Fw: Can not understand how maxThreads of Connectors works
 
Hermes Flying wrote:
> Hi,
> I don't see how this answers my issue.
> 1) You say 0 threads means 0 requests being processed. This does not happen. Requests are being processed. No error noticed

It is not only me saying it. The on-line documentation at https://tomcat.apache.org/tomcat-7.0-doc/config/http.html
says this :
quote

maxThreads    

The maximum number of request processing threads to be created by this Connector, which therefore determines the maximum number of simultaneous requests that can be handled. If not specified, this attribute is set to 200. If an executor is associated with this connector, this attribute is ignored as the connector will execute tasks using the executor rather than an internal thread pool.

unquote

Now, considering this, there are a number of possibilities :
- the documentation is totally wrong
- there is a bug in Tomcat
- your Tomcat server is not using this server.xml
- or, it being rather unlikely that processing 0 requests is what a normal user would want, the Tomcat developers have coded this so that an obviously nonsensical value of 0 would result in the default (of 200) being applied.

Pick any one of the above.

> 2)You say: "you are setting your parameters in the wrong place". This is not the case here.I already send an example server.xml. Will copy/paste it again bellow

Yes, but we cannot check from here if this is really the server.xml that your Tomcat is reading. Are you absolutely sure it is ? How ?

> 3)"It does not seem to make a lot of sense to set up a whole machinery like a host, a JVM and a Tomcat, just to process one single request at a time." I am not planning to do that, but I must see how the system behaves in various configuration. Tomcat does not seem to behave as expected in the trivial case.

The "trivial case" is 0 Threads ? What happens when you set it to 1 ?

> 4) "The default Tomcat settings are chosen by people who know what they are doing, to obtain a reasonable Tomcat behaviour over a reasonable range of conditions" What does this actually mean? That we are not supposed to configure Tomcat according to our needs?
> 

Of course you can. But if you are using nonsensical values, do you expect a sensible behaviour ?
Come on, man. This is open-source software, that you get to use for free.
This is not to say that it is not good software, nor that the developers do not try to make it as efficient and reliable as possible, nor that the people writing the documentation (also for free) do not make every effort to write it well and accurately.
On the other hand, it is kind of expected that people using Tomcat and configuring it, would use a bit of judgment and give the developers a bit of slack.

I am not a developer of Tomcat, but what I tried to provide in my explanation is a guideline as to how these parameters are supposed to work. That was to help you maybe find the reason for what appears to you as "not working", but which apparently other people cannot reproduce.

I just tried with Tomcat 6.0.24 under Windows, and when I set
maxThreads="0" in the HTTP Connector, Tomcat starts up without error in the log. But if I try to access it with a browser, the browser loops saying "connecting.." and never goes past that point.  If I set maxThreads="1", then Tomcat is answering with the homepage.

Same thing with Tomcat 7.0.21.

So I would say : check that the server.xml below is really the one that Tomcat is using.

(Additionally, I would say that it seems that when Tomcat is configured to not have any Threads to process requests, well it just does not process any.  Which seems to me like sensible behaviour under adverse circumstances.)



> 
> <?xml version='1.0' encoding='utf-8'?>
> <Server port="8005" shutdown="SHUTDOWN">
> 
>   <!--APR library loader. Documentation at /docs/apr.html -->
>   <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
>   <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
>   <Listener className="org.apache.catalina.core.JasperListener" />
>   <!-- Prevent memory leaks due to use of particular java/javax APIs-->
>   <Listener
>  className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
>   <!-- JMX Support for the Tomcat server.
>  Documentation at /docs/non-existent.html -->
>   <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
>   <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
> 
>   <!-- Global JNDI resources
>        Documentation at /docs/jndi-resources-howto.html
>   -->
>   <GlobalNamingResources>
>     <!-- Editable user database that can also be used by
>          UserDatabaseRealm to authenticate users
>     -->
>     <Resource name="UserDatabase" auth="Container"
>               type="org.apache.catalina.UserDatabase"
>               description="User database that can be updated and
>  saved"
>               factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
>               pathname="conf/tomcat-users.xml" />
>   </GlobalNamingResources>
> 
>   <!-- A "Service" is a collection of one or more "Connectors" that share
>        a single "Container" Note:  A "Service" is not itself a "Container",        so you may not define subcomponents such as "Valves" at this level.
>        Documentation at /docs/config/service.html
>    -->
>   <Service name="Catalina">
>       <!--The connectors can use a shared executor, you can define one or more named thread pools-->
>     <!--
>     <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"         maxThreads="150" minSpareThreads="4"/>
>     -->
>             <!-- A "Connector" represents an endpoint by which requests are received
>          and responses are returned. Documentation at :
>          Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
>          Java AJP  Connector: /docs/config/ajp.html
>          APR (HTTP/AJP) Connector: /docs/apr.html
>          Define a non-SSL HTTP/1.1 Connector on port 8080
>     -->
>     <Connector port="8080" maxThreads="0" acceptCount="1"
>  protocol="HTTP/1.1"                connectionTimeout="20000"                redirectPort="8443" />
> 
>     <!-- Define an AJP 1.3 Connector on port 8009 -->
>     <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
> 
> 
>     <!-- An Engine represents the entry point (within Catalina) that processes
>          every request.  The Engine implementation for Tomcat stand alone
>          analyzes the HTTP headers included with the request, and passes them
>          on to the appropriate Host (virtual host).
>          Documentation at /docs/config/engine.html
>  -->
> 
>     <!-- You should set jvmRoute to support load-balancing via AJP ie :
>     <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">             -->     <Engine name="Catalina" defaultHost="localhost">
> 
> 
>       <!-- This Realm uses the UserDatabase configured in the global JNDI
>            resources under the key "UserDatabase".  Any edits
>            that are performed against this UserDatabase are immediately
>            available for use by the Realm.  -->
>       <Realm
>  className="org.apache.catalina.realm.UserDatabaseRealm"
>              resourceName="UserDatabase"/>
> 
>       <!-- Define the default virtual host
>            Note: XML Schema validation will not work with Xerces 2.2.
>        -->
>       <Host name="localhost"  appBase="webapps"
>             unpackWARs="true" autoDeploy="true"
>             xmlValidation="false" xmlNamespaceAware="false">
> 
> 
>       </Host>
>     </Engine>
>   </Service>
> </Server>
> 
> 
> 
> 
> ________________________________
>  From: André Warnier <aw...@ice-sa.com>
> To: Tomcat Users List <us...@tomcat.apache.org> Sent: Thursday, January 24, 2013 11:53 AM
> Subject: Re: Fw: Can not understand how maxThreads of Connectors works
>  Hermes Flying wrote:
>> Hi,
>> So is there an explanation for this? All I am interested is make sure that after a limit, clients attempted to connect are stopped based on my configuration on maxThreads and accept count.
>> But I can not figure out how this works.
>> 
> 
> (This all being explained in vernacular language to which experts may object).
> 
> Threads in Tomcat serve to process requests.  Each Thread can process one request.
> 0 Threads = 0 requests being processed.
> n Threads = n requests can be processed simultaneously (kind of).
> 
> Threads "belong to" either a Connector (by default), or an Executor (if you configure several Connectors to use an Executor, then they use the common pool of Threads of the Executor, instead of their own individual pool of Threads).
> 
> Having a common pool of Threads between several Connectors is normally more efficient and allows for a smoother operation.  Otherwise you could have the case that requests arriving through one Connector (e.g. HTTP) are being starved because this particular Connector has no more Threads available, while on the other hand another Connector (e.g. AJP) still has plenty of capacity.
> 
> The "acceptCount" is another matter entirely, working at a deeper level.
> Before a Thread is assigned to process a request,
> - the client requests a TCP connection to the server
> - the server must "accept" this connection. If it doesn't within a certain time, the client will get an error (connect timeout).
> - when the server accepts the connection, it goes into a queue. The length of that queue corresponds to the acceptCount of the corresponding Connector.
> (If the accept queue is already full, the connection request will be rejected).
> As long as the server does no further action, an accepted connection stays in the queue and the client request does not proceed. If that lasts a long time, the client may timeout (usually saying that the server is not responsive).
> - whenever the server feels like it (for example, when it sees that it has at least one Thread free to handle a request), it will pop the first connection from the accept queue, and pass it to a Thread to be processed.
> Now a Thread is assigned to process this request, so one less Thread is available in the pool of Threads.
> - if another client connection happens now, it goes into the accept queue.
> - whenever the original Thread is done processing the request, the Thread goes back into the pool of available Threads, and could be assigned to another client request currently sitting in the accept queue.
> 
> That's roughly how it works.
> If it does not do so in your case, then it must mean that you are setting your parameters in the wrong place, and Tomcat is either not seeing them at all, or ignoring them because they are not where they should be.
> 
> The default Tomcat settings are chosen by people who know what they are doing, to obtain a reasonable Tomcat behaviour over a reasonable range of conditions.
> If you change these settings, you can get a behaviour that is no longer reasonable or balanced.
> For example, if you set the accepCount to 1 and maxThreads to 1, then you can have the following :
> - 1 request accepted and allocated a Thread, thus in process
> - 1 additional request being queued in the accept queue, waiting for a Thread to become available
> And any additional client request arriving at that time will be rejected at the TCP level.  That will hardly result in an error that is understandable by the clients.
> 
> Intuitively, it does not seem to make a lot of sense to set up a whole machinery like a host, a JVM and a Tomcat, just to process one single request at a time.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

Re: Can not understand how maxThreads of Connectors works

Posted by Ben Stringer <be...@burbong.com>.

On 25/01/2013, at 6:09 AM, Christopher Schultz <ch...@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> André,
> 
> On 1/24/13 12:14 PM, André Warnier wrote:
>> Now, considering this, there are a number of possibilities : - the
>> documentation is totally wrong - there is a bug in Tomcat - your
>> Tomcat server is not using this server.xml - or, it being rather
>> unlikely that processing 0 requests is what a normal user would
>> want, the Tomcat developers have coded this so that an obviously
>> nonsensical value of 0 would result in the default (of 200) being
>> applied.
> 
> That last one is not true: the code will happily accept maxThreads=0
> but then will throw an exception when the connector tries to actually
> start its Executor.
> 
> I suspect Hermes is editing some unrelated server.xml file: his
> observations seem totally in-line with that hypothesis.
> 
> Hermes, try modifying your server.xml file to be syntactically
> incorrect. For example, put a "<!--" into the middle of the file and
> try to start Tomcat. If it still starts, you are editing the wrong file.

And if using a Linux OS, you can use "lsof" to identify what file descriptors the tomcat JVM has opened, this is handy for tracking down issues with misplaced  conf files.

Cheers, Ben

> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
> 
> iEYEAREIAAYFAlEBhv8ACgkQ9CaO5/Lv0PDUWgCfWY/BUyhl4rQkZUC19SNB2P72
> sckAn2dZwfEd7uVZz6eg0HuPmuZC81j6
> =YVBj
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Fw: Can not understand how maxThreads of Connectors works

Posted by Mark Thomas <ma...@apache.org>.
On 25/01/2013 19:58, Hermes Flying wrote:
> Hi, I actually deploy in 2 servers one in 6 and one in 5. I noticed
> the same behavior described (that was not believed). I did not aim
> in taking anyone's time. All I wanted to do is verify the
> functionality using really small values. In a previous mail it was
> written by someone that he tested this in 6 and he said the browser
> stuck. I did not notice that.

Exact Tomcat version. Exact connector configuration...

This is getting tiresome.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Fw: Can not understand how maxThreads of Connectors works

Posted by Hermes Flying <fl...@yahoo.com>.
Hi,
I actually deploy in 2 servers one in 6 and one in 5. I noticed the same behavior described (that was not believed).
I did not aim in taking anyone's time.
All I wanted to do is verify the functionality using really small values.
In a previous mail it was written by someone that he tested this in 6 and he said the browser stuck.
I did not notice that.




________________________________
 From: Christopher Schultz <ch...@christopherschultz.net>
To: Tomcat Users List <us...@tomcat.apache.org> 
Sent: Friday, January 25, 2013 9:34 PM
Subject: Re: Fw: Can not understand how maxThreads of Connectors works
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hermes,

On 1/25/13 4:16 AM, Hermes Flying wrote:
> I am using the correct server.xml. In the version 5.5.36 the 
> maxThreads of 0 has no effect due to this code in 
> org.apache.tomcat.util.net.PoolTcpEndpoint

You said you were using Tomcat 6. Now you say you are using Tomcat
5.5.36. This is why I asked (long ago) to give us exact versions.

> So what I observe is correct. I.e. with 0 there is no error and
> also my web application works fine since it defaults to 200
> threads. Will check this out in Tomcat 6

Maybe then we'll finally be on the same page.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlEC3kIACgkQ9CaO5/Lv0PBZUQCfWTYi3fmEi45N+wWGCVqz+yGf
4ZUAn1CdzM0CexovENDj3YJBhYCa1JIG
=Gc1n
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

Re: Fw: Can not understand how maxThreads of Connectors works

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hermes,

On 1/25/13 4:16 AM, Hermes Flying wrote:
> I am using the correct server.xml. In the version 5.5.36 the 
> maxThreads of 0 has no effect due to this code in 
> org.apache.tomcat.util.net.PoolTcpEndpoint

You said you were using Tomcat 6. Now you say you are using Tomcat
5.5.36. This is why I asked (long ago) to give us exact versions.

> So what I observe is correct. I.e. with 0 there is no error and
> also my web application works fine since it defaults to 200
> threads. Will check this out in Tomcat 6

Maybe then we'll finally be on the same page.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlEC3kIACgkQ9CaO5/Lv0PBZUQCfWTYi3fmEi45N+wWGCVqz+yGf
4ZUAn1CdzM0CexovENDj3YJBhYCa1JIG
=Gc1n
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Fw: Can not understand how maxThreads of Connectors works

Posted by Mark Thomas <ma...@apache.org>.
> On Jan 16, you wrote this :
> 
> Hermes Flying wrote:
>> Hi,
>> I am using Tomcat 6 (I think it is version 33 but will double check)
>> And JVM is Java 6 from IBM
>> Do you need exact versions?
>>
> 
> And you haven't provided any other version number since then.
> 
> So why are you quoting Tomcat 5.5.36 code above ?
> Do you actually enjoy confusing people on this list and causing them to
> uselessly spend time answering your questions and trying to reproduce
> the symptoms which you indicate ?

+1

The behaviour in 6.0.x is significantly different to that of 5.5.x.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Fw: Can not understand how maxThreads of Connectors works

Posted by André Warnier <aw...@ice-sa.com>.
Hermes Flying wrote:
> I am using the correct server.xml.
> In the version 5.5.36 the maxThreads of 0 has no effect due to this code in org.apache.tomcat.util.net.PoolTcpEndpoint
> 
> 
>  public void setMaxThreads(int maxThreads) {
>     if( maxThreads > 0)
>         tp.setMaxThreads(maxThreads);
>     }
> 
> So what I observe is correct. I.e. with 0 there is no error and also my web application works fine since it defaults to 200 threads.
> Will check this out in Tomcat 6
> 

On Jan 16, you wrote this :

Hermes Flying wrote:
 > Hi,
 > I am using Tomcat 6 (I think it is version 33 but will double check)
 > And JVM is Java 6 from IBM
 > Do you need exact versions?
 >

And you haven't provided any other version number since then.

So why are you quoting Tomcat 5.5.36 code above ?
Do you actually enjoy confusing people on this list and causing them to uselessly spend 
time answering your questions and trying to reproduce the symptoms which you indicate ?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Fw: Can not understand how maxThreads of Connectors works

Posted by Hermes Flying <fl...@yahoo.com>.
I am using the correct server.xml.
In the version 5.5.36 the maxThreads of 0 has no effect due to this code in org.apache.tomcat.util.net.PoolTcpEndpoint


 public void setMaxThreads(int maxThreads) {
    if( maxThreads > 0)
        tp.setMaxThreads(maxThreads);
    }

So what I observe is correct. I.e. with 0 there is no error and also my web application works fine since it defaults to 200 threads.
Will check this out in Tomcat 6





________________________________
 From: Christopher Schultz <ch...@christopherschultz.net>
To: Tomcat Users List <us...@tomcat.apache.org> 
Sent: Thursday, January 24, 2013 9:09 PM
Subject: Re: Fw: Can not understand how maxThreads of Connectors works
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

André,

On 1/24/13 12:14 PM, André Warnier wrote:
> Now, considering this, there are a number of possibilities : - the
> documentation is totally wrong - there is a bug in Tomcat - your
> Tomcat server is not using this server.xml - or, it being rather
> unlikely that processing 0 requests is what a normal user would
> want, the Tomcat developers have coded this so that an obviously
> nonsensical value of 0 would result in the default (of 200) being
> applied.

That last one is not true: the code will happily accept maxThreads=0
but then will throw an exception when the connector tries to actually
start its Executor.

I suspect Hermes is editing some unrelated server.xml file: his
observations seem totally in-line with that hypothesis.

Hermes, try modifying your server.xml file to be syntactically
incorrect. For example, put a "<!--" into the middle of the file and
try to start Tomcat. If it still starts, you are editing the wrong file.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlEBhv8ACgkQ9CaO5/Lv0PDUWgCfWY/BUyhl4rQkZUC19SNB2P72
sckAn2dZwfEd7uVZz6eg0HuPmuZC81j6
=YVBj
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

Re: Fw: Can not understand how maxThreads of Connectors works

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

André,

On 1/24/13 12:14 PM, André Warnier wrote:
> Now, considering this, there are a number of possibilities : - the
> documentation is totally wrong - there is a bug in Tomcat - your
> Tomcat server is not using this server.xml - or, it being rather
> unlikely that processing 0 requests is what a normal user would
> want, the Tomcat developers have coded this so that an obviously
> nonsensical value of 0 would result in the default (of 200) being
> applied.

That last one is not true: the code will happily accept maxThreads=0
but then will throw an exception when the connector tries to actually
start its Executor.

I suspect Hermes is editing some unrelated server.xml file: his
observations seem totally in-line with that hypothesis.

Hermes, try modifying your server.xml file to be syntactically
incorrect. For example, put a "<!--" into the middle of the file and
try to start Tomcat. If it still starts, you are editing the wrong file.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlEBhv8ACgkQ9CaO5/Lv0PDUWgCfWY/BUyhl4rQkZUC19SNB2P72
sckAn2dZwfEd7uVZz6eg0HuPmuZC81j6
=YVBj
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Fw: Can not understand how maxThreads of Connectors works

Posted by André Warnier <aw...@ice-sa.com>.
Hermes Flying wrote:
> Hi,
> I don't see how this answers my issue.
> 1) You say 0 threads means 0 requests being processed. This does not happen. Requests are being processed. No error noticed

It is not only me saying it. The on-line documentation at 
https://tomcat.apache.org/tomcat-7.0-doc/config/http.html
says this :
quote

maxThreads	

The maximum number of request processing threads to be created by this Connector, which 
therefore determines the maximum number of simultaneous requests that can be handled. If 
not specified, this attribute is set to 200. If an executor is associated with this 
connector, this attribute is ignored as the connector will execute tasks using the 
executor rather than an internal thread pool.

unquote

Now, considering this, there are a number of possibilities :
- the documentation is totally wrong
- there is a bug in Tomcat
- your Tomcat server is not using this server.xml
- or, it being rather unlikely that processing 0 requests is what a normal user would 
want, the Tomcat developers have coded this so that an obviously nonsensical value of 0 
would result in the default (of 200) being applied.

Pick any one of the above.

> 2)You say: "you are setting your parameters in the wrong place". This is not the case here.I already send an example server.xml. Will copy/paste it again bellow

Yes, but we cannot check from here if this is really the server.xml that your Tomcat is 
reading. Are you absolutely sure it is ? How ?

> 3)"It does not seem to make a lot of sense to set up a whole machinery like a host, a JVM and a Tomcat, just to process one single request at a time." I am not planning to do that, but I must see how the system behaves in various configuration. Tomcat does not seem to behave as expected in the trivial case.

The "trivial case" is 0 Threads ? What happens when you set it to 1 ?

> 4) "The default Tomcat settings are chosen by people who know what they are 
> doing, to obtain a reasonable Tomcat behaviour over a reasonable range 
> of conditions" What does this actually mean? That we are not supposed to configure Tomcat according to our needs?
> 

Of course you can. But if you are using nonsensical values, do you expect a sensible 
behaviour ?
Come on, man. This is open-source software, that you get to use for free.
This is not to say that it is not good software, nor that the developers do not try to 
make it as efficient and reliable as possible, nor that the people writing the 
documentation (also for free) do not make every effort to write it well and accurately.
On the other hand, it is kind of expected that people using Tomcat and configuring it, 
would use a bit of judgment and give the developers a bit of slack.

I am not a developer of Tomcat, but what I tried to provide in my explanation is a 
guideline as to how these parameters are supposed to work. That was to help you maybe find 
the reason for what appears to you as "not working", but which apparently other people 
cannot reproduce.

I just tried with Tomcat 6.0.24 under Windows, and when I set
maxThreads="0" in the HTTP Connector, Tomcat starts up without error in the log. But if I 
try to access it with a browser, the browser loops saying "connecting.." and never goes 
past that point.  If I set maxThreads="1", then Tomcat is answering with the homepage.

Same thing with Tomcat 7.0.21.

So I would say : check that the server.xml below is really the one that Tomcat is using.

(Additionally, I would say that it seems that when Tomcat is configured to not have any 
Threads to process requests, well it just does not process any.  Which seems to me like 
sensible behaviour under adverse circumstances.)



> 
> <?xml version='1.0' encoding='utf-8'?>
> <Server port="8005" shutdown="SHUTDOWN">
> 
>   <!--APR library loader. Documentation at /docs/apr.html -->
>   <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
>   <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
>   <Listener className="org.apache.catalina.core.JasperListener" />
>   <!-- Prevent memory leaks due to use of particular java/javax APIs-->
>   <Listener
>  className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
>   <!-- JMX Support for the Tomcat server.
>  Documentation at /docs/non-existent.html -->
>   <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
>   <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
> 
>   <!-- Global JNDI resources
>        Documentation at /docs/jndi-resources-howto.html
>   -->
>   <GlobalNamingResources>
>     <!-- Editable user database that can also be used by
>          UserDatabaseRealm to authenticate users
>     -->
>     <Resource name="UserDatabase" auth="Container"
>               type="org.apache.catalina.UserDatabase"
>               description="User database that can be updated and
>  saved"
>               factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
>               pathname="conf/tomcat-users.xml" />
>   </GlobalNamingResources>
> 
>   <!-- A "Service" is a collection of one or more "Connectors" that share
>        a single "Container" Note:  A "Service" is not itself a "Container", 
>        so you may not define subcomponents such as "Valves" at this level.
>        Documentation at /docs/config/service.html
>    -->
>   <Service name="Catalina">
>   
>     <!--The connectors can use a shared executor, you can define one or more named thread pools-->
>     <!--
>    
>  <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
>         maxThreads="150" minSpareThreads="4"/>
>     -->
>     
>     
>     <!-- A "Connector" represents an endpoint by which requests are received
>          and responses are returned. Documentation at :
>          Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
>          Java AJP  Connector: /docs/config/ajp.html
>          APR (HTTP/AJP) Connector: /docs/apr.html
>          Define a non-SSL HTTP/1.1 Connector on port 8080
>     -->
>     <Connector port="8080" maxThreads="0" acceptCount="1"
>  protocol="HTTP/1.1" 
>                connectionTimeout="20000" 
>                redirectPort="8443" />
> 
>     <!-- Define an AJP 1.3 Connector on port 8009 -->
>     <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
> 
> 
>     <!-- An Engine represents the entry point (within Catalina) that processes
>          every request.  The Engine implementation for Tomcat stand alone
>          analyzes the HTTP headers included with the request, and passes them
>          on to the appropriate Host (virtual host).
>          Documentation at /docs/config/engine.html
>  -->
> 
>     <!-- You should set jvmRoute to support load-balancing via AJP ie :
>     <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">         
>     --> 
>     <Engine name="Catalina" defaultHost="localhost">
> 
> 
>       <!-- This Realm uses the UserDatabase configured in the global JNDI
>            resources under the key "UserDatabase".  Any edits
>            that are performed against this UserDatabase are immediately
>            available for use by the Realm.  -->
>       <Realm
>  className="org.apache.catalina.realm.UserDatabaseRealm"
>              resourceName="UserDatabase"/>
> 
>       <!-- Define the default virtual host
>            Note: XML Schema validation will not work with Xerces 2.2.
>        -->
>       <Host name="localhost"  appBase="webapps"
>             unpackWARs="true" autoDeploy="true"
>             xmlValidation="false" xmlNamespaceAware="false">
> 
> 
>       </Host>
>     </Engine>
>   </Service>
> </Server>
> 
> 
> 
> 
> ________________________________
>  From: André Warnier <aw...@ice-sa.com>
> To: Tomcat Users List <us...@tomcat.apache.org> 
> Sent: Thursday, January 24, 2013 11:53 AM
> Subject: Re: Fw: Can not understand how maxThreads of Connectors works
>  
> Hermes Flying wrote:
>> Hi,
>> So is there an explanation for this? All I am interested is make sure that after a limit, clients attempted to connect are stopped based on my configuration on maxThreads and accept count.
>> But I can not figure out how this works.
>>
> 
> (This all being explained in vernacular language to which experts may object).
> 
> Threads in Tomcat serve to process requests.  Each Thread can process one request.
> 0 Threads = 0 requests being processed.
> n Threads = n requests can be processed simultaneously (kind of).
> 
> Threads "belong to" either a Connector (by default), or an Executor (if you configure several Connectors to use an Executor, then they use the common pool of Threads of the Executor, instead of their own individual pool of Threads).
> 
> Having a common pool of Threads between several Connectors is normally more efficient and allows for a smoother operation.  Otherwise you could have the case that requests arriving through one Connector (e.g. HTTP) are being starved because this particular Connector has no more Threads available, while on the other hand another Connector (e.g. AJP) still has plenty of capacity.
> 
> The "acceptCount" is another matter entirely, working at a deeper level.
> Before a Thread is assigned to process a request,
> - the client requests a TCP connection to the server
> - the server must "accept" this connection. If it doesn't within a certain time, the client will get an error (connect timeout).
> - when the server accepts the connection, it goes into a queue. The length of that queue corresponds to the acceptCount of the corresponding Connector.
> (If the accept queue is already full, the connection request will be rejected).
> As long as the server does no further action, an accepted connection stays in the queue and the client request does not proceed. If that lasts a long time, the client may timeout (usually saying that the server is not responsive).
> - whenever the server feels like it (for example, when it sees that it has at least one Thread free to handle a request), it will pop the first connection from the accept queue, and pass it to a Thread to be processed.
> Now a Thread is assigned to process this request, so one less Thread is available in the pool of Threads.
> - if another client connection happens now, it goes into the accept queue.
> - whenever the original Thread is done processing the request, the Thread goes back into the pool of available Threads, and could be assigned to another client request currently sitting in the accept queue.
> 
> That's roughly how it works.
> If it does not do so in your case, then it must mean that you are setting your parameters in the wrong place, and Tomcat is either not seeing them at all, or ignoring them because they are not where they should be.
> 
> The default Tomcat settings are chosen by people who know what they are doing, to obtain a reasonable Tomcat behaviour over a reasonable range of conditions.
> If you change these settings, you can get a behaviour that is no longer reasonable or balanced.
> For example, if you set the accepCount to 1 and maxThreads to 1, then you can have the following :
> - 1 request accepted and allocated a Thread, thus in process
> - 1 additional request being queued in the accept queue, waiting for a Thread to become available
> And any additional client request arriving at that time will be rejected at the TCP level.  That will hardly result in an error that is understandable by the clients.
> 
> Intuitively, it does not seem to make a lot of sense to set up a whole machinery like a host, a JVM and a Tomcat, just to process one single request at a time.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Fw: Can not understand how maxThreads of Connectors works

Posted by Hermes Flying <fl...@yahoo.com>.
Hi,
I don't see how this answers my issue.
1) You say 0 threads means 0 requests being processed. This does not happen. Requests are being processed. No error noticed
2)You say: "you are setting your parameters in the wrong place". This is not the case here.I already send an example server.xml. Will copy/paste it again bellow
3)"It does not seem to make a lot of sense to set up a whole machinery like a host, a JVM and a Tomcat, just to process one single request at a time." I am not planning to do that, but I must see how the system behaves in various configuration. Tomcat does not seem to behave as expected in the trivial case.
4) "The default Tomcat settings are chosen by people who know what they are 
doing, to obtain a reasonable Tomcat behaviour over a reasonable range 
of conditions" What does this actually mean? That we are not supposed to configure Tomcat according to our needs?


<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">

  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener
 className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <!-- JMX Support for the Tomcat server.
 Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and
 saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container", 
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">
  
    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
   
 <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
        maxThreads="150" minSpareThreads="4"/>
    -->
    
    
    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8080" maxThreads="0" acceptCount="1"
 protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html
 -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">         
    --> 
    <Engine name="Catalina" defaultHost="localhost">


      <!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm.  -->
      <Realm
 className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">


      </Host>
    </Engine>
  </Service>
</Server>




________________________________
 From: André Warnier <aw...@ice-sa.com>
To: Tomcat Users List <us...@tomcat.apache.org> 
Sent: Thursday, January 24, 2013 11:53 AM
Subject: Re: Fw: Can not understand how maxThreads of Connectors works
 
Hermes Flying wrote:
> Hi,
> So is there an explanation for this? All I am interested is make sure that after a limit, clients attempted to connect are stopped based on my configuration on maxThreads and accept count.
> But I can not figure out how this works.
> 

(This all being explained in vernacular language to which experts may object).

Threads in Tomcat serve to process requests.  Each Thread can process one request.
0 Threads = 0 requests being processed.
n Threads = n requests can be processed simultaneously (kind of).

Threads "belong to" either a Connector (by default), or an Executor (if you configure several Connectors to use an Executor, then they use the common pool of Threads of the Executor, instead of their own individual pool of Threads).

Having a common pool of Threads between several Connectors is normally more efficient and allows for a smoother operation.  Otherwise you could have the case that requests arriving through one Connector (e.g. HTTP) are being starved because this particular Connector has no more Threads available, while on the other hand another Connector (e.g. AJP) still has plenty of capacity.

The "acceptCount" is another matter entirely, working at a deeper level.
Before a Thread is assigned to process a request,
- the client requests a TCP connection to the server
- the server must "accept" this connection. If it doesn't within a certain time, the client will get an error (connect timeout).
- when the server accepts the connection, it goes into a queue. The length of that queue corresponds to the acceptCount of the corresponding Connector.
(If the accept queue is already full, the connection request will be rejected).
As long as the server does no further action, an accepted connection stays in the queue and the client request does not proceed. If that lasts a long time, the client may timeout (usually saying that the server is not responsive).
- whenever the server feels like it (for example, when it sees that it has at least one Thread free to handle a request), it will pop the first connection from the accept queue, and pass it to a Thread to be processed.
Now a Thread is assigned to process this request, so one less Thread is available in the pool of Threads.
- if another client connection happens now, it goes into the accept queue.
- whenever the original Thread is done processing the request, the Thread goes back into the pool of available Threads, and could be assigned to another client request currently sitting in the accept queue.

That's roughly how it works.
If it does not do so in your case, then it must mean that you are setting your parameters in the wrong place, and Tomcat is either not seeing them at all, or ignoring them because they are not where they should be.

The default Tomcat settings are chosen by people who know what they are doing, to obtain a reasonable Tomcat behaviour over a reasonable range of conditions.
If you change these settings, you can get a behaviour that is no longer reasonable or balanced.
For example, if you set the accepCount to 1 and maxThreads to 1, then you can have the following :
- 1 request accepted and allocated a Thread, thus in process
- 1 additional request being queued in the accept queue, waiting for a Thread to become available
And any additional client request arriving at that time will be rejected at the TCP level.  That will hardly result in an error that is understandable by the clients.

Intuitively, it does not seem to make a lot of sense to set up a whole machinery like a host, a JVM and a Tomcat, just to process one single request at a time.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

Re: Fw: Can not understand how maxThreads of Connectors works

Posted by André Warnier <aw...@ice-sa.com>.
Hermes Flying wrote:
> Hi,
> So is there an explanation for this? All I am interested is make sure that after a limit, clients attempted to connect are stopped based on my configuration on maxThreads and accept count.
> But I can not figure out how this works.
> 

(This all being explained in vernacular language to which experts may object).

Threads in Tomcat serve to process requests.  Each Thread can process one request.
0 Threads = 0 requests being processed.
n Threads = n requests can be processed simultaneously (kind of).

Threads "belong to" either a Connector (by default), or an Executor (if you configure 
several Connectors to use an Executor, then they use the common pool of Threads of the 
Executor, instead of their own individual pool of Threads).

Having a common pool of Threads between several Connectors is normally more efficient and 
allows for a smoother operation.  Otherwise you could have the case that requests arriving 
through one Connector (e.g. HTTP) are being starved because this particular Connector has 
no more Threads available, while on the other hand another Connector (e.g. AJP) still has 
plenty of capacity.

The "acceptCount" is another matter entirely, working at a deeper level.
Before a Thread is assigned to process a request,
- the client requests a TCP connection to the server
- the server must "accept" this connection. If it doesn't within a certain time, the 
client will get an error (connect timeout).
- when the server accepts the connection, it goes into a queue. The length of that queue 
corresponds to the acceptCount of the corresponding Connector.
(If the accept queue is already full, the connection request will be rejected).
As long as the server does no further action, an accepted connection stays in the queue 
and the client request does not proceed. If that lasts a long time, the client may timeout 
(usually saying that the server is not responsive).
- whenever the server feels like it (for example, when it sees that it has at least one 
Thread free to handle a request), it will pop the first connection from the accept queue, 
and pass it to a Thread to be processed.
Now a Thread is assigned to process this request, so one less Thread is available in the 
pool of Threads.
- if another client connection happens now, it goes into the accept queue.
- whenever the original Thread is done processing the request, the Thread goes back into 
the pool of available Threads, and could be assigned to another client request currently 
sitting in the accept queue.

That's roughly how it works.
If it does not do so in your case, then it must mean that you are setting your parameters 
in the wrong place, and Tomcat is either not seeing them at all, or ignoring them because 
they are not where they should be.

The default Tomcat settings are chosen by people who know what they are doing, to obtain a 
reasonable Tomcat behaviour over a reasonable range of conditions.
If you change these settings, you can get a behaviour that is no longer reasonable or 
balanced.
For example, if you set the accepCount to 1 and maxThreads to 1, then you can have the 
following :
- 1 request accepted and allocated a Thread, thus in process
- 1 additional request being queued in the accept queue, waiting for a Thread to become 
available
And any additional client request arriving at that time will be rejected at the TCP level. 
  That will hardly result in an error that is understandable by the clients.

Intuitively, it does not seem to make a lot of sense to set up a whole machinery like a 
host, a JVM and a Tomcat, just to process one single request at a time.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Fw: Can not understand how maxThreads of Connectors works

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hermes,

On 1/23/13 5:25 PM, Hermes Flying wrote:
> So is there an explanation for this? All I am interested is make
> sure that after a limit, clients attempted to connect are stopped
> based on my configuration on maxThreads and accept count. But I can
> not figure out how this works.

Sorry, but your description of what you experience does not match the
experiences of others. The conclusion is that you are not configuring
Tomcat the way you claim to be configuring it.

You never told us what versions of things you were using. You never
told us what OS you are on. You never told us how you are launching
Tomcat. You never told us where your configuration files are.

I cannot help you any further without the above information. I believe
that others can also not help you without this information.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlEAjhwACgkQ9CaO5/Lv0PCSNQCgjrNeg1OWsZvWRWVfqOCEWRmP
LBsAn26IFVIG/5zXXofpNPnxEQXrFWD/
=XZvE
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Fw: Can not understand how maxThreads of Connectors works

Posted by Hermes Flying <fl...@yahoo.com>.
Hi,
So is there an explanation for this? All I am interested is make sure that after a limit, clients attempted to connect are stopped based on my configuration on maxThreads and accept count.
But I can not figure out how this works.






________________________________
 From: Hermes Flying <fl...@yahoo.com>
To: Tomcat Users List <us...@tomcat.apache.org> 
Sent: Monday, January 21, 2013 6:17 PM
Subject: Re: Fw: Can not understand how maxThreads of Connectors works
 
The web application works.I can not see any issue. What does this mean?



________________________________
From: Mark Thomas <ma...@apache.org>
To: Tomcat Users List <us...@tomcat.apache.org> 
Sent: Monday, January 21, 2013 11:06 AM
Subject: Re: Fw: Can not understand how maxThreads of Connectors works

On 21/01/2013 07:07, Hermes Flying wrote:
> 
> Hi,
> Is there any update on this? I don't see any problem setting maxThreads=0

And if you try making a request with a Tomcat instance that uses that
configuration?

Mark


> 
> Thank you
> 
> 
> ----- Forwarded Message -----
> From: Hermes Flying <fl...@yahoo.com>
> To: Tomcat Users List <us...@tomcat.apache.org> 
> Sent: Friday, January 18, 2013 8:55 AM
> Subject: Re: Can not understand how maxThreads of Connectors works
>  
> 
> Hi Chris,
> Tried with this simple server.xml and maxThreads=0 but I did not see any kind of errors.Attached the catalina logs
> 
> <?xml version='1.0' encoding='utf-8'?>
> <Server port="8005" shutdown="SHUTDOWN">
> 
>   <!--APR library loader. Documentation at /docs/apr.html -->
>   <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
>   <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
>   <Listener className="org.apache.catalina.core.JasperListener" />
>   <!-- Prevent memory leaks due to use of particular java/javax APIs-->
>   <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
>   <!-- JMX Support for the Tomcat server.
>  Documentation at /docs/non-existent.html -->
>   <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
>   <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
> 
>   <!-- Global JNDI resources
>        Documentation at /docs/jndi-resources-howto.html
>   -->
>   <GlobalNamingResources>
>     <!-- Editable user database that can also be used by
>          UserDatabaseRealm to authenticate users
>     -->
>     <Resource name="UserDatabase" auth="Container"
>               type="org.apache.catalina.UserDatabase"
>               description="User database that can be updated and
>  saved"
>               factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
>               pathname="conf/tomcat-users.xml" />
>   </GlobalNamingResources>
> 
>   <!-- A "Service" is a collection of one or more "Connectors" that share
>        a single "Container" Note:  A "Service" is not itself a "Container", 
>        so you may not define subcomponents such as "Valves" at this level.
>        Documentation at /docs/config/service.html
>    -->
>   <Service name="Catalina">
>  
>     <!--The connectors can use a shared executor, you can define one or more named thread pools-->
>     <!--
>    
>  <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
>         maxThreads="150" minSpareThreads="4"/>
>     -->
>    
>    
>     <!-- A "Connector" represents an endpoint by which requests are received
>          and responses are returned. Documentation at :
>          Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
>          Java AJP  Connector: /docs/config/ajp.html
>          APR (HTTP/AJP) Connector: /docs/apr.html
>          Define a non-SSL HTTP/1.1 Connector on port 8080
>     -->
>     <Connector port="8080" maxThreads="0" acceptCount="1"
>  protocol="HTTP/1.1" 
>                connectionTimeout="20000" 
>                redirectPort="8443" />
> 
>     <!-- Define an AJP 1.3 Connector on port 8009 -->
>     <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
> 
> 
>     <!-- An Engine represents the entry point (within Catalina) that processes
>          every request.  The Engine implementation for Tomcat stand alone
>          analyzes the HTTP headers included with the request, and passes them
>          on to the appropriate Host (virtual host).
>          Documentation at /docs/config/engine.html
>  -->
> 
>     <!-- You should set jvmRoute to support load-balancing via AJP ie :
>     <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">        
>     --> 
>     <Engine name="Catalina" defaultHost="localhost">
> 
> 
>       <!-- This Realm uses the UserDatabase configured in the global JNDI
>            resources under the key "UserDatabase".  Any edits
>            that are performed against this UserDatabase are immediately
>            available for use by the Realm.  -->
>       <Realm
>  className="org.apache.catalina.realm.UserDatabaseRealm"
>              resourceName="UserDatabase"/>
> 
>       <!-- Define the default virtual host
>            Note: XML Schema validation will not work with Xerces 2.2.
>        -->
>       <Host name="localhost"  appBase="webapps"
>             unpackWARs="true" autoDeploy="true"
>             xmlValidation="false" xmlNamespaceAware="false">
> 
> 
>       </Host>
>     </Engine>
>   </Service>
> </Server>
> 
> 
> 
> 
> 
> 
> 
> ________________________________
>  From: Christopher Schultz <ch...@christopherschultz.net>
> To: Tomcat Users List <us...@tomcat.apache.org> 
> Sent: Thursday, January 17, 2013 6:57 PM
> Subject: Re: Can not understand how maxThreads of Connectors works
>  
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> André,
> 
> On 1/17/13 3:32 AM, André Warnier wrote:
>> Quite a few messages ago, I asked the OP if he could copy/paste
>> his server.xml.
> 
> Yes. Getting information from the OP seems to be difficult.
> 
>> The reason was that if his config uses an Executor, then I believe
>> the Threads settings in the Connectors don't really matter, do they
>> ?
> 
> Correct: setting executor="someExecutor" means that any
> executor-related settings on the <Connector> will be ignored in favor
> of those set in the <Connector>.
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
> 
> iEYEAREIAAYFAlD4LX4ACgkQ9CaO5/Lv0PAzegCgtxrX5Yx2V0UlEiDI1hK/vK+H
> u20AmwWQz6+LToA3uPSSb8V1+kdPMY3N
> =9fQb
> -----END PGP
>  SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

Re: Fw: Can not understand how maxThreads of Connectors works

Posted by Hermes Flying <fl...@yahoo.com>.
The web application works.I can not see any issue. What does this mean?



________________________________
 From: Mark Thomas <ma...@apache.org>
To: Tomcat Users List <us...@tomcat.apache.org> 
Sent: Monday, January 21, 2013 11:06 AM
Subject: Re: Fw: Can not understand how maxThreads of Connectors works
 
On 21/01/2013 07:07, Hermes Flying wrote:
> 
> Hi,
> Is there any update on this? I don't see any problem setting maxThreads=0

And if you try making a request with a Tomcat instance that uses that
configuration?

Mark


> 
> Thank you
> 
> 
> ----- Forwarded Message -----
> From: Hermes Flying <fl...@yahoo.com>
> To: Tomcat Users List <us...@tomcat.apache.org> 
> Sent: Friday, January 18, 2013 8:55 AM
> Subject: Re: Can not understand how maxThreads of Connectors works
>  
> 
> Hi Chris,
> Tried with this simple server.xml and maxThreads=0 but I did not see any kind of errors.Attached the catalina logs
> 
> <?xml version='1.0' encoding='utf-8'?>
> <Server port="8005" shutdown="SHUTDOWN">
> 
>   <!--APR library loader. Documentation at /docs/apr.html -->
>   <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
>   <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
>   <Listener className="org.apache.catalina.core.JasperListener" />
>   <!-- Prevent memory leaks due to use of particular java/javax APIs-->
>   <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
>   <!-- JMX Support for the Tomcat server.
>  Documentation at /docs/non-existent.html -->
>   <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
>   <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
> 
>   <!-- Global JNDI resources
>        Documentation at /docs/jndi-resources-howto.html
>   -->
>   <GlobalNamingResources>
>     <!-- Editable user database that can also be used by
>          UserDatabaseRealm to authenticate users
>     -->
>     <Resource name="UserDatabase" auth="Container"
>               type="org.apache.catalina.UserDatabase"
>               description="User database that can be updated and
>  saved"
>               factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
>               pathname="conf/tomcat-users.xml" />
>   </GlobalNamingResources>
> 
>   <!-- A "Service" is a collection of one or more "Connectors" that share
>        a single "Container" Note:  A "Service" is not itself a "Container", 
>        so you may not define subcomponents such as "Valves" at this level.
>        Documentation at /docs/config/service.html
>    -->
>   <Service name="Catalina">
>  
>     <!--The connectors can use a shared executor, you can define one or more named thread pools-->
>     <!--
>    
>  <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
>         maxThreads="150" minSpareThreads="4"/>
>     -->
>    
>    
>     <!-- A "Connector" represents an endpoint by which requests are received
>          and responses are returned. Documentation at :
>          Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
>          Java AJP  Connector: /docs/config/ajp.html
>          APR (HTTP/AJP) Connector: /docs/apr.html
>          Define a non-SSL HTTP/1.1 Connector on port 8080
>     -->
>     <Connector port="8080" maxThreads="0" acceptCount="1"
>  protocol="HTTP/1.1" 
>                connectionTimeout="20000" 
>                redirectPort="8443" />
> 
>     <!-- Define an AJP 1.3 Connector on port 8009 -->
>     <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
> 
> 
>     <!-- An Engine represents the entry point (within Catalina) that processes
>          every request.  The Engine implementation for Tomcat stand alone
>          analyzes the HTTP headers included with the request, and passes them
>          on to the appropriate Host (virtual host).
>          Documentation at /docs/config/engine.html
>  -->
> 
>     <!-- You should set jvmRoute to support load-balancing via AJP ie :
>     <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">        
>     --> 
>     <Engine name="Catalina" defaultHost="localhost">
> 
> 
>       <!-- This Realm uses the UserDatabase configured in the global JNDI
>            resources under the key "UserDatabase".  Any edits
>            that are performed against this UserDatabase are immediately
>            available for use by the Realm.  -->
>       <Realm
>  className="org.apache.catalina.realm.UserDatabaseRealm"
>              resourceName="UserDatabase"/>
> 
>       <!-- Define the default virtual host
>            Note: XML Schema validation will not work with Xerces 2.2.
>        -->
>       <Host name="localhost"  appBase="webapps"
>             unpackWARs="true" autoDeploy="true"
>             xmlValidation="false" xmlNamespaceAware="false">
> 
> 
>       </Host>
>     </Engine>
>   </Service>
> </Server>
> 
> 
> 
> 
> 
> 
> 
> ________________________________
>  From: Christopher Schultz <ch...@christopherschultz.net>
> To: Tomcat Users List <us...@tomcat.apache.org> 
> Sent: Thursday, January 17, 2013 6:57 PM
> Subject: Re: Can not understand how maxThreads of Connectors works
>  
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> André,
> 
> On 1/17/13 3:32 AM, André Warnier wrote:
>> Quite a few messages ago, I asked the OP if he could copy/paste
>> his server.xml.
> 
> Yes. Getting information from the OP seems to be difficult.
> 
>> The reason was that if his config uses an Executor, then I believe
>> the Threads settings in the Connectors don't really matter, do they
>> ?
> 
> Correct: setting executor="someExecutor" means that any
> executor-related settings on the <Connector> will be ignored in favor
> of those set in the <Connector>.
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
> 
> iEYEAREIAAYFAlD4LX4ACgkQ9CaO5/Lv0PAzegCgtxrX5Yx2V0UlEiDI1hK/vK+H
> u20AmwWQz6+LToA3uPSSb8V1+kdPMY3N
> =9fQb
> -----END PGP
>  SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

Re: Fw: Can not understand how maxThreads of Connectors works

Posted by Mark Thomas <ma...@apache.org>.
On 21/01/2013 07:07, Hermes Flying wrote:
> 
> Hi,
> Is there any update on this? I don't see any problem setting maxThreads=0

And if you try making a request with a Tomcat instance that uses that
configuration?

Mark


> 
> Thank you
> 
> 
> ----- Forwarded Message -----
> From: Hermes Flying <fl...@yahoo.com>
> To: Tomcat Users List <us...@tomcat.apache.org> 
> Sent: Friday, January 18, 2013 8:55 AM
> Subject: Re: Can not understand how maxThreads of Connectors works
>  
> 
> Hi Chris,
> Tried with this simple server.xml and maxThreads=0 but I did not see any kind of errors.Attached the catalina logs
> 
> <?xml version='1.0' encoding='utf-8'?>
> <Server port="8005" shutdown="SHUTDOWN">
> 
>   <!--APR library loader. Documentation at /docs/apr.html -->
>   <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
>   <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
>   <Listener className="org.apache.catalina.core.JasperListener" />
>   <!-- Prevent memory leaks due to use of particular java/javax APIs-->
>   <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
>   <!-- JMX Support for the Tomcat server.
>  Documentation at /docs/non-existent.html -->
>   <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
>   <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
> 
>   <!-- Global JNDI resources
>        Documentation at /docs/jndi-resources-howto.html
>   -->
>   <GlobalNamingResources>
>     <!-- Editable user database that can also be used by
>          UserDatabaseRealm to authenticate users
>     -->
>     <Resource name="UserDatabase" auth="Container"
>               type="org.apache.catalina.UserDatabase"
>               description="User database that can be updated and
>  saved"
>               factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
>               pathname="conf/tomcat-users.xml" />
>   </GlobalNamingResources>
> 
>   <!-- A "Service" is a collection of one or more "Connectors" that share
>        a single "Container" Note:  A "Service" is not itself a "Container", 
>        so you may not define subcomponents such as "Valves" at this level.
>        Documentation at /docs/config/service.html
>    -->
>   <Service name="Catalina">
>   
>     <!--The connectors can use a shared executor, you can define one or more named thread pools-->
>     <!--
>    
>  <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
>         maxThreads="150" minSpareThreads="4"/>
>     -->
>     
>     
>     <!-- A "Connector" represents an endpoint by which requests are received
>          and responses are returned. Documentation at :
>          Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
>          Java AJP  Connector: /docs/config/ajp.html
>          APR (HTTP/AJP) Connector: /docs/apr.html
>          Define a non-SSL HTTP/1.1 Connector on port 8080
>     -->
>     <Connector port="8080" maxThreads="0" acceptCount="1"
>  protocol="HTTP/1.1" 
>                connectionTimeout="20000" 
>                redirectPort="8443" />
> 
>     <!-- Define an AJP 1.3 Connector on port 8009 -->
>     <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
> 
> 
>     <!-- An Engine represents the entry point (within Catalina) that processes
>          every request.  The Engine implementation for Tomcat stand alone
>          analyzes the HTTP headers included with the request, and passes them
>          on to the appropriate Host (virtual host).
>          Documentation at /docs/config/engine.html
>  -->
> 
>     <!-- You should set jvmRoute to support load-balancing via AJP ie :
>     <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">         
>     --> 
>     <Engine name="Catalina" defaultHost="localhost">
> 
> 
>       <!-- This Realm uses the UserDatabase configured in the global JNDI
>            resources under the key "UserDatabase".  Any edits
>            that are performed against this UserDatabase are immediately
>            available for use by the Realm.  -->
>       <Realm
>  className="org.apache.catalina.realm.UserDatabaseRealm"
>              resourceName="UserDatabase"/>
> 
>       <!-- Define the default virtual host
>            Note: XML Schema validation will not work with Xerces 2.2.
>        -->
>       <Host name="localhost"  appBase="webapps"
>             unpackWARs="true" autoDeploy="true"
>             xmlValidation="false" xmlNamespaceAware="false">
> 
> 
>       </Host>
>     </Engine>
>   </Service>
> </Server>
> 
> 
> 
> 
> 
> 
> 
> ________________________________
>  From: Christopher Schultz <ch...@christopherschultz.net>
> To: Tomcat Users List <us...@tomcat.apache.org> 
> Sent: Thursday, January 17, 2013 6:57 PM
> Subject: Re: Can not understand how maxThreads of Connectors works
>  
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> André,
> 
> On 1/17/13 3:32 AM, André Warnier wrote:
>> Quite a few messages ago, I asked the OP if he could copy/paste
>> his server.xml.
> 
> Yes. Getting information from the OP seems to be difficult.
> 
>> The reason was that if his config uses an Executor, then I believe
>> the Threads settings in the Connectors don't really matter, do they
>> ?
> 
> Correct: setting executor="someExecutor" means that any
> executor-related settings on the <Connector> will be ignored in favor
> of those set in the <Connector>.
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
> 
> iEYEAREIAAYFAlD4LX4ACgkQ9CaO5/Lv0PAzegCgtxrX5Yx2V0UlEiDI1hK/vK+H
> u20AmwWQz6+LToA3uPSSb8V1+kdPMY3N
> =9fQb
> -----END PGP
>  SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Fw: Can not understand how maxThreads of Connectors works

Posted by Hermes Flying <fl...@yahoo.com>.
Hi,
Is there any update on this? I don't see any problem setting maxThreads=0

Thank you


----- Forwarded Message -----
From: Hermes Flying <fl...@yahoo.com>
To: Tomcat Users List <us...@tomcat.apache.org> 
Sent: Friday, January 18, 2013 8:55 AM
Subject: Re: Can not understand how maxThreads of Connectors works
 

Hi Chris,
Tried with this simple server.xml and maxThreads=0 but I did not see any kind of errors.Attached the catalina logs

<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">

  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <!-- JMX Support for the Tomcat server.
 Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and
 saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container", 
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">
  
    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
   
 <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
        maxThreads="150" minSpareThreads="4"/>
    -->
    
    
    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8080" maxThreads="0" acceptCount="1"
 protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html
 -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">         
    --> 
    <Engine name="Catalina" defaultHost="localhost">


      <!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm.  -->
      <Realm
 className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">


      </Host>
    </Engine>
  </Service>
</Server>







________________________________
 From: Christopher Schultz <ch...@christopherschultz.net>
To: Tomcat Users List <us...@tomcat.apache.org> 
Sent: Thursday, January 17, 2013 6:57 PM
Subject: Re: Can not understand how maxThreads of Connectors works
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

André,

On 1/17/13 3:32 AM, André Warnier wrote:
> Quite a few messages ago, I asked the OP if he could copy/paste
> his server.xml.

Yes. Getting information from the OP seems to be difficult.

> The reason was that if his config uses an Executor, then I believe
> the Threads settings in the Connectors don't really matter, do they
> ?

Correct: setting executor="someExecutor" means that any
executor-related settings on the <Connector> will be ignored in favor
of those set in the <Connector>.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlD4LX4ACgkQ9CaO5/Lv0PAzegCgtxrX5Yx2V0UlEiDI1hK/vK+H
u20AmwWQz6+LToA3uPSSb8V1+kdPMY3N
=9fQb
-----END PGP
 SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

Re: Can not understand how maxThreads of Connectors works

Posted by Hermes Flying <fl...@yahoo.com>.
Hi Chris,
Tried with this simple server.xml and maxThreads=0 but I did not see any kind of errors.Attached the catalina logs

<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">

  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container", 
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">
  
    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
        maxThreads="150" minSpareThreads="4"/>
    -->
    
    
    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8080" maxThreads="0" acceptCount="1" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">         
    --> 
    <Engine name="Catalina" defaultHost="localhost">


      <!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm.  -->
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">


      </Host>
    </Engine>
  </Service>
</Server>







________________________________
 From: Christopher Schultz <ch...@christopherschultz.net>
To: Tomcat Users List <us...@tomcat.apache.org> 
Sent: Thursday, January 17, 2013 6:57 PM
Subject: Re: Can not understand how maxThreads of Connectors works
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

André,

On 1/17/13 3:32 AM, André Warnier wrote:
> Quite a few messages ago, I asked the OP if he could copy/paste
> his server.xml.

Yes. Getting information from the OP seems to be difficult.

> The reason was that if his config uses an Executor, then I believe
> the Threads settings in the Connectors don't really matter, do they
> ?

Correct: setting executor="someExecutor" means that any
executor-related settings on the <Connector> will be ignored in favor
of those set in the <Connector>.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlD4LX4ACgkQ9CaO5/Lv0PAzegCgtxrX5Yx2V0UlEiDI1hK/vK+H
u20AmwWQz6+LToA3uPSSb8V1+kdPMY3N
=9fQb
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

Re: Can not understand how maxThreads of Connectors works

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

André,

On 1/17/13 3:32 AM, André Warnier wrote:
> Quite a few messages ago, I asked the OP if he could copy/paste
> his server.xml.

Yes. Getting information from the OP seems to be difficult.

> The reason was that if his config uses an Executor, then I believe
> the Threads settings in the Connectors don't really matter, do they
> ?

Correct: setting executor="someExecutor" means that any
executor-related settings on the <Connector> will be ignored in favor
of those set in the <Connector>.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlD4LX4ACgkQ9CaO5/Lv0PAzegCgtxrX5Yx2V0UlEiDI1hK/vK+H
u20AmwWQz6+LToA3uPSSb8V1+kdPMY3N
=9fQb
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Can not understand how maxThreads of Connectors works

Posted by André Warnier <aw...@ice-sa.com>.
Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> Hermes,
> 
> On 1/16/13 3:07 PM, Hermes Flying wrote:
>> I believe acceptCount can not work with value 0 because if I am
>> not wrong, the acceptCount is the value passed as backlog in the 
>> ServerSocket constructor. According to javadoc if the backlog
>> value is less than or equal to 0, then a default value is used
>> instead which is 50. So acceptCount=0 does not mean that backlog
>> queue does not queue anything. That is why I used the value 1
>> instead.
> 
> Fair enough.
> 
>> Also when I say I was expecting a network failure (bad terminology)
>> I meant that the client would get a failure in the TCP attempt to 
>> connect.
> 
> Okay.
> 
>> Also I used maxThreads=0 and the server worked fine. Did not see
>> any problem in my applications. Did not check the logs though. I
>> assumed that perhaps 0 would be set to some default value. Can not
>> answer about your observation. It also makes me wonder.
> 
> Sure you can answer about my observation: look at your log files.
> 
>> Finally concerning my test setup, I need to configure Tomcat to
>> limit the amount of concurrent client requests accepted.
> 
> I understand that from reading your initial post.
> 
>> I need to configure it so that e.g. 300 concurrent clients can 
>> connect but the 301 will not be able to connect (not queued by OS 
>> either). That client will see a failure to connect to server in
>> TCP level.
> 
> I understand your requirements (though I think they are silly).
> 
>> Do you need more info on this?
> 
> I was asking about your test setup. You said you made 2 simultaneous
> requests with what seems to be an effective throughput of 2
> simultaneous requests (1 in-process and 1 in the queue) and were
> surprised that you got responses. I was not surprised. Are you still
> surprised?
> 
> Next, how are you making those two simultaneous requests
> (specifically: like, are you using some tool to do it or did you write
> your own code)? What happens if you have maxThreads=1 and
> acceptCount=1 and you make 10 simultaneous requests? 100?
> 

Quite a few messages ago, I asked the OP if he could copy/paste his server.xml.
The reason was that if his config uses an Executor, then I believe the Threads settings in 
the Connectors don't really matter, do they ?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Can not understand how maxThreads of Connectors works

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hermes,

On 1/16/13 3:07 PM, Hermes Flying wrote:
> I believe acceptCount can not work with value 0 because if I am
> not wrong, the acceptCount is the value passed as backlog in the 
> ServerSocket constructor. According to javadoc if the backlog
> value is less than or equal to 0, then a default value is used
> instead which is 50. So acceptCount=0 does not mean that backlog
> queue does not queue anything. That is why I used the value 1
> instead.

Fair enough.

> Also when I say I was expecting a network failure (bad terminology)
> I meant that the client would get a failure in the TCP attempt to 
> connect.

Okay.

> Also I used maxThreads=0 and the server worked fine. Did not see
> any problem in my applications. Did not check the logs though. I
> assumed that perhaps 0 would be set to some default value. Can not
> answer about your observation. It also makes me wonder.

Sure you can answer about my observation: look at your log files.

> Finally concerning my test setup, I need to configure Tomcat to
> limit the amount of concurrent client requests accepted.

I understand that from reading your initial post.

> I need to configure it so that e.g. 300 concurrent clients can 
> connect but the 301 will not be able to connect (not queued by OS 
> either). That client will see a failure to connect to server in
> TCP level.

I understand your requirements (though I think they are silly).

> Do you need more info on this?

I was asking about your test setup. You said you made 2 simultaneous
requests with what seems to be an effective throughput of 2
simultaneous requests (1 in-process and 1 in the queue) and were
surprised that you got responses. I was not surprised. Are you still
surprised?

Next, how are you making those two simultaneous requests
(specifically: like, are you using some tool to do it or did you write
your own code)? What happens if you have maxThreads=1 and
acceptCount=1 and you make 10 simultaneous requests? 100?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iEYEAREIAAYFAlD3DWcACgkQ9CaO5/Lv0PAwDwCdGGprLr1BEl3vueSsWcA3A7px
kP0AoLq23hNN8sJkcHnFJQBx+2RwP/Ka
=4dS/
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Can not understand how maxThreads of Connectors works

Posted by Hermes Flying <fl...@yahoo.com>.
Hi Chris, thanks for the reply.
Concerning your questions:
I believe acceptCount can not work with value 0 because if I am not wrong, the acceptCount is the value passed as backlog in the ServerSocket constructor. According to javadoc if the backlog value is less than or equal to 0, then a default value is used instead which is 50. So acceptCount=0 does not mean that backlog queue does not queue anything. That is why I used the value 1 instead.
Also when I say I was expecting a network failure (bad terminology) I meant that the client would get a failure in the TCP attempt to connect.
Also I used maxThreads=0 and the server worked fine. Did not see any problem in my applications. Did not check the logs though. I assumed that perhaps 0 would be set to some default value. Can not answer about your observation.It also makes me wonder.
Finally concerning my test setup, I need to configure Tomcat to limit the amount of concurrent client requests accepted. I need to configure it so that e.g. 300 concurrent clients can connect but the 301 will not be able to connect (not queued by OS either). That client will see a failure to connect to server in TCP level.
Do you need more info on this?

Best Regards




________________________________
 From: Christopher Schultz <ch...@christopherschultz.net>
To: Tomcat Users List <us...@tomcat.apache.org> 
Sent: Wednesday, January 16, 2013 7:52 PM
Subject: Re: Can not understand how maxThreads of Connectors works
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hermes,

On 1/16/13 11:01 AM, Hermes Flying wrote:
> I am trying to understand how the maxThreads attribute of
> Connectors works. I did some tests in order to configure Tomcat to
> limit the number of concurrent client requests (as asked in my
> previous mail).

Please copy anything relevant into this thread. Otherwise the archives
don't work very well.

> Did the following trivial configuration.
> 
> maxThreads=1 and acceptCount=1
> 
> Then I send 2 concurrent requests from 2 clients and both were
> served!

I would expect both to be served: one request was served immediately
(maxThreads=1) and one was queued (acceptCount=1). When the first
request was completed, the second one came out of the queue and was
served.

If you had acceptCount="0" (which may or may not be legal for your
TCP/IP stack) or you had sent 10 simultaneous connections, I would
have expected at least some of them to be dropped with a connection
error (assuming that they really are simultaneous and the response
time is long enough to cover any variance in the connection-attempt time).

Please provide more details about your test setup.

> I was expecting that one would get a network failure!

Woah, you thought you'd take-down your network? You must be running
some shaky hardware.

> I even tried maxThreads=0 and still the clients were served! How is
> this possible?

maxThreads="0" is an illegal configuration. Are you sure Tomcat
started properly? Tomcat 6+ uses an Executor whether you configure one
of not, and the StandardThreadExecutor simply passes the maxThreads
value off to Java's ThreadPoolExecutor, which will throw
IllegalArgumentException if maxThreads is 0.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iEYEAREIAAYFAlD26OcACgkQ9CaO5/Lv0PCgLQCffw+xQflDLr4Ps8vYkQkcXUYw
EZ0AoKU7bMkUJkmx21IgaRkNpQVV20dh
=9xBW
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

Re: Can not understand how maxThreads of Connectors works

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hermes,

On 1/16/13 11:01 AM, Hermes Flying wrote:
> I am trying to understand how the maxThreads attribute of
> Connectors works. I did some tests in order to configure Tomcat to
> limit the number of concurrent client requests (as asked in my
> previous mail).

Please copy anything relevant into this thread. Otherwise the archives
don't work very well.

> Did the following trivial configuration.
> 
> maxThreads=1 and acceptCount=1
> 
> Then I send 2 concurrent requests from 2 clients and both were
> served!

I would expect both to be served: one request was served immediately
(maxThreads=1) and one was queued (acceptCount=1). When the first
request was completed, the second one came out of the queue and was
served.

If you had acceptCount="0" (which may or may not be legal for your
TCP/IP stack) or you had sent 10 simultaneous connections, I would
have expected at least some of them to be dropped with a connection
error (assuming that they really are simultaneous and the response
time is long enough to cover any variance in the connection-attempt time).

Please provide more details about your test setup.

> I was expecting that one would get a network failure!

Woah, you thought you'd take-down your network? You must be running
some shaky hardware.

> I even tried maxThreads=0 and still the clients were served! How is
> this possible?

maxThreads="0" is an illegal configuration. Are you sure Tomcat
started properly? Tomcat 6+ uses an Executor whether you configure one
of not, and the StandardThreadExecutor simply passes the maxThreads
value off to Java's ThreadPoolExecutor, which will throw
IllegalArgumentException if maxThreads is 0.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iEYEAREIAAYFAlD26OcACgkQ9CaO5/Lv0PCgLQCffw+xQflDLr4Ps8vYkQkcXUYw
EZ0AoKU7bMkUJkmx21IgaRkNpQVV20dh
=9xBW
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org