2006. 07. 14, péntek keltezéssel 16.08-kor Joachim Draeger ezt írta: > I was looking for the maximal number of threads Java is able to run I > found the answer that it is only limited by memory... > I always try to challenge propositions. Is it even a problem to have a > sleeping thread per connection? >
Several years ago, several jobs far away, I had some experience with the non-blocking socket handling vs one-thread-per-connection strategy issue. Please consider the followings to see my experiences in context: a, that was a Linux machine with a kernel from the 2.4 series (so every java thread handled as a process by the kernel) b, the best JVM of that time was the IBM 1.3.1. (java.nio was only a dream, and a weak promise) c, the application was a simple chat server, minimal input, a lots of output. With the old, one-thread-per-connection strategy we had: a, after 600-700 connection the system becamed very unstable and irresponsible, the load was between 10 and 20, the VM had grown more then 512 MB in the RAM. b, after ~800 connection the VM was unable to create any additional threads, and silently died. After I rewrote in a non-blocking fashion the same machine and VM could serve 1200-1300 connections, in a much more responsible manner. I know, that with kernels from the 2.6 series able to handle much more threads, but every context switch has a cost penalty, and if you have hundreds or thousands of threads, it can (and will) cause some pain. BR, Zsombor --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]