tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Cartwright <John.C.Cartwri...@noaa.gov>
Subject Re: java.net.SocketException: Too many open files
Date Wed, 03 Jun 2009 20:15:43 GMT
Thanks for your suggestions Martin, I'll look into modifying the memory 
parameters.  Strange thing is that this has been running for weeks w/o 
any changes in the configuration or contexts.

--john


Martin Gainty wrote:
> Here is the code
>     void acceptConnections() {
>         if( log.isDebugEnabled() )
>             log.debug("Accepting ajp connections on " + port);
>         while( running ) {
>         try{
>                 MsgContext ep=createMsgContext(packetSize);
>                 ep.setSource(this);
>                 ep.setWorkerEnv( wEnv );
>                 this.accept(ep);
>
>                 if( !running ) break;
>                 
>          // Since this is a long-running connection, we don't care about the small GC
>          //next line gac's
>                 SocketConnection ajpConn=
>                     new SocketConnection(this, ep);
>                 tp.runIt( ajpConn );
>         }catch(Exception ex) {
>                 if (running) log.warn("Exception executing accept" ,ex);
>         }
>         }
>     }
>
> where org.apache.jk.core.JkHandler.java contains the createMsgContext
>   public MsgContext createMsgContext() {
>         return new MsgContext(8*1024);
>     }
>
> which calls org.apache.jk.core.MsgContext
>     public MsgContext(int bsize) {
>         try {
>             c2b = new C2BConverter("iso-8859-1");
>         } catch(IOException iex) {
>             log.warn("Can't happen", iex);
>         }
>         jkIS = new JkInputStream(this, bsize);
>     }
>
> which calls org.apache.jk.common.JkInputStream
>     public JkInputStream(MsgContext context, int bsize) {
>         mc = context;
>         bodyMsg = new MsgAjp(bsize);
>         outputMsg = new MsgAjp(bsize);
>     }
>
> //which calls org.apache.jk.common.MsgAjp
>   private byte buf[];
>     // The current read or write position in the buffer
>     private int pos;    
>     /**
>      * This actually means different things depending on whether the
>      * packet is read or write.  For read, it's the length of the
>      * payload (excluding the header).  For write, it's the length of
>      * the packet as a whole (counting the header).  Oh, well.
>      */
>     private int len; 
>     /*** The maximum packet size*/
>     private int bufsize;
>
>     /*** Constructor that takes a buffer size*/
>     public MsgAjp(int bsize) {
>         if(bsize < 8*1024) {
>             bsize = 8*1024;
>         }
>         bufsize = bsize;
>         buf = new byte[bsize];    
>     }
> 3 possiblities
> 1)misconfig with AJP connector
>
> 2)so you're running out of heap 
> tweaking JAVA_OPT minheap and maxheap parameters would help
> a 2004 post http://forums.sun.com/thread.jspa?messageID=10055131 says it best
>
> The default stack size is 256K on UNIX and on 32-bit Windows operating systems. To set
Stack
> size
>
> java -XX:NewSize=128m -XX:MaxNewSize=128m -XX:SurvivorRatio=8  -Xms512m -Xmx512m
>
> 1. Setting the New generation heap size
>  -XX:NewSize
>  Use
> this option to set the New generation Java heap size. Set this value to
> a multiple of 1024 that is greater than 1MB. As a general rule, set
> -XX:NewSize to be one-fourth the size of the maximum heap size.
> Increase the value of this option for larger numbers of short-lived
> objects.(problem is you would have to know which objects are short-lived)
>
> Be sure to increase the New generation as you increase the number of
> processors. Memory allocation can be parallel, but garbage collection
> is not parallel.
>
> 2. Setting the maximum New generation heap size
>  -XX:MaxNewSize
> Use this option to set the maximum New generation Java heap size. Set
> this value to a multiple of 1024 that is greater than 1MB.
> (this is the ceiling for New Generation heap)
>
> 3. Setting New heap size ratios
>  -XX:SurvivorRatio
>  The New generation area is divided into three sub-areas: Eden, and two survivor spaces
that
> are equal in size. 
>
> Use the -XX:SurvivorRatio=X option to configure the ratio of the
> Eden/survivor space size. Try setting this value to 8, and then monitor
> your garbage collection.
>
> 4. Setting minimum heap size
>  -Xms
> Use this option to set the minimum size of the memory allocation pool.
> Set this value to a multiple of 1024 that is greater than 1MB. As a
> general rule, set minimum heap size (-Xms) equal to the maximum heap
> size (-Xmx) to minimize garbage collections. 
>
> 5. Setting maximum heap size
>  -Xmx
>  Use this option to set the maximum Java heap size. Set this value to a multiple of 1024
that
> is greater than 1MB.
>
> i would double all specified params (leave Survivor alone) until maxheap -Xmx reaches
AvailablePhysicalRam/2
> 2)you've maxed out HW RAM
> at which point I'd run down to local tech supply store and buy more RAM sticks (good
to wait for offhours
> ,down the server and take one of the ram sticks with you just to make sure you have a
good fit..generally safe to double..if you have 1 get another..if you have 2 get 2 more )
>
> (unless of course this is a unisys box then i would ask Unisys)
> Martin Gainty 
> ______________________________________________ 
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
>  Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein,
so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer
Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und
entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails
koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire
prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe
quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information
seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les
email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune
responsabilité pour le contenu fourni.
>
>
>
>
>   
>> Date: Wed, 3 Jun 2009 09:04:33 -0600
>> From: John.C.Cartwright@noaa.gov
>> Subject: java.net.SocketException: Too many open files
>> To: users@tomcat.apache.org
>>
>> Hello All,
>>
>> something strange happened to our tomcat 5.5 instance running on RHEL Linux.
>>
>> Suddenly we began getting the exception listed below written out to the
>> catalina.out log.  It was repeated approx 4 million times w/in a couple
>> of hours until it filled up the file system and hung tomcat.  This is a
>> pretty standard setup.  Requests come into apache and then a ProxyPass
>> forwards onto tomcat. Apache has a directive like the following for each
>> context:
>>
>> ProxyPass /gdsg               ajp://localhost:8009/gdsg
>>
>>
>> Can someone please help to to understand what might cause such an
>> exception?  Is there a good way to see the files tomcat has open?  I'm
>> not sure that a simple "lsof -u tomcat" will show them all.
>>
>> Thanks so much for the help!
>>
>> --john
>>
>> Jun 1, 2009 6:19:07 AM org.apache.jk.common.ChannelSocket acceptConnections
>> WARNING: Exception executing accept
>> java.net.SocketException: Too many open files
>>         at java.net.PlainSocketImpl.socketAccept(Native Method)
>>         at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
>>         at java.net.ServerSocket.implAccept(ServerSocket.java:450)
>>         at java.net.ServerSocket.accept(ServerSocket.java:421)
>>         at org.apache.jk.common.ChannelSocket.accept(ChannelSocket.java:312)
>>         at
>> org.apache.jk.common.ChannelSocket.acceptConnections(ChannelSocket.java:666)
>>         at
>> org.apache.jk.common.ChannelSocket$SocketAcceptor.runIt(ChannelSocket.java:876)
>>         at
>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
>>         at java.lang.Thread.run(Thread.java:595)
>>
>>  
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>     
>
> _________________________________________________________________
> Windows Live™ SkyDrive™: Get 25 GB of free online storage.
> http://windowslive.com/online/skydrive?ocid=TXT_TAGLM_WL_SD_25GB_062009
>   

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


Mime
View raw message