On 2020-03-31 15:34, Mark Thomas wrote:
> On 31/03/2020 13:49, Aditya Kumar wrote:
>> Hi Mark,
>>
>> Sorry I'm not familiar with what a Selector is? However on one system I've
>> noticed 28000 such connections. Are these caused by client connections? I'm
>> not saying the connection originates from a client, but does the type of
>> socket get create because of client connections?
> 
> A selector is what a NIO Connector uses to "select" the socket
> connections that have data waiting to be processed out of all of the
> current connections. I'd expect a 1:1 mapping between Selectors and
> Tomcat Connectors. (It might be 2:1 to n+1:n I'd need to look at the
> code to be sure but it will be driven by listening sockets on Tomcat,
> not client connections.
> 
> It looks like something is creating selectors but not destroying them.
> That might be Tomcat code but at those numbers I think the application
> is more likely.
> 
> I recommend using a profiler to track the current number of Selectors
> and trying to work out what triggers the creation of a new one.
> 
> Mark
> 
> 
>>
>> On Tue, Mar 31, 2020 at 1:20 PM Mark Thomas <ma...@apache.org> wrote:
>>
>>> On 31/03/2020 11:20, Aditya Kumar wrote:
>>>> Tomcat 9.0.30 on Windows Server 2012 / Java 1.8
>>>>
>>>> I've noticed on a freshly installed version of tomcat 9, upon startup
>>> there
>>>> are several connections to and from localhost on different ports
>>>>
>>>> For example on my tomcat server there are 4 connections to and from
>>>> localhost (output from netstat)
>>>>
>>>>  TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING
>>>  3972
>>>>  TCP    127.0.0.1:55618        127.0.0.1:55619        ESTABLISHED
>>>  3972
>>>>  TCP    127.0.0.1:55619        127.0.0.1:55618        ESTABLISHED
>>>  3972
>>>>  TCP    127.0.0.1:55620        127.0.0.1:55621        ESTABLISHED
>>>  3972
>>>>  TCP    127.0.0.1:55621        127.0.0.1:55620        ESTABLISHED
>>>  3972
>>>>  TCP    [::]:8080              [::]:0                 LISTENING
>>>  3972
>>>>
>>>> These can grow to a large number (several thousand) on a busy system.
>>> What
>>>> are these connections used for? What caused them? What thread are they
>>>> attributed to?
>>>
>>> The Java NIO implementation on Windows uses TCP for intra-process
>>> signalling. It opens a pair of self-connected sockets for every Selector.
>>>
>>> Mark

Dear Aditya, dear all,

it's also an effect from using "modern" Java stream I/O. You might notice (by 
consulting /proc/$N/fd/) even pipe handles in addition to the socket handles. 
The worse thing I discovered that they are not necessarily released by a minor 
garbage collection (after the corresponding java "instrument" is out-of-scope) 
but may be even remain until a full gc is running! And if you're using the 
up-to-date G1 GC, then -- as an explicit aim of design -- this will run very 
seldom.

For my Tomcat (and Wildfly) instances of our "Java Application platform" I was 
forced to increase the (container) file descriptor limit a lot and in addition 
to write a watchdog which will fire an forced full GC on the JVM (via 'jcmd 
$PID GC.run') in case the number of fd is approaching the limit. This is 
because the Java heap is independed to the OS file descriptor resources and 
might not be become collected in the right time because the corresponding 
memory occupation of the related objects on the Java heap is typical right 
small.


greetings

Guido

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

Reply via email to