Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 15D1911965 for ; Mon, 4 Aug 2014 17:57:18 +0000 (UTC) Received: (qmail 74073 invoked by uid 500); 4 Aug 2014 17:57:14 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 73993 invoked by uid 500); 4 Aug 2014 17:57:14 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 73981 invoked by uid 99); 4 Aug 2014 17:57:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Aug 2014 17:57:14 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.192.178] (HELO mail-pd0-f178.google.com) (209.85.192.178) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Aug 2014 17:57:10 +0000 Received: by mail-pd0-f178.google.com with SMTP id w10so9988723pde.23 for ; Mon, 04 Aug 2014 10:56:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=via.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=aoNzk6SLVmaqy4PYHjLbC4pVtS0FeltD8GJbVEwoYww=; b=Vzypm99Qhg8McUca69Nb9/KoQI1Aqbniwe6AjAHRKEwkCAJpaPPysoMmDKLxKABMz+ 73EeLxENEkNnRGEs7T2NBVMOg4fpR9eQIZ+dgumuZikexDPE8qk5HAkx5j4k6EAk6Cwy De9TZzpj3/nykQ9QaHFpPxST8fqSi255zUWGY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=aoNzk6SLVmaqy4PYHjLbC4pVtS0FeltD8GJbVEwoYww=; b=cs7rcY77JbGp7FaLExPhxq634Hl5/jW1F/U6XSu15LtSY2lCksr+Gvci2s+FH9zrqa 8QeZQCg386hCh5rh6q9xB/ovzC5YU4gq8FJHjgFw5FADCer+r0csaDUCZf5A+adJk4rY TxvopXe4Pd+7fo28qfxm9Ft80+lBWiN6vUZiqgbQmPOZ5PAQxNKVw2yVtDM+WBDwdepo hS4v8pr9u69SrKbsOT8ncX33fxVsUFcwF/DPCm4XiYkzobfr00Z1LcykCCdUSDG0pv1U b70KBUWAe5DZT1V5y80uvSgCEfmThRAkD0AU3TtfsS5eJwlx2In2U/DqypyB8qbAt44g HROQ== X-Gm-Message-State: ALoCoQmRRScc2trd1rl3A29eX9a6XX419GZMesEOEtaV4vn8df6gsg7mbrdMK9FDWDpNoxNnduUL MIME-Version: 1.0 X-Received: by 10.70.92.132 with SMTP id cm4mr3702065pdb.151.1407175008766; Mon, 04 Aug 2014 10:56:48 -0700 (PDT) Received: by 10.70.84.72 with HTTP; Mon, 4 Aug 2014 10:56:48 -0700 (PDT) In-Reply-To: <53DEA97E.7040904@ice-sa.com> References: <53DEA97E.7040904@ice-sa.com> Date: Mon, 4 Aug 2014 23:26:48 +0530 Message-ID: Subject: Re: Increasing incoming connection request in a queue From: Dhaval Jaiswal To: Tomcat Users List Content-Type: multipart/alternative; boundary=047d7b5d43aa88e6bb04ffd176a9 X-Virus-Checked: Checked by ClamAV on apache.org --047d7b5d43aa88e6bb04ffd176a9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Ok. Required details are as below. current configuration. >> 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(DelegatingMethodAccessorImp= l.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=C3=A9 Warnier wrote: > Hi. > > There are a number of problems with your post, which make it difficult t= o > 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=3D"8080" protocol=3D"HTTP/1.1" >> connectionTimeout=3D"20000" >> redirectPort=3D"8443" >> >> That tag is incomplete. > > > >> Resource name=3D"jdbc/DB_NAME" auth=3D"Container" type=3D"javax.sql.Data= Source" >> driverClassName=3D"org. >> postgresql.Driver" url=3D"jdbc:postgresql://IP:PORT/DB_NAME" >> username=3D"" password=3D"" >> maxActive=3D"100" maxIdle=3D"20" maxWait=3D"30000" >> validationQuery=3D"select 1" testOnBorrow=3D"true" >> removeAbandoned=3D"true" removeAbandonedTimeout=3D"120" >> logAbandoned=3D"true" /> >> >> >> > That tag is also incomplete, and it has basically nothing to do with the > tag above (nor with acceptCount or maxThreads). > > > >> Planning to add below parameters. >> >> maxThreads=3D"20000" >> acceptCount=3D"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 fo= r > 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 goin= g >> to degrade the performance if i will increase the value of acceptCount >> variable along with maxThreads. >> >> maxThreads=3D"20000" >> acceptCount=3D"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 Tomc= at > 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, ho= w > 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 situati= on > 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 happenin= g. > > 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 thread= s > 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 seco= nd) > > 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 wi= ll > 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 rectif= y > 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 wi= ll > 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 > > --047d7b5d43aa88e6bb04ffd176a9--