Re: singe thread per connection



Peter Duniho wrote:

Is that in Java? The limit comes from the size of the stack allocated for a thread (1MB by default) and the maximum virtual address space for a process (2GB).

Ah, Java sets a default stack size of 256K, though you can configure
as a JVM parameter (and from Java 5 onwards you can override in the
Thread constructor). Yes, now I do the calculation, that means my 5,600
threads need about 1.4Gb just for their stack space. Yerk!

It's possible that Java's NIO classes use this mechanism on Windows (known as "I/O Completion Ports"). I don't really know.

NIO uses the plain old select() function. To use I/O completion ports
you have to write native code yourself -- though I guess somebody's
released a library to do this by now. (And yes, you can get
a severalfold reduction in CPU usage compared to using NIO by doing
this.) However, if I remember my figures correctly NIO can still service
a couple of thousand connections in a few % of CPU usage on what's
nowadays a fairly average machine. So OP, if you're still listening,
NIO should be good enough for your 500 telnet connections.

Neil
.



Relevant Pages

  • Re: Scatter/Gather in Java or Javascript & html (Dynamic class loading?)
    ... constrained by the requirement to talk to a non-Java server here. ... FWIW here are my thought processes whilst deciding which Java socket client ... The only problem I saw with NIO is that Esmond has said "For example, ...
    (comp.lang.java.programmer)
  • Re: Callback-oriented socket API?
    ... It looks like the asynchronous APIs follow the old package rather closely. ... Thanks for the info...that looks like the best answer to my question (but of course unfortunately suggests it's not in Java yet:)). ... But they would still wind up using the lower-performance i/o classes. ... I look forward to seeing the new NIO 2 stuff. ...
    (comp.lang.java.programmer)
  • Re: question for use java nio to get the data from rss link?
    ... I'm wonder what you say is that when I use the httpclient jar. ... The HTTPClient offer the function of the URL of JAVA. ... I have to realize the function the HTTPClient offer with the nio? ... But my teacher ask me to get the data in the asynchronism way. ...
    (comp.lang.java.programmer)
  • Re: NIO slow (no buffering?)
    ... >> I probably yet don't understand some fundamental things about NIO. ... > reading small packs of bytes is very slow, besides that, use ... Unified I/O makes transparent buffering, ... http://uio.dev.java.net Unified I/O for Java ...
    (comp.lang.java.programmer)