You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Dhaval Jaiswal <dh...@via.com> on 2014/08/03 20:58:00 UTC

Increasing incoming connection request in a queue

acceptCount variable:

Following is the current configuration in server.xml  I am using version. 6.

Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"


Resource name="jdbc/DB_NAME" auth="Container" type="javax.sql.DataSource"
        driverClassName="org.
postgresql.Driver" url="jdbc:postgresql://IP:PORT/DB_NAME"
        username="" password=""
        maxActive="100" maxIdle="20" maxWait="30000"
        validationQuery="select 1" testOnBorrow="true"
        removeAbandoned="true" removeAbandonedTimeout="120"
logAbandoned="true" />



Planning to add  below parameters.

maxThreads="20000"
acceptCount="500"



The situation I got is some times i am not getting timely response from the
outsiders. In this case i need to make the bigger queue in connection pool.

As per document and forums says default queue size of acceptCount is 100.
During the time if new connection request comes in it simply refuse it.



1)

I just do not want to refuse the new connection, but want to keep that
connection in a pool. I want to make the queue size of 500 and if possible
more than that.
What is your opinion on below configuration. Will it help me. Is it going
to degrade the performance if i will increase the value of acceptCount
variable along with maxThreads.

maxThreads="20000"
acceptCount="500"


2)

As tomcat works on FIFO (first in first out) model. Is there any way to
override the precedence of connection. I know its quite not possible.
However, in case some one has any thought on it.

Re: Increasing incoming connection request in a queue

Posted by Dhaval Jaiswal <dh...@via.com>.
Noted.

I was uncertain henceforth raised it again.


On Wed, Aug 6, 2014 at 8:06 PM, André Warnier <aw...@ice-sa.com> wrote:

> Dhaval Jaiswal wrote:
>
>> David,
>>
>> Resources are enough.
>>
>> what happened in current configurations, When I will receive more than 200
>> connections. Will it keep on hold or it will give the blank page.
>>
>> <Connector port="8080" protocol="HTTP/1.1"
>>                connectionTimeout="20000"
>>                redirectPort="8443" />
>>
>>
>>
> Rather than keep asking the same question over and over again, should you
> not make an effort at trying to *understand* what is going on, and how it
> works ?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


--

Re: Increasing incoming connection request in a queue

Posted by André Warnier <aw...@ice-sa.com>.
Dhaval Jaiswal wrote:
> David,
> 
> Resources are enough.
> 
> what happened in current configurations, When I will receive more than 200
> connections. Will it keep on hold or it will give the blank page.
> 
> <Connector port="8080" protocol="HTTP/1.1"
>                connectionTimeout="20000"
>                redirectPort="8443" />
> 
> 

Rather than keep asking the same question over and over again, should you not make an 
effort at trying to *understand* what is going on, and how it works ?


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


Re: Increasing incoming connection request in a queue

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

Dhaval,

On 8/5/14, 12:41 PM, Dhaval Jaiswal wrote:
> David,
> 
> Resources are enough.
> 
> what happened in current configurations, When I will receive more
> than 200 connections. Will it keep on hold or it will give the
> blank page.
> 
> <Connector port="8080" protocol="HTTP/1.1" 
> connectionTimeout="20000" redirectPort="8443" />

Read about these configuration settings:

acceptCount
maxConnections
maxThreads


Then go back and throw-away your "maxThreads" and instead configure an
<Executor>.

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

iQIcBAEBCAAGBQJT4XiPAAoJEBzwKT+lPKRYMzoP/AhEwR2t+79fy9/nuB/fJc0g
XRiei2B7gthk1wU+ZfYUtiAyBBACdOf7TCvrk3jlbFLzaXbPlkiKg1ytrj4paB5x
a1upVG/PtZazOY3DF1bcJ8aWZRsv8Kr0S2/hOVY20c5p2hzfgP1XuWARWA005gwz
V66T7sYBOkv++vZcu3LeONL8zu2wxh7tipjD8pHedt4WXHu/unR6BL+SNWZUIWZv
M6zbrHeKuUdghZlTtXfiorH3TcstoZgq9XbkDThTF5MKWlfNM2cIyRE0yoCWEXb8
cR2V1A5ZlpaGwDt8wtXXbSXkEibTcuUhN23LbyRNvpWB9gEc1IxBtENctnO+b0o+
D6x5ow9l4SHavJKY06gWhxzbngB9A/JKWlKrNCWs5202PbGJR5PffpdivzUBPaT2
15sFDSaDMEn4gB2VIl2uy6ice8rXOuk08bM/xuWmo71AUBuhHNILsEuaOonP1jev
eU5CMheRknIodA8VTy+/u/UZknzKo3H3JsAGynqEIikli6oQOtD9R+wm6EMR/Czc
yDIoEqdh7dxpElQrECXkm0Gvu+urm4o1P9qvbXgKKWGN2sBf8Pi+LBO1weR5WDNp
0Mcw8OoK6BOE9vY5Ln31caeS8TB8jmYekGbD41VIVfRU4ggtKq9YNCbI0YY3Xlps
JJuQ6nVPb4HFI25SqaZm
=vbOp
-----END PGP SIGNATURE-----

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


Re: Increasing incoming connection request in a queue

Posted by Dhaval Jaiswal <dh...@via.com>.
David,

Resources are enough.

what happened in current configurations, When I will receive more than 200
connections. Will it keep on hold or it will give the blank page.

<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />




On Tue, Aug 5, 2014 at 6:30 PM, David kerber <dc...@verizon.net> wrote:

> On 8/5/2014 8:49 AM, Dhaval Jaiswal wrote:
>
>> After reviewing your comments found that in below tags i have not defined
>> the maxThreads limit in Connector Port 8080. While the same exists with
>> the
>> connector port 8009. Default limit of maxThreads is 200.
>>
>> LB is communicating with tomcat on port 8080. I think by increasing
>> maxThreads limit will help me. What is your take. Is it going to create
>> any
>> performance issue If i will increase maxThreads to 10000 in connector
>> 8080.
>>
>
> That depends on your hardware.  Too many threads with not enough CPU
> and/or RAM to handle may make things worse.
>
>
>
>
>>
>> <Connector port="8080" protocol="HTTP/1.1"
>>                 connectionTimeout="20000"
>>                 redirectPort="8443" />
>>
>>
>> <Connector port="8009" protocol="AJP/1.3"
>>                 connectionTimeout="20000"
>>                 redirectPort="8443" maxThreads="10000"/>
>>
>>
>>
>>
>> On Tue, Aug 5, 2014 at 2:23 AM, Christopher Schultz <
>> chris@christopherschultz.net> wrote:
>>
>>  -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA256
>>>
>>> Dhaval,
>>>
>>> On 8/4/14, 1:56 PM, Dhaval Jaiswal wrote:
>>>
>>>> <Connector port="8080" protocol="HTTP/1.1"
>>>> connectionTimeout="20000" redirectPort="8443" />
>>>>
>>>
>>> You need to check the Tomcat configuration guide for the default
>>> settings that you are getting. It is also pretty clear which
>>> configuration attributes affect the maximum number of total and
>>> simultaneous connections, etc.
>>>
>>>
>>>>
>>>
>>>
>>>>  if you really have a problem now, or if you are just
>>>>>> speculating without
>>>>>>
>>>>> real facts. If you have a real problem, what is it ? is your Tomcat
>>>> really refusing browser connections ? if yes, does this happen all
>>>> the time, or only at specific times ?
>>>>
>>>>
>>>> It happens only at specific time. While trying to hit some api and
>>>> response did not received in time. For such request I have kept the
>>>> time out of 100 seconds (that is the requirement). As the first
>>>> request/thread itself is in waiting mode new incoming
>>>> request/thread will be very slow and after some time logout issue
>>>> will occur or it will slow down the performance for other requests
>>>> and resultant site will be loading very slow. Moreover, it will
>>>> start throwing below errors. Henceforth, decided to increase
>>>> incoming connection request. I am not sure whether acceptQueue or
>>>> some another parameter need to add.
>>>>
>>>> Caused by: java.net.SocketTimeoutException: connect timed out at
>>>> java.net.PlainSocketImpl.socketConnect(Native Method) at
>>>> java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at
>>>> java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
>>>>
>>>>
>>>>  at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
>>>
>>>> at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at
>>>> java.net.Socket.connect(Socket.java:519) at
>>>> sun.reflect.GeneratedMethodAccessor93.invoke(Unknown Source) at
>>>>
>>>>  sun.reflect.DelegatingMethodAccessorImpl.invoke(
>>> DelegatingMethodAccessorImpl.java:25)
>>>
>>>>
>>>>
>>>>  at java.lang.reflect.Method.invoke(Method.java:597)
>>>
>>> This is not enough information: you need to post the whole stack trace.
>>>
>>>  The browser clients trying to get a connection to Tomcat, or
>>>>>> the
>>>>>>
>>>>> postgres database which you seem to be using for authentication ?
>>>>
>>>> We have three tier architect. It will first try to get the
>>>> connection from web server (haporxy) to tomcat and then to
>>>> database.
>>>>
>>>
>>> Confusing.
>>>
>>> - -chris
>>> -----BEGIN PGP SIGNATURE-----
>>> Version: GnuPG v1
>>> Comment: GPGTools - http://gpgtools.org
>>> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>>>
>>> iQIcBAEBCAAGBQJT3/LSAAoJEBzwKT+lPKRYy8oP/jnUbF4db7rHr3E5Ceehl791
>>> +frtDPcfqsXe5LOyBAE0MJ/qCrjEMAFtun78ofCQnwh/Tx20hr9PAIk9MAzcOlQe
>>> jgCdwTGRTZa74McNn6xpt7gfHJLlgMDngt39Rzl7CmcvZ2V3ruwT8IC2rInRo9mM
>>> fnr2jMdMuOuzcAZTMJPm4xZhN5WEzzZFP9o0Dmwn+XC9e27ufKYg6mgPrTISyO6A
>>> 0g/MKXJKjKRM7fOd/Q+rW0SjRZUMLOekacBNbM0JHvRh+PmHDfeRmVwlqgZ9RpcC
>>> yax2J1bbf7tprLUG+tKOBEn5JoIbV10rfhNBufnRFYR2Jde4+d1Df/IWTTglzFAj
>>> F1wWDwKgSkIMk0HF5u/pF8BtiMQ8V4jmwFBEFoRS78iB+ynpdYU0Awj6ZcAB/Lnv
>>> BgrRnsYp/kWjr7ycsk1BvdKZJ1gp+lLuhVU0J2nab4jj37kfJjGwW5WWGbR3WTG9
>>> PLi+FAOOonMiGzx6FYRAum6rzCFeJll6CUE1PMFp70DQEM9WMYFDMZJEmo7BWjw0
>>> 7kNMxhopKqtsvhBO2aVtU4B2ZaV35Sucn9KNlgYa8Y1BlKx2RrvClNLk0XYObh1j
>>> 0/4JKIGjSAFNVHqsxWz/oy1+lD4sZAJ6mmii7Fud71W5n6tV88OWWxwtSRxuvtTi
>>> XJhlk43/9rqfr2yLWgE/
>>> =E3+3
>>> -----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: Increasing incoming connection request in a queue

Posted by David kerber <dc...@verizon.net>.
On 8/5/2014 8:49 AM, Dhaval Jaiswal wrote:
> After reviewing your comments found that in below tags i have not defined
> the maxThreads limit in Connector Port 8080. While the same exists with the
> connector port 8009. Default limit of maxThreads is 200.
>
> LB is communicating with tomcat on port 8080. I think by increasing
> maxThreads limit will help me. What is your take. Is it going to create any
> performance issue If i will increase maxThreads to 10000 in connector 8080.

That depends on your hardware.  Too many threads with not enough CPU 
and/or RAM to handle may make things worse.


>
>
> <Connector port="8080" protocol="HTTP/1.1"
>                 connectionTimeout="20000"
>                 redirectPort="8443" />
>
>
> <Connector port="8009" protocol="AJP/1.3"
>                 connectionTimeout="20000"
>                 redirectPort="8443" maxThreads="10000"/>
>
>
>
>
> On Tue, Aug 5, 2014 at 2:23 AM, Christopher Schultz <
> chris@christopherschultz.net> wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA256
>>
>> Dhaval,
>>
>> On 8/4/14, 1:56 PM, Dhaval Jaiswal wrote:
>>> <Connector port="8080" protocol="HTTP/1.1"
>>> connectionTimeout="20000" redirectPort="8443" />
>>
>> You need to check the Tomcat configuration guide for the default
>> settings that you are getting. It is also pretty clear which
>> configuration attributes affect the maximum number of total and
>> simultaneous connections, etc.
>>
>>>
>>
>>
>>>
>>>>> if you really have a problem now, or if you are just
>>>>> speculating without
>>> real facts. If you have a real problem, what is it ? is your Tomcat
>>> really refusing browser connections ? if yes, does this happen all
>>> the time, or only at specific times ?
>>>
>>>
>>> It happens only at specific time. While trying to hit some api and
>>> response did not received in time. For such request I have kept the
>>> time out of 100 seconds (that is the requirement). As the first
>>> request/thread itself is in waiting mode new incoming
>>> request/thread will be very slow and after some time logout issue
>>> will occur or it will slow down the performance for other requests
>>> and resultant site will be loading very slow. Moreover, it will
>>> start throwing below errors. Henceforth, decided to increase
>>> incoming connection request. I am not sure whether acceptQueue or
>>> some another parameter need to add.
>>>
>>> Caused by: java.net.SocketTimeoutException: connect timed out at
>>> java.net.PlainSocketImpl.socketConnect(Native Method) at
>>> java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at
>>> java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
>>>
>>>
>> at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
>>> at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at
>>> java.net.Socket.connect(Socket.java:519) at
>>> sun.reflect.GeneratedMethodAccessor93.invoke(Unknown Source) at
>>>
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>
>>>
>> at java.lang.reflect.Method.invoke(Method.java:597)
>>
>> This is not enough information: you need to post the whole stack trace.
>>
>>>>> The browser clients trying to get a connection to Tomcat, or
>>>>> the
>>> postgres database which you seem to be using for authentication ?
>>>
>>> We have three tier architect. It will first try to get the
>>> connection from web server (haporxy) to tomcat and then to
>>> database.
>>
>> Confusing.
>>
>> - -chris
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1
>> Comment: GPGTools - http://gpgtools.org
>> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>>
>> iQIcBAEBCAAGBQJT3/LSAAoJEBzwKT+lPKRYy8oP/jnUbF4db7rHr3E5Ceehl791
>> +frtDPcfqsXe5LOyBAE0MJ/qCrjEMAFtun78ofCQnwh/Tx20hr9PAIk9MAzcOlQe
>> jgCdwTGRTZa74McNn6xpt7gfHJLlgMDngt39Rzl7CmcvZ2V3ruwT8IC2rInRo9mM
>> fnr2jMdMuOuzcAZTMJPm4xZhN5WEzzZFP9o0Dmwn+XC9e27ufKYg6mgPrTISyO6A
>> 0g/MKXJKjKRM7fOd/Q+rW0SjRZUMLOekacBNbM0JHvRh+PmHDfeRmVwlqgZ9RpcC
>> yax2J1bbf7tprLUG+tKOBEn5JoIbV10rfhNBufnRFYR2Jde4+d1Df/IWTTglzFAj
>> F1wWDwKgSkIMk0HF5u/pF8BtiMQ8V4jmwFBEFoRS78iB+ynpdYU0Awj6ZcAB/Lnv
>> BgrRnsYp/kWjr7ycsk1BvdKZJ1gp+lLuhVU0J2nab4jj37kfJjGwW5WWGbR3WTG9
>> PLi+FAOOonMiGzx6FYRAum6rzCFeJll6CUE1PMFp70DQEM9WMYFDMZJEmo7BWjw0
>> 7kNMxhopKqtsvhBO2aVtU4B2ZaV35Sucn9KNlgYa8Y1BlKx2RrvClNLk0XYObh1j
>> 0/4JKIGjSAFNVHqsxWz/oy1+lD4sZAJ6mmii7Fud71W5n6tV88OWWxwtSRxuvtTi
>> XJhlk43/9rqfr2yLWgE/
>> =E3+3
>> -----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: Increasing incoming connection request in a queue

Posted by Dhaval Jaiswal <dh...@via.com>.
After reviewing your comments found that in below tags i have not defined
the maxThreads limit in Connector Port 8080. While the same exists with the
connector port 8009. Default limit of maxThreads is 200.

LB is communicating with tomcat on port 8080. I think by increasing
maxThreads limit will help me. What is your take. Is it going to create any
performance issue If i will increase maxThreads to 10000 in connector 8080.


<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />


<Connector port="8009" protocol="AJP/1.3"
               connectionTimeout="20000"
               redirectPort="8443" maxThreads="10000"/>




On Tue, Aug 5, 2014 at 2:23 AM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Dhaval,
>
> On 8/4/14, 1:56 PM, Dhaval Jaiswal wrote:
> > <Connector port="8080" protocol="HTTP/1.1"
> > connectionTimeout="20000" redirectPort="8443" />
>
> You need to check the Tomcat configuration guide for the default
> settings that you are getting. It is also pretty clear which
> configuration attributes affect the maximum number of total and
> simultaneous connections, etc.
>
> >
>
>
> >
> >>> if you really have a problem now, or if you are just
> >>> speculating without
> > real facts. If you have a real problem, what is it ? is your Tomcat
> > really refusing browser connections ? if yes, does this happen all
> > the time, or only at specific times ?
> >
> >
> > It happens only at specific time. While trying to hit some api and
> > response did not received in time. For such request I have kept the
> > time out of 100 seconds (that is the requirement). As the first
> > request/thread itself is in waiting mode new incoming
> > request/thread will be very slow and after some time logout issue
> > will occur or it will slow down the performance for other requests
> > and resultant site will be loading very slow. Moreover, it will
> > start throwing below errors. Henceforth, decided to increase
> > incoming connection request. I am not sure whether acceptQueue or
> > some another parameter need to add.
> >
> > Caused by: java.net.SocketTimeoutException: connect timed out at
> > java.net.PlainSocketImpl.socketConnect(Native Method) at
> > java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at
> > java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
> >
> >
> at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
> > at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at
> > java.net.Socket.connect(Socket.java:519) at
> > sun.reflect.GeneratedMethodAccessor93.invoke(Unknown Source) at
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >
> >
> at java.lang.reflect.Method.invoke(Method.java:597)
>
> This is not enough information: you need to post the whole stack trace.
>
> >>> The browser clients trying to get a connection to Tomcat, or
> >>> the
> > postgres database which you seem to be using for authentication ?
> >
> > We have three tier architect. It will first try to get the
> > connection from web server (haporxy) to tomcat and then to
> > database.
>
> Confusing.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQIcBAEBCAAGBQJT3/LSAAoJEBzwKT+lPKRYy8oP/jnUbF4db7rHr3E5Ceehl791
> +frtDPcfqsXe5LOyBAE0MJ/qCrjEMAFtun78ofCQnwh/Tx20hr9PAIk9MAzcOlQe
> jgCdwTGRTZa74McNn6xpt7gfHJLlgMDngt39Rzl7CmcvZ2V3ruwT8IC2rInRo9mM
> fnr2jMdMuOuzcAZTMJPm4xZhN5WEzzZFP9o0Dmwn+XC9e27ufKYg6mgPrTISyO6A
> 0g/MKXJKjKRM7fOd/Q+rW0SjRZUMLOekacBNbM0JHvRh+PmHDfeRmVwlqgZ9RpcC
> yax2J1bbf7tprLUG+tKOBEn5JoIbV10rfhNBufnRFYR2Jde4+d1Df/IWTTglzFAj
> F1wWDwKgSkIMk0HF5u/pF8BtiMQ8V4jmwFBEFoRS78iB+ynpdYU0Awj6ZcAB/Lnv
> BgrRnsYp/kWjr7ycsk1BvdKZJ1gp+lLuhVU0J2nab4jj37kfJjGwW5WWGbR3WTG9
> PLi+FAOOonMiGzx6FYRAum6rzCFeJll6CUE1PMFp70DQEM9WMYFDMZJEmo7BWjw0
> 7kNMxhopKqtsvhBO2aVtU4B2ZaV35Sucn9KNlgYa8Y1BlKx2RrvClNLk0XYObh1j
> 0/4JKIGjSAFNVHqsxWz/oy1+lD4sZAJ6mmii7Fud71W5n6tV88OWWxwtSRxuvtTi
> XJhlk43/9rqfr2yLWgE/
> =E3+3
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Increasing incoming connection request in a queue

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

Dhaval,

On 8/4/14, 1:56 PM, Dhaval Jaiswal wrote:
> <Connector port="8080" protocol="HTTP/1.1" 
> connectionTimeout="20000" redirectPort="8443" />

You need to check the Tomcat configuration guide for the default
settings that you are getting. It is also pretty clear which
configuration attributes affect the maximum number of total and
simultaneous connections, etc.

> 


> 
>>> if you really have a problem now, or if you are just
>>> speculating without
> real facts. If you have a real problem, what is it ? is your Tomcat
> really refusing browser connections ? if yes, does this happen all
> the time, or only at specific times ?
> 
> 
> It happens only at specific time. While trying to hit some api and
> response did not received in time. For such request I have kept the
> time out of 100 seconds (that is the requirement). As the first
> request/thread itself is in waiting mode new incoming
> request/thread will be very slow and after some time logout issue
> will occur or it will slow down the performance for other requests
> and resultant site will be loading very slow. Moreover, it will 
> start throwing below errors. Henceforth, decided to increase
> incoming connection request. I am not sure whether acceptQueue or
> some another parameter need to add.
> 
> Caused by: java.net.SocketTimeoutException: connect timed out at
> java.net.PlainSocketImpl.socketConnect(Native Method) at
> java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at
> java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
>
> 
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
> at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at
> java.net.Socket.connect(Socket.java:519) at
> sun.reflect.GeneratedMethodAccessor93.invoke(Unknown Source) at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>
> 
at java.lang.reflect.Method.invoke(Method.java:597)

This is not enough information: you need to post the whole stack trace.

>>> The browser clients trying to get a connection to Tomcat, or
>>> the
> postgres database which you seem to be using for authentication ?
> 
> We have three tier architect. It will first try to get the
> connection from web server (haporxy) to tomcat and then to
> database.

Confusing.

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

iQIcBAEBCAAGBQJT3/LSAAoJEBzwKT+lPKRYy8oP/jnUbF4db7rHr3E5Ceehl791
+frtDPcfqsXe5LOyBAE0MJ/qCrjEMAFtun78ofCQnwh/Tx20hr9PAIk9MAzcOlQe
jgCdwTGRTZa74McNn6xpt7gfHJLlgMDngt39Rzl7CmcvZ2V3ruwT8IC2rInRo9mM
fnr2jMdMuOuzcAZTMJPm4xZhN5WEzzZFP9o0Dmwn+XC9e27ufKYg6mgPrTISyO6A
0g/MKXJKjKRM7fOd/Q+rW0SjRZUMLOekacBNbM0JHvRh+PmHDfeRmVwlqgZ9RpcC
yax2J1bbf7tprLUG+tKOBEn5JoIbV10rfhNBufnRFYR2Jde4+d1Df/IWTTglzFAj
F1wWDwKgSkIMk0HF5u/pF8BtiMQ8V4jmwFBEFoRS78iB+ynpdYU0Awj6ZcAB/Lnv
BgrRnsYp/kWjr7ycsk1BvdKZJ1gp+lLuhVU0J2nab4jj37kfJjGwW5WWGbR3WTG9
PLi+FAOOonMiGzx6FYRAum6rzCFeJll6CUE1PMFp70DQEM9WMYFDMZJEmo7BWjw0
7kNMxhopKqtsvhBO2aVtU4B2ZaV35Sucn9KNlgYa8Y1BlKx2RrvClNLk0XYObh1j
0/4JKIGjSAFNVHqsxWz/oy1+lD4sZAJ6mmii7Fud71W5n6tV88OWWxwtSRxuvtTi
XJhlk43/9rqfr2yLWgE/
=E3+3
-----END PGP SIGNATURE-----

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


Re: Increasing incoming connection request in a queue

Posted by Dhaval Jaiswal <dh...@via.com>.
Ok.

Required details are as below.

current configuration.

<Connector port="8080" protocol="HTTP/1.1"
                connectionTimeout="20000"
                redirectPort="8443" />


>> if you really have a problem now, or if you are just speculating without
real facts. If you have a real problem, what is it ? is your Tomcat really
refusing browser connections ? if yes, does this happen all the time, or
only at specific times ?


It happens only at specific time. While trying to hit some api and response
did not received in time. For such request I have kept the time out of 100
seconds (that is the requirement). As the first request/thread itself is in
waiting mode new incoming request/thread will be very slow and after some
time logout issue will occur or it will slow down the performance for other
requests and resultant site will be loading very slow. Moreover, it will
start throwing below errors. Henceforth, decided to increase incoming
connection request. I am not sure whether acceptQueue or some another
parameter need to add.

Caused by: java.net.SocketTimeoutException: connect timed out
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:519)
    at sun.reflect.GeneratedMethodAccessor93.invoke(Unknown Source)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)



 >>  The browser clients trying to get a connection to Tomcat, or the
postgres database which you seem to be using for authentication ?

     We have three tier architect. It will first try to get the connection
from web server (haporxy) to tomcat and then to database.





On Mon, Aug 4, 2014 at 2:58 AM, André Warnier <aw...@ice-sa.com> wrote:

> Hi.
>
> There are  a number of problems with your post, which make it difficult to
> understand exactly what you want to know.
>
>
> Dhaval Jaiswal wrote:
>
>> acceptCount variable:
>>
>> Following is the current configuration in server.xml  I am using version.
>> 6.
>>
>> Connector port="8080" protocol="HTTP/1.1"
>>                connectionTimeout="20000"
>>                redirectPort="8443"
>>
>>  That tag is incomplete.
>
>
>
>> Resource name="jdbc/DB_NAME" auth="Container" type="javax.sql.DataSource"
>>         driverClassName="org.
>> postgresql.Driver" url="jdbc:postgresql://IP:PORT/DB_NAME"
>>         username="" password=""
>>         maxActive="100" maxIdle="20" maxWait="30000"
>>         validationQuery="select 1" testOnBorrow="true"
>>         removeAbandoned="true" removeAbandonedTimeout="120"
>> logAbandoned="true" />
>>
>>
>>
> That tag is also incomplete, and it has basically nothing to do with the
> <Connector> tag above (nor with acceptCount or maxThreads).
>
>
>
>> Planning to add  below parameters.
>>
>> maxThreads="20000"
>> acceptCount="500"
>>
>>
>>
> Where ?
>
>
>
>> The situation I got is some times i am not getting timely response from
>> the
>> outsiders.
>>
>
> What is "the outsiders" ?  The browser clients trying to get a connection
> to Tomcat, or the postgres database which you seem to be using for
> authentication ?
>
>
>  In this case i need to make the bigger queue in connection pool.
>
> What connection pool ?
>
>
>
>> As per document and forums says default queue size of acceptCount is 100.
>> During the time if new connection request comes in it simply refuse it.
>>
>>
> That has nothing to do with any "connection pool".
>
> A new connection (from a client) will be refused if :
> - all Tomcat threads of the Connector are already busy handling other
> requests
> AND
> - there are already "acceptCount" previous connection requests waiting for
> an accept in the "accept queue" of the Connector
>
>
>
>>
>> 1)
>>
>> I just do not want to refuse the new connection, but want to keep that
>> connection in a pool.
>>
>
> That does not really make sense, as a phrase.
>
>
> I want to make the queue size of 500 and if possible
>
>> more than that.
>>
>
> Why ?
>
>
>  What is your opinion on below configuration. Will it help me. Is it going
>> to degrade the performance if i will increase the value of acceptCount
>> variable along with maxThreads.
>>
>> maxThreads="20000"
>> acceptCount="500"
>>
>>
> These two parameters are not directly related, and each of those
> parameters should only be modified (compared to the default) in very
> specific circumstances.
> We cannot have an opinion on whether changing one or the other will help
> or not, before we know
> 1) if you really have a problem now, or if you are just speculating
> without real facts. If you have a real problem, what is it ? is your Tomcat
> really refusing browser connections ? if yes, does this happen all the
> time, or only at specific times ?
> 2) what is the expected load of your server ? how many clients are
> expected to connect to your server at the same time ? how many HTTP
> requests are you expecting to have to process at the same time ? how long
> does it take, on average, to process one request ?
> 3) what are the characteristics of your server ? (how fast is the CPU, how
> much memory does it have, how much of that is available to Tomcat)
>
> etc..
>
> Here are some general tips :
>
> 1) the default parameters of Tomcat are set by people who know what they
> are doing, in a way that they determine is appropriate for the large
> majority of practical cases.
> There are thousands of Tomcats which are running fine on the WWW, using
> these default parameters.  Changing them without knowing why, and without
> konwing exactly what effect they have, is more likely to make the situation
> worse, than improving it.
>
> 2) to determine if you need to change a parameter, and which parameter to
> change and how to change it, you need first to *measure* what is happening.
>
> 2) the "acceptCount" of the Connector is a parameter which relates to the
> TCP/IP stack of your machine.  Tomcat just passes this parameter to the
> underlying OS, when it opens the TCP socket which is used by this
> Connector.  It is the TCP/IP stack of the OS which is going to refuse new
> client connections, if the "accept queue" fills up.
> The "accept queue" fills up, when Tomcat (for any of many possible
> reasons) cannot handle anymore the number of client requests which arrive
> over a period of time.
>
> 3) the "maxThreads" parameter of a Connector, represents how many threads
> maximum, this Connector can start at the same time.  Each of those threads
> handles one request of one client. So, *if you know* :
> a) that it takes on average 1 second for your Tomcat (and your webapp) to
> process one request
> b) that, sometimes, there can be 300 clients sending one request each to
> your Tomcat over 1 second (for a total of 300 requests over the same second)
>
> then, you would know that you need to set the maxThreads parameter to (at
> least) 300.
>
> If processing one request takes on average 2 seconds, then if during 1
> second Tomcat can receive 300 requests, you will need to set maxThreads
> higher (because at the end of this first second, the first 300 threads will
> still be busy; and another series of 300 requests is coming in, and there
> are no available (non-busy) threads to handle them).
>
> But of course, each running thread uses up some resources (CPU, memory),
> so the maximum number of threads that you can effectively set will depend
> on the total resources available on your machine.
>
> 4) when Tomcat cannot handle the volume of requests which clients are
> sending to it, there can be a number of reasons, such as :
> - the maximum number of threads (maxThreads) is not high enough
> - the application is "too slow" (meaning: it takes longer than you think,
> to process one request)
> - there is not enough memory
> - the CPU is too slow
> - the Java JVM is not properly configured
> - some parameter is not set correctly
> etc.. etc.. etc..
> You need to find out which one of the above is the cause, and then rectify
> that cause.
> Changing a parameter randomly is not the good way to go.
> Changing more than one parameter at a time is even worse, because many of
> these parameters have indirect effects on one another.
>
> 5) if the problem is that Tomcat cannot handle the volume of requests,
> then increasing the size of the accept queue is not going to help.  It will
> only delay a bit more the "server busy" message that the clients will
> receive, which will frustrate them even more.
>
>
>
>
>> 2)
>>
>> As tomcat works on FIFO (first in first out) model. Is there any way to
>> override the precedence of connection.
>>
>
> No.
> In any case, what would be the point, and how would you determine which
> connection request should be handled in priority compared to any other ?
>
>
> I know its quite not possible.
>
>> However, in case some one has any thought on it.
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Increasing incoming connection request in a queue

Posted by André Warnier <aw...@ice-sa.com>.
Hi.

There are  a number of problems with your post, which make it difficult to understand 
exactly what you want to know.

Dhaval Jaiswal wrote:
> acceptCount variable:
> 
> Following is the current configuration in server.xml  I am using version. 6.
> 
> Connector port="8080" protocol="HTTP/1.1"
>                connectionTimeout="20000"
>                redirectPort="8443"
> 
That tag is incomplete.

> 
> Resource name="jdbc/DB_NAME" auth="Container" type="javax.sql.DataSource"
>         driverClassName="org.
> postgresql.Driver" url="jdbc:postgresql://IP:PORT/DB_NAME"
>         username="" password=""
>         maxActive="100" maxIdle="20" maxWait="30000"
>         validationQuery="select 1" testOnBorrow="true"
>         removeAbandoned="true" removeAbandonedTimeout="120"
> logAbandoned="true" />
> 
> 

That tag is also incomplete, and it has basically nothing to do with the <Connector> tag 
above (nor with acceptCount or maxThreads).

> 
> Planning to add  below parameters.
> 
> maxThreads="20000"
> acceptCount="500"
> 
> 

Where ?

> 
> The situation I got is some times i am not getting timely response from the
> outsiders.

What is "the outsiders" ?  The browser clients trying to get a connection to Tomcat, or 
the postgres database which you seem to be using for authentication ?

  In this case i need to make the bigger queue in connection pool.

What connection pool ?

> 
> As per document and forums says default queue size of acceptCount is 100.
> During the time if new connection request comes in it simply refuse it.
> 

That has nothing to do with any "connection pool".

A new connection (from a client) will be refused if :
- all Tomcat threads of the Connector are already busy handling other requests
AND
- there are already "acceptCount" previous connection requests waiting for an accept in 
the "accept queue" of the Connector

> 
> 
> 1)
> 
> I just do not want to refuse the new connection, but want to keep that
> connection in a pool. 

That does not really make sense, as a phrase.

I want to make the queue size of 500 and if possible
> more than that.

Why ?

> What is your opinion on below configuration. Will it help me. Is it going
> to degrade the performance if i will increase the value of acceptCount
> variable along with maxThreads.
> 
> maxThreads="20000"
> acceptCount="500"
> 

These two parameters are not directly related, and each of those parameters should only be 
modified (compared to the default) in very specific circumstances.
We cannot have an opinion on whether changing one or the other will help or not, before we 
know
1) if you really have a problem now, or if you are just speculating without real facts. If 
you have a real problem, what is it ? is your Tomcat really refusing browser connections ? 
if yes, does this happen all the time, or only at specific times ?
2) what is the expected load of your server ? how many clients are expected to connect to 
your server at the same time ? how many HTTP requests are you expecting to have to process 
at the same time ? how long does it take, on average, to process one request ?
3) what are the characteristics of your server ? (how fast is the CPU, how much memory 
does it have, how much of that is available to Tomcat)

etc..

Here are some general tips :

1) the default parameters of Tomcat are set by people who know what they are doing, in a 
way that they determine is appropriate for the large majority of practical cases.
There are thousands of Tomcats which are running fine on the WWW, using these default 
parameters.  Changing them without knowing why, and without konwing exactly what effect 
they have, is more likely to make the situation worse, than improving it.

2) to determine if you need to change a parameter, and which parameter to change and how 
to change it, you need first to *measure* what is happening.

2) the "acceptCount" of the Connector is a parameter which relates to the TCP/IP stack of 
your machine.  Tomcat just passes this parameter to the underlying OS, when it opens the 
TCP socket which is used by this Connector.  It is the TCP/IP stack of the OS which is 
going to refuse new client connections, if the "accept queue" fills up.
The "accept queue" fills up, when Tomcat (for any of many possible reasons) cannot handle 
anymore the number of client requests which arrive over a period of time.

3) the "maxThreads" parameter of a Connector, represents how many threads maximum, this 
Connector can start at the same time.  Each of those threads handles one request of one 
client. So, *if you know* :
a) that it takes on average 1 second for your Tomcat (and your webapp) to process one request
b) that, sometimes, there can be 300 clients sending one request each to your Tomcat over 
1 second (for a total of 300 requests over the same second)

then, you would know that you need to set the maxThreads parameter to (at least) 300.

If processing one request takes on average 2 seconds, then if during 1 second Tomcat can 
receive 300 requests, you will need to set maxThreads higher (because at the end of this 
first second, the first 300 threads will still be busy; and another series of 300 requests 
is coming in, and there are no available (non-busy) threads to handle them).

But of course, each running thread uses up some resources (CPU, memory), so the maximum 
number of threads that you can effectively set will depend on the total resources 
available on your machine.

4) when Tomcat cannot handle the volume of requests which clients are sending to it, there 
can be a number of reasons, such as :
- the maximum number of threads (maxThreads) is not high enough
- the application is "too slow" (meaning: it takes longer than you think, to process one 
request)
- there is not enough memory
- the CPU is too slow
- the Java JVM is not properly configured
- some parameter is not set correctly
etc.. etc.. etc..
You need to find out which one of the above is the cause, and then rectify that cause.
Changing a parameter randomly is not the good way to go.
Changing more than one parameter at a time is even worse, because many of these parameters 
have indirect effects on one another.

5) if the problem is that Tomcat cannot handle the volume of requests, then increasing the 
size of the accept queue is not going to help.  It will only delay a bit more the "server 
busy" message that the clients will receive, which will frustrate them even more.


> 
> 2)
> 
> As tomcat works on FIFO (first in first out) model. Is there any way to
> override the precedence of connection. 

No.
In any case, what would be the point, and how would you determine which connection request 
should be handled in priority compared to any other ?

I know its quite not possible.
> However, in case some one has any thought on it.
> 



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