You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "André Warnier (tomcat)" <aw...@ice-sa.com> on 2017/01/18 11:34:54 UTC

Suggested doc change for Connectors

Hi.

This is a partial recap of the theme discussed on the list, in this thread :
http://marc.info/?l=tomcat-user&m=148473249120783&w=2

I would sugest a documentation change, basically in all pages related to Connector's 
configurations, from 9.0, and I believe all the way back to 6.0.

The change relates to the "minSpareThreads" attribute of the Connectors, such as
http://tomcat.apache.org/tomcat-7.0-doc/config/http.html

and the suggestion is based on :
http://tomcat.apache.org/migration-6.html#Connector_thread_pools

Basically, each of the Connector pages repeats the same text about this attribute :

quote

minSpareThreads	

The minimum number of threads always kept running. If not specified, the default of 10 is 
used. 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. Note 
that if an executor is configured any value set for this attribute will be recorded 
correctly but it will be reported (e.g. via JMX) as -1 to make clear that it is not used.

unquote

So,
- if there is an Executor, then this Connector attribute is ignored
- but according to the above migration guide, if there is no Executor, it is also ignored.

So basically, why have it ?

Of course, I don't know if there is some deeper code reason to keep mentioning it in the 
Connectors' documentations.  Which is why this is a suggestion.

Maybe instead, it could be made clearer that if there is no Executor, the number of 
threads associated to a Connector may keep on growing over time, up to the maxThreads 
value, and never go down again.
(And the nefarious/beneficial/neutral effects thereof ?)




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


Re: Suggested doc change for Connectors

Posted by Mark Thomas <ma...@apache.org>.
On 18/01/2017 13:02, Andr� Warnier (tomcat) wrote:
> On 18.01.2017 13:00, Mark Thomas wrote:

<snip/>

>> Maybe change the first sentence to:
>>
>> The number of idle threads Tomcat keeps available to handle new
>> requests. Note that excess idle threads are not stopped. The total
>> number of threads will therefore increase over time with an upper limit
>> of maxThreads. If you require excess idle threads to be stopped, use an
>> Executor.
>>
>> Mark
> 
> So what you are saying above, is that the "minSpareThreads" attribute in
> a Connector (without Executor) is not really being ignored.
> It is just the "shrinking" part of it that is not being done anymore,
> since tomcat 6.0.
> Is that the correct interpretation ?

Yes. That was controlled by maxSpareThreads as far as I recall and that
configuration option was removed.

> A different question : how would one go about determining how many
> resources /are/ being used by an idle thread ? (or more relevantly, by a
> couple of hundred of them)

A profiler is probably your best bet. I'd expect the answer to be
"trivially little compared to the application doing some real work"

> And yet another :
> Above, you say that "Tomcat starts another 3 threads in the background".
> When does that actually happen, in relation to "3 new connections arrive" ?
> (or maybe without a direct relation, on some separate time schedule)

However java.util.concurrent.ThreadPoolExecutor is implemented.

> I realise that these are probably somewhat pernickety questions, and
> maybe without much real-world practical importance.  But I figure that
> we may as well get to the bottom of this, while we have your expert
> attention.

Happy to help.

Mark

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


Re: Suggested doc change for Connectors

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

Andr�,

On 1/18/17 8:02 AM, Andr� Warnier (tomcat) wrote:
> So what you are saying above, is that the "minSpareThreads"
> attribute in a Connector (without Executor) is not really being
> ignored.

Right.

> It is just the "shrinking" part of it that is not being done
> anymore, since tomcat 6.0. Is that the correct interpretation ?

Well... there isn't any "maxSpareThreads" setting on a <Connector>. So
the expectation that e.g. only 10 spare threads would be kept around
is an incorrect assumption.

There is one such configuration option on <Executor> -- it's actually
"maxIdleTime" which is slightly different, but gets the job done.

> A different question : how would one go about determining how many 
> resources /are/ being used by an idle thread ? (or more relevantly,
> by a couple of hundred of them)

You are using a little memory: stack space for the thread (non-heap),
overhead for the thread itself to be managed by the JVM and/or OS,
etc. But in terms of CPU usage, the thread may as well not be there at
all.

> And yet another : Above, you say that "Tomcat starts another 3
> threads in the background". When does that actually happen, in
> relation to "3 new connections arrive" ? (or maybe without a direct
> relation, on some separate time schedule)

The background processor sees that the request for "10 idle threads
minimum" is not being fulfilled (only 7 remain! yikes!) and adds 3 new
threads to the pool.

> I realise that these are probably somewhat pernickety questions,
> and maybe without much real-world practical importance.  But I
> figure that we may as well get to the bottom of this, while we have
> your expert attention.

Ask away! Especially if it means that you are working on improving the
documentation for people who don't have as clear of an understanding.

- -chris

-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJYf6frAAoJEBzwKT+lPKRYa64P/iUEi5AtvZqMsEXQms3awsz7
O+tYWphb7QKy3b7gqP9s5BBD4vjDglm1pNMBlsNAcLtgkq8HcJ9dxuCyw2OtHzwp
yVdWmdu2qkr/lBAFuprh6gdSdnE+7Eg4qtSBmbR5sKrD7Xx+LdS1tG8smB8MeIAd
7B4bmYmpx8v1PAh3ylFF4wG7leeMiAZ8RTukyTIvTSezybLRAmBO24KhKQLm23J0
BTb2vmLjSN2UdJyhADXPnlVfCPRoiL3g78dD295qEmvomQXBq5GYlrdMLDlBOzfv
z1IZUVCMmdqZ0WGBQWlw+48dRoQ58/Do8V4ML+/500wzZ/0cFuIhGYT/bS12IcS1
B9rQTp9ZxzhCpkZzggO94n3CKWtDGEkwTJ4iDyc4CZMrXjj9NsTnuC7cHVjd2HVC
ElDwNV4kgAoHKv4MEe0H7KfG4ejjEPSZSWJnbt1dhhtB48i87bSQpZ4LmUp/Qm6w
2E0T/1xx5z/AQ7YYsLs2J1hnvXk5e7s4V+bDLih3xsfMdC7Qw3P2oSXLKC1tz2LO
JD3vEzOttiOl5fVty9A64/cR8x9afYlYhbs8aHGammj+pHnBap6ZrrU25JPx9A4a
ezp4zk6oxrJ7N/qaAFx75DgrtZuTYVHqfaUq+J/g8Qh2NQkA2Qs/pEGdWzhcmt5E
SbEK/5qerEo3WxGtB4vR
=Nkff
-----END PGP SIGNATURE-----

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


Re: Suggested doc change for Connectors

Posted by "André Warnier (tomcat)" <aw...@ice-sa.com>.
On 18.01.2017 13:00, Mark Thomas wrote:
> On 18/01/2017 11:34, Andr� Warnier (tomcat) wrote:
>> Hi.
>>
>> This is a partial recap of the theme discussed on the list, in this
>> thread :
>> http://marc.info/?l=tomcat-user&m=148473249120783&w=2
>>
>> I would sugest a documentation change, basically in all pages related to
>> Connector's configurations, from 9.0, and I believe all the way back to
>> 6.0.
>>
>> The change relates to the "minSpareThreads" attribute of the Connectors,
>> such as
>> http://tomcat.apache.org/tomcat-7.0-doc/config/http.html
>>
>> and the suggestion is based on :
>> http://tomcat.apache.org/migration-6.html#Connector_thread_pools
>>
>> Basically, each of the Connector pages repeats the same text about this
>> attribute :
>>
>> quote
>>
>> minSpareThreads
>>
>> The minimum number of threads always kept running. If not specified, the
>> default of 10 is used. 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. Note that if an executor
>> is configured any value set for this attribute will be recorded
>> correctly but it will be reported (e.g. via JMX) as -1 to make clear
>> that it is not used.
>>
>> unquote
>>
>> So,
>> - if there is an Executor, then this Connector attribute is ignored
>> - but according to the above migration guide, if there is no Executor,
>> it is also ignored.
>>
>> So basically, why have it ?
>
> Creating a thread is a relatively time consuming task.
>
> It ensures that, up to the maximum allowed threads, there are always
> minSpareThreads available to handle a spike in incoming requests.
>
> i.e.
> - Start with 10 idle threads
> - 3 new connections arrive
> - they each get handled by one of the threads
> - Tomcat starts another 3 threads in the background to bring the spare
>    pool back up to 10
> - the 3 connections complete
> - the spare pool is now 13
>
> If you want the spare pool to be reduced back down to 10 (or some other
> setting) when threads are idle then you need to use an appropriately
> configured Executor.
>
> The best settings will depend on the load profile. Keeping a thread idle
> in the background uses relatively little resources. The more 'spikey'
> your load is, the less benefit you'll get from stopping idle threads. At
> some point, the load caused by creating and stopping threads will cause
> more problems than just leaving the threads idle.
>
> Maybe change the first sentence to:
>
> The number of idle threads Tomcat keeps available to handle new
> requests. Note that excess idle threads are not stopped. The total
> number of threads will therefore increase over time with an upper limit
> of maxThreads. If you require excess idle threads to be stopped, use an
> Executor.
>
> Mark

So what you are saying above, is that the "minSpareThreads" attribute in a Connector 
(without Executor) is not really being ignored.
It is just the "shrinking" part of it that is not being done anymore, since tomcat 6.0.
Is that the correct interpretation ?

A different question : how would one go about determining how many resources /are/ being 
used by an idle thread ? (or more relevantly, by a couple of hundred of them)

And yet another :
Above, you say that "Tomcat starts another 3 threads in the background".
When does that actually happen, in relation to "3 new connections arrive" ?
(or maybe without a direct relation, on some separate time schedule)

I realise that these are probably somewhat pernickety questions, and maybe without much 
real-world practical importance.  But I figure that we may as well get to the bottom of 
this, while we have your expert attention.




>
>> Of course, I don't know if there is some deeper code reason to keep
>> mentioning it in the Connectors' documentations.  Which is why this is a
>> suggestion.
>>
>> Maybe instead, it could be made clearer that if there is no Executor,
>> the number of threads associated to a Connector may keep on growing over
>> time, up to the maxThreads value, and never go down again.
>> (And the nefarious/beneficial/neutral effects thereof ?)
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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: Suggested doc change for Connectors

Posted by Mark Thomas <ma...@apache.org>.
On 18/01/2017 11:34, Andr� Warnier (tomcat) wrote:
> Hi.
> 
> This is a partial recap of the theme discussed on the list, in this
> thread :
> http://marc.info/?l=tomcat-user&m=148473249120783&w=2
> 
> I would sugest a documentation change, basically in all pages related to
> Connector's configurations, from 9.0, and I believe all the way back to
> 6.0.
> 
> The change relates to the "minSpareThreads" attribute of the Connectors,
> such as
> http://tomcat.apache.org/tomcat-7.0-doc/config/http.html
> 
> and the suggestion is based on :
> http://tomcat.apache.org/migration-6.html#Connector_thread_pools
> 
> Basically, each of the Connector pages repeats the same text about this
> attribute :
> 
> quote
> 
> minSpareThreads   
> 
> The minimum number of threads always kept running. If not specified, the
> default of 10 is used. 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. Note that if an executor
> is configured any value set for this attribute will be recorded
> correctly but it will be reported (e.g. via JMX) as -1 to make clear
> that it is not used.
> 
> unquote
> 
> So,
> - if there is an Executor, then this Connector attribute is ignored
> - but according to the above migration guide, if there is no Executor,
> it is also ignored.
> 
> So basically, why have it ?

Creating a thread is a relatively time consuming task.

It ensures that, up to the maximum allowed threads, there are always
minSpareThreads available to handle a spike in incoming requests.

i.e.
- Start with 10 idle threads
- 3 new connections arrive
- they each get handled by one of the threads
- Tomcat starts another 3 threads in the background to bring the spare
  pool back up to 10
- the 3 connections complete
- the spare pool is now 13

If you want the spare pool to be reduced back down to 10 (or some other
setting) when threads are idle then you need to use an appropriately
configured Executor.

The best settings will depend on the load profile. Keeping a thread idle
in the background uses relatively little resources. The more 'spikey'
your load is, the less benefit you'll get from stopping idle threads. At
some point, the load caused by creating and stopping threads will cause
more problems than just leaving the threads idle.

Maybe change the first sentence to:

The number of idle threads Tomcat keeps available to handle new
requests. Note that excess idle threads are not stopped. The total
number of threads will therefore increase over time with an upper limit
of maxThreads. If you require excess idle threads to be stopped, use an
Executor.

Mark

> Of course, I don't know if there is some deeper code reason to keep
> mentioning it in the Connectors' documentations.  Which is why this is a
> suggestion.
> 
> Maybe instead, it could be made clearer that if there is no Executor,
> the number of threads associated to a Connector may keep on growing over
> time, up to the maxThreads value, and never go down again.
> (And the nefarious/beneficial/neutral effects thereof ?)
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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