Friday, February 03, 2006

How to fight network leaks in your java app

You are suffering from errors like 'too many open files' from time to time? You are using sockets all over the place in your enterprise java application? Then this might be an interessting read if you are running on linux.
Why do we get this error?
This is quite simple, you are using more file resources aka descriptors as the operating system is willing to offer for one process. Suppose you are running your enterprise application inside tomcat, then all applications inside this server can use only some amount of descriptors. I give you an idea what is using a file descriptor in the java server world: each jar file you or the server loads, each socket connection you need, each file you read or write, each font you or the JRE loads, each logfile you need, each shared object the JRE needs. Even without user apps, there is some significant amount of file descriptors open. If you have a high transaction application where each user uses sockets and have some problems with leaking, its just a matter of hours or days when your application breaks and with break i really mean break (mostly its in fact a halt of your app)

No comments:

Post a Comment