Help Needed Java NIO server and Tomcat 100% CPU utilization !!!!

Discussion in 'Java' started by Avizz, Dec 9, 2003.

  1. Avizz

    Avizz Guest

    PS :I am cross posting this in some more forums in hopes of getting
    some answers Please excuse me if it irritates some one

    Hi All
    I have the following setup

    Jdk1.4.1_02 ( i have tested it with JDK1.4.0 and 1.4.2 )
    Win2k SP 4 (all updates and patches made)
    Apache Tomcat/4.1.18-LE-jdk14 ( Tested on newer version too)

    I have a Async Server (listening for socket connections on one port )
    which is being init in a static block in a Servlet ,I did this as I
    need to access the Http Functionality
    of Tomcat .In other words my server shares the same process as the
    Servlet .So far so good ,things were working fine
    Until I started noticing that some times (initially once in a month)
    tomcat started taking up huge CPU resources. Driving the processor to
    100% utilization,
    The server still works but the machine becomes very slow,

    -- My first step was to introduce 'Time outs' in all the While(true)
    and places where
    there were blocking operations. As it looked more like something stuck
    in a for loop which was not ending But to my dismay the problem
    continued
    Things became worse this abnormality became more frequent

    -- Next i found that when ever the this happened , i had some
    connections in CLOSE_WAIT state ( doing netstat -a ).but when i
    emulated the problem on my local machine ,i never had 100%cpu
    utilization ,even when i had 70 - 80 CLOSE_WAIT

    -- Next i found that when the N/w Goes Down the NIO Selector's
    select() operation
    stops blocking and returns with 0 selected keys .It went into a
    infinite loop as it was in a while (true) loop ,and consumed lots of
    processing as select operation was not blocking
    I learnt that it was an acknowledged bug and i came up with a work
    around where in i recreated / re initialized the selector when ever i
    got zero selected keys (after a threshold i.e after continues 50 zero
    select operation) . This worked fine on my local machine as well as
    the production machine .I pulled out the n/w cable and reconfirmed. I
    thought that my nightmare was over

    -- But again after working fine for 3 days it has again gone into a
    loop
    no errors / no exception/ nw connectivity is fine too

    Can any one throw some light on the topic .I can not find any thing
    wrong in the code
    , and all the NIO bugs i have patched. Still it behaves abnormally.I
    have to restart the server for it to behave properly ,but it
    disconnecs all connected clients .This is not desirable.
    Is it due to the CLOSE_WAITS or the my approach to recreate selector
    is wrong (works fine for some days though) ,Or some thing I don't know
    yet any ways please let me know If any one has experienced any thing
    like this OR can add any thing you will save fellow developer from
    going insane..
    Thanks and regards
    Avizz
     
    Avizz, Dec 9, 2003
    #1
    1. Advertisements

  2. Avizz

    Mike Guest

    (Avizz) wrote in message
    I find Tomcat, along with a bunch of other Apache code mediocre and
    clumsy.
    Try Jetty, way lighter and less problamatic.

    JBoss runs a lot better I find with the Jetty version as apposed to
    the Tomcat flavor I find.
     
    Mike, Dec 10, 2003
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.